I'm using a TadvGDIPChartView with a line chart to plot scientific data. I need to be able to add non data lines to these charts, so I'm coding this in the OnDrawChart method. But I'm having great difficulty finding how to map a real world value to a value that can be plotted on the canvas.
Hi,
Thanks for the quick reply. I think I've got the Y points sorted out - when I resize the chart and scale the Y axis, my line in the Y direction draws correctly. However, I must be doing something wrong in the X as when I reduce the width of the chart, my line doesn't get drawn at the correct X position. Making the chart narrower causes the X points to be drawn at too small a value.
For example, I'm drawing a test line that has X1 at 25% of the data points and X2 at 50% (18,000 data points so X1 = 4500, X2 = 9000). With a large chart, this appears to draw correctly, but as I shrink the chart down in the X direction, X1 is drawn at approximately 3000 and X2 at approximately 7000. This is just resizing the chart, not scaling or scrolling the axis.
I'm calculating X1 and x2 in the OnDrawChart method using
x1 := Round(4500 * chart.XScale);
x2 := Round(9000 * chart.XScale);
Am I missing an offset or something here?
Thanks
OK, figured it out. Just in case anybody else is searching for this. The canvas X and Y values are calculated from
DR : TRect;
DR := AdvChartView.Panes[0].Series.SeriesRectangle;;
canvasX := Round(realXValue * AdvChartView.Panes[0].XScale) + DR .Left;
canvasY := AdvChartView.Panes[0].Series[0.ValueToY(realYValue, DR);