将TChart上的左轴设置为将十进制值增加到.13? [英] Setting the Left Axis on a TChart to increment the decimal value up to .13?

查看:133
本文介绍了将TChart上的左轴设置为将十进制值增加到.13?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与此处的另一个正在进行的问题有关:格式化石头和磅?

This question relates to another ongoing question here: Format Stones and Pounds correctly?

我认为在决定要做什么之前,在这里单独提问是更合适的。

I figured it would be more suitable to ask here as a separate question, before deciding what to do.

如上面的链接所述,我将TChart中的重量表示为石头和磅。

As described from the link above, I am representing weight in a TChart as stones and pounds.

在我决定是否更改当前正在使用的数据类型(双精度)之前,如上面的注释所示,我想看看如何在图表中显示我的图表。

Before I decide on whether to change the data type I am currently using (Double) as the comments from above suggest, I want to see how I can display my chart in Stones and Pounds as I originally had in mind.

请参阅我为演示目的操作的示例图像:

See this sample image I manipulated for demo purposes:

问题在左边图表的轴,作为图像状态中的注释-在达到下一个整数(在这种情况下为石头)之前,图表会递增至.99(磅)。例如:

The problem is the left Axis of the chart, as the notes in the image state - the chart increments up to .99 (Pounds) before reaching the next whole number (Stones in this case). For example:


  • 03.00

  • 02.99< .99 =达到3.00之前的最大数量

  • 02.98

  • 02.97

  • 03.00
  • 02.99 < .99 = max number before reaching 3.00
  • 02.98
  • 02.97

我需要像这样设置左轴:

I need the Left axis to be setup like so:


  • 03.00

  • 02.13< .13 =达到3.00之前的最大数量

  • 02.12

  • 02.11

  • 02.10

  • 03.00
  • 02.13 < .13 = max number before reaching 3.00
  • 02.12
  • 02.11
  • 02.10

,并且还显示英镑部分的所有标签。

And also display all the labels for the pounds part.

在某处有一个设置可以用来在到达下一个整数(石头)之前设置.00(磅)的最大值吗?

Is there a setting somewhere that I can use to set the max value for the .00 (lbs) before reaching the next whole number (stones)?

目前似乎没有什么从其他问题中我可以理解,我应该使用整数并仅表示磅。

At the moment nothing seems to be making a lot of sense, From what I understand from the other question is I should be using Integers and representing as Pounds only.

我想看看在进行任何更改之前它的外观,理想情况下,我希望图表尽可能与图片保持一致。

I want to see how it could look before making any changes though, ideally I want the chart to stay near the same as the image if possible.

希望这很有意义。

谢谢。

更新

我只是以为我会更新所做的更改最终得以工作。

Just thought I would update the changes I eventually got working.

所有荣誉都必须归功于David Heffernan,他坚持不懈地解释了我出了问题的地方,并写了详细资料信息和建议。

All credit has to go to David Heffernan for his persistence in explaining where I was going wrong, and writing detailed information and advice.

我仍然需要做一些工作,但是现在这是我现在拥有的更新图表:

There is still some work I need to do, but for now here is the updated chart I now have:

我还没有完成标签中的值,但是在上面的示例图中,这是我使用的值:

I have not done the values in labels, but from the sample image above this is the values I used:


  • 15.2

  • 15.3

  • 15.11

  • 15.13

  • 16.0

  • 16.4

  • 15.2
  • 15.3
  • 15.11
  • 15.13
  • 16.0
  • 16.4

推荐答案

您不能使用当前的表示法进行绘图合理的图表。假设您有一个具有以下值的条形图:

You can't use your current representation to plot a reasonable chart. Suppose you have a bar chart with the following values:


10st 12lb
10st 13lb
11st 0lb
11st 1lb

图表将如下所示:

暂时忘掉轴标签。看一下酒吧之间的区别。每个相邻值之间的差为1lb。但是图表却讲述了一个完全不同的故事。我在这里使用了条形图,但是该原理适用于所有图表类型。

Forget about the axis labelling for a moment. Look at the difference between the bars. The difference between each adjacent value is 1lb. But the graph tells a completely different story. I've used a bar chart here, but the principle applies for all chart types.

最重要的是,您需要用真实的十进制表示法表示体重值的重量。您的陈述不符合算术的基本定律。因此,半宝石必须为0.5。试图用数字0.07表示一半只是在索要一个痛苦的世界。

The bottom line is that you need to represent your weight values with a true decimal representation of the weight. Your representation does not obey basic laws of arithmetic. So, half a stone must be 0.5. Trying to represent a half with the number 0.07 is simply asking for a world of pain.

使用此公式可以将石头和磅转换为真实的浮点表示形式。重量:

Use this formula to convert from stones and pounds to a true floating point representation of the weight:

FloatingPointWeightValue := Stones + Pounds/14.0;

或者,如果您仅存储英镑,那就简单了

Or if you store only the pounds then it is simply

FloatingPointWeightValue := Pounds/14.0;

我建议您确保增量至少为1。如果需要缩小,则必须进入自定义轴标签标题。当您添加值时,给它们加上标签。这将允许图表使用明智的标签来标识值。例如:

I would suggest that you make sure that the Increment of the axis is at least 1. If you need to go smaller than that then you'll have to get into custom axis label titles. And when you add your values, give them a label. This will allow the chart to use sensible labels to identify values. For example:

Series1.Add(10 + 12/14, '10st, 12lb');
Series1.Add(10 + 13/14, '10st, 13lb');
Series1.Add(11 + 00/14, '11st, 0lb');
Series1.Add(11 + 01/14, '11st, 1lb');

结果如下:

您显然会编写一堆帮助程序函数来处理此问题。我建议将原始数据存储为磅。因此,第11个1lb将被存储为11 * 14 +1 =155。然后您将拥有以下助手:

You'd obviously write a bunch of helper functions to handle this. I'd suggest storing the raw data as pounds. So, 11st 1lb would be stored as 11*14 + 1 = 155. Then you'd have these helpers:

function StonesFromPounds(Pounds: Integer): Double;
begin
  Result := Pounds / 14.0;
end;

function StonesPoundsLabel(Pounds: Integer): string;
begin
  Result := Format('%dst %dlb', [Pounds div 14, Pounds mod 14]);
end;

然后数据填充看起来像这样:

And then the data population would look like this:

Pounds := 152;
Series1.Add(StonesFromPounds(Pounds), StonesPoundsLabel(Pounds));

您完全可以自由选择如何为体重创建文本标签。如果您想要的细节不如第10磅重13磅,那么您可以根据需要调整助手功能。

You have complete freedom with how you create text labels for your weights. If you want something less verbose than 10st 13lb then you can adjust the helper functions to your needs.

现在,这已经是一个很长的答案了,所以我将总结一下建议:

Now, this has been quite a long answer, so I will summarise my advice:


  1. 当您从任何来源获取数据时,将其转换为定义良好的存储格式,原始数据格式。

  2. 将此原始数据存储为整数值(以磅为单位)。

  3. 绘制权重时,请转换为浮点数值,单位为 Stones:=磅/14.0

  4. 将文本标签与绘制的每个值相关联,以便

  5. 如果需要在石头的整个值之间标注重量,请准备提供自定义的标注轴。

  1. When you acquire the data, from what ever source, convert from whichever format they arrive in to a well-defined storage format, the raw data format.
  2. Store this raw data as integer values, in units of pounds.
  3. When you plot the weights, convert to floating point values in units of stones by Stones := Pounds/14.0.
  4. Associate text labels to each value that you plot so that you can present the weights in human readable form.
  5. Be prepared to supply custom label axes if you need to label weights in between whole values of stones.

这篇关于将TChart上的左轴设置为将十进制值增加到.13?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆