折线图数学 [英] Line Chart Mathematics

查看:102
本文介绍了折线图数学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的环境的性质意味着我需要创建绘制折线图的功能,并且我无法根据任何行的最高值来计算通用解决方案的数学(我知道我的解决方案)使用精确的硬编码比例值和因子)。



所以关于这个问题:



1 。折线图容器的高度为2.8513英寸/ b $ b 2. Y尺度目前适应任何线的最大值,例如最大值1428意味着比例尺从0开始,在10个部分以1450结束。

3.线条由起始高度和结束高度绘制,起始高度是前一个值,结束高度是当前行值



我需要解决的是某种通用公式(我擅长数学而不是那个级别)会找出线条的正确高度基于内的值该容器高度的比例。



重申比例是根据找到的最大值动态计算的,但容器高度已设定。



如果有人能提供任何最受欢迎的帮助。

The nature of the environment I am using means I need to create functionality that draws a line chart and I am having trouble working out the mathematics for a generic solution based on the highest value of any line (I know the solution I am using works fine with hard coded scale values and factors).

So onto the question:

1. The height of the container for the line chart is 2.8513in
2. The Y scale currently adapts itself to the maximum value of any line, so for example a maximum value of 1428 would mean the scale would start at 0 and end at 1450 in 10 sections.
3. The lines are drawn by a starting height and and ending height, the starting height is the previous value and the ending height is the current line value

What I need to work out is some kind of generic formula (I am good at maths but not to that level) that will work out the correct height for the lines based on the values within the scale for that container height.

To reiterate the scale is worked out dynamically based on the maximum value found but the container height is set.

If anyone can provide any help that would be most welcome.

推荐答案

你需要将最大行高乘以当前项价值占最大价值的百分比。



高度= MaxHeight *(价值/ MaxValue)



如果你想在图表上绘制水平线以显示最大值的10,那么你不必涉及值(除非你想为线赋值),你只需要知道高度。



NoLine = 10



LineY =(LineNumber / NoLines)*高度

LineValue =(LineNumber / NoLines)* MaxValue



这都是基于小数百分比,其中100%= 1.



SegmentValue / TotalV alue =十进制百分比
You need to multiply the maximum line height by the current items value as a percentage of maximum value.

Height = MaxHeight * (Value / MaxValue)

If you want to draw the horizonal lines across the chart to show 10ths of the maximum value then you don't have to involve the values (unless you want to assign values to the lines), you only need to know the height.

NoLine = 10

LineY = (LineNumber / NoLines) * Height
LineValue = (LineNumber / NoLines) * MaxValue

This is all based around decimal percentages, where 100% = 1.

SegmentValue / TotalValue = Decimal Percentage


这篇关于折线图数学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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