[英]Delphi TeeChart drawing on canvas
I am using delphi 10.3 TeeChart to map out some points.我使用 delphi 10.3 TeeChart 到 map 了一些点。
After mapping these points out, I want to generate lines between these points.将这些点映射出来后,我想在这些点之间生成线。
So basically a line from Point A to Point B所以基本上是从 A 点到 B 点的一条线
chart1.Canvas.Pen.Color := ClYellow;
chart1.Canvas.Pen.Width := 2;
chart1.Canvas.MoveTo(Chart1.Axes.Bottom.CalcXPosValue(chart1.Series[0].XValues[WayPoint]),Chart1.Axes.left.CalcYPosValue(Chart1.Series[0].YValues[WayPoint]));
chart1.Canvas.LineTo(Chart1.Axes.Bottom.CalcXPosValue(chart1.Series[0].XValues[WayPoint+1]),Chart1.Axes.left.CalcYPosValue(Chart1.Series[0].YValues[WayPoint+1]));
That code is run on the AfterDraw event of chart1, It is run under a for I:= 1 to Points (number of waypoints).该代码在 chart1 的 AfterDraw 事件上运行,它在 a for I:= 1 to Points(航点数)下运行。
The Result I get is as follows:我得到的结果如下:
Any help or suggestions would be great !任何帮助或建议都会很棒!
if I
is the same as Waypoint
, note that series value lists are indexed from 0
to NPoints - 1
, so for I:= 1 to Points
looks strange.如果I
与Waypoint
相同,请注意系列值列表的索引从0
到NPoints - 1
,因此对于I:= 1 to Points
看起来很奇怪。
Moreever, to connect points, you need NPoints - 1
segments, so loop should count from 0
to NPoint - 2
(to avoid out of array at WayPoint+1
)此外,要连接点,您需要NPoints - 1
段,因此循环应从0
计数到NPoint - 2
(以避免在WayPoint+1
处超出数组)
And the main doubt - why do you draw lines "by hands" while TChart
was intended for this purpose?主要的疑问 - 为什么你要“用手”画线,而TChart
就是为此目的?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.