Page 1 of 1
Q: how to plot a Horizontal line in a Line Chart?
Posted: Tue Nov 25, 2003 11:12 am
by 8441073
Hello,
I have a LineSeries chart, used to display quotation values.
I want to draw a horizontal line tangent the highest and lowest values visible in the chart.
My problem is I don't know where the MaxValue or MinValue has been drawn on the chart (in other words, the Y-coordinate), in order to draw a line at that coordinate.
Regards
Posted: Tue Nov 25, 2003 4:05 pm
by Marjan
Hi!
You could use the following approach:
1) Cycle through all visible points and determine the index of minimum and maximum point. Pseudo-code you can use:
Code: Select all
for i := Series.FirstVisibleIndex to Series.LastVisibleInde x do
if Series.YValues[i] > current_max then maxindex := i ;
if Series.YValues[i] < current_min then minindex := i;
2) Now that you have minimum and maximum point indices, you can use series CalcYPos method to get the maximum and minimum point y pixel coordinate.
3) Finally, use calculated screen position to draw horizontal line. Pseudo-code, placed in TChart.OnAfterDraw event:
Code: Select all
With Chart1, Chart1.Canvas do
begin
MoveTo(ChartRect.Left,calculated_y_pos);
LineTo(ChartRect.Right,calculated_y_pos);
end;
Posted: Tue Nov 25, 2003 4:57 pm
by 8441073
you can use series CalcYPos method
CalcYPos, that's the key I was missing!
Thank you
Posted: Fri Nov 28, 2003 9:18 am
by 8441073
Hello,
I reuse this topic for another problem.
I want to draw a horizontal line, on my TLineSeries chart, at certain Y value.
I obtained the screen coordinates using TChartSeries.CalcYPosValue.
I'd like drawing a line using SmallDots style, which I found only in TChartPen class (derived from TPen).
Where TChartPen is used? Chart objects have the standard Canvas property, which contains the standard Pen.
How can I draw a line using TChartPen, in a chart?
Regards
Posted: Sun Nov 30, 2003 8:42 pm
by Pep
How about using the ColorLine tool ?
I think it does all that you're looking for. You can see one example example of it in the TeeChart Pro Demo Features under : All Features -> Welcome ! -> Tools -> Color Line
Josep Lluis Jorge
http://support.steema.com