Hello,
I use the OnClickSeries event to get the X value in a TLineSeries chart from the ValueIndex using Series.XValues[ValueIndex].
However, it looks like most of the time the Index returned in the OnClickSeries evenat after clicking is corresponding to the previous point in the series.
The X parameter and axis are of TDatetime time, so the X value is in the order of 42400 or something (around year 2016). Between 2 points there often is a day or so. Is this a round off error? Is the resolution to do this not sufficient to keep 2 points of say 42400 and 42401 apart with OnClickSeries?
Also if I determine the index using Series.Clicked(X,Y) I get the index of the prior point.
Or am I overlooking something.
Thanks, Wilfried
TDBChart OnClickSeries gives wrong ValueIndex
Re: TDBChart OnClickSeries gives wrong ValueIndex
Hello Wilfried,
Note the points are the edges of each line segment, not the lines themselves. So, the click function has to return one edge point or the other, and it returns the first one.
Note the points are the edges of each line segment, not the lines themselves. So, the click function has to return one edge point or the other, and it returns the first one.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TDBChart OnClickSeries gives wrong ValueIndex
Thanks, so actually, the clickseries event is triggered by clicking the line segment?
What would then be the best approach to get the index of the pointer if the pointers between the line segments are clicked? Just add 1 to the index?
regards, Wilfried
What would then be the best approach to get the index of the pointer if the pointers between the line segments are clicked? Just add 1 to the index?
regards, Wilfried
Re: TDBChart OnClickSeries gives wrong ValueIndex
Hello,
OnClickSeries event is triggered by clicking on the pointer and the line segment. You can differentiate one or the other with some code:
OnClickSeries event is triggered by clicking on the pointer and the line segment. You can differentiate one or the other with some code:
Code: Select all
type TSeriesAccess=class(TChartSeries);
procedure TForm1.Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if TSeriesAccess(Series).ClickedPointer(ValueIndex,
Series.GetHorizAxis.CalcXPosValue(Series.XValue[ValueIndex]),
Series.GetVertAxis.CalcYPosValue(Series.YValue[ValueIndex]),
X, Y) then
Caption:='Pointer Clicked: ' + IntToStr(ValueIndex)
else
Caption:='Line segment Clicked: ' + IntToStr(ValueIndex) + ' - ' + IntToStr(ValueIndex+1);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |