Graph Annotation to move on zoom or scroll
Graph Annotation to move on zoom or scroll
Hello, I have to show comments near the selected points on TLine Series (data coming from database). I am using TAnnotationTool and position the annotation correctly on a graph, but after scrolling or zooming graph - all my annotations are not in sync with my points, so how can I stick them together (exactly as the mark). Thank you
Re: Graph Annotation to move on zoom or scroll
Hi Nicho,
You have to recalculate the positions every time the chart is scrolled because the positions have changed.
Use the series CalcXPos and CalcYPos functions at OnScroll event to get the X and Y positions in pixels of each series point. And use these values to set Left and Top properties in the annotations.
If you still have problems with it, don't hesitate to let us know.
You have to recalculate the positions every time the chart is scrolled because the positions have changed.
Use the series CalcXPos and CalcYPos functions at OnScroll event to get the X and Y positions in pixels of each series point. And use these values to set Left and Top properties in the annotations.
If you still have problems with it, don't hesitate to let us know.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Graph Annotation to move on zoom or scroll
Is there any way to find an index of line series by XValue? Don't want to loop XValues, because it could be more then 10000 point
I created a dictionary of annotations as <XValue, TAnnotationTool>
now, to move all of them on zoom or scroll, I have to find out an index of each point, contains comments.
Cannot use an index as Key in a dictionary, because the user can add, remove points, so the only unchangeable part is XValue
Thank you
I created a dictionary of annotations as <XValue, TAnnotationTool>
now, to move all of them on zoom or scroll, I have to find out an index of each point, contains comments.
Cannot use an index as Key in a dictionary, because the user can add, remove points, so the only unchangeable part is XValue
Thank you
Re: Graph Annotation to move on zoom or scroll
Hi Nicho,
You could loop from FirstVisibleIndex to LastVisibleIndex if you know that the point you are looking for is visible, but I'm afraid the only way to find the index of a point for a given XValue is to loop into the data.
Of course, if there would be a direct association you could assume in your specific application, you could avoid this loop. For example, if you know that your XValues go from 0 to 9999, the indexes would coincide with the XValues. Or if you have DateTimes but you know that the increment is constant, you could calculate the index of a given datetime. But allowing the user to add and remove values would probably discard these direct associations.
You could loop from FirstVisibleIndex to LastVisibleIndex if you know that the point you are looking for is visible, but I'm afraid the only way to find the index of a point for a given XValue is to loop into the data.
Of course, if there would be a direct association you could assume in your specific application, you could avoid this loop. For example, if you know that your XValues go from 0 to 9999, the indexes would coincide with the XValues. Or if you have DateTimes but you know that the increment is constant, you could calculate the index of a given datetime. But allowing the user to add and remove values would probably discard these direct associations.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Graph Annotation to move on zoom or scroll
I found another way: Series1.XValues.Locate(XValue)
Re: Graph Annotation to move on zoom or scroll
Hi Nicho,
Yes, there is a Locate function. But note it's looping:
Yes, there is a Locate function. But note it's looping:
Code: Select all
Function TChartValueList.Locate(Const AValue:TChartValue; FirstIndex,LastIndex:Integer):Integer;
begin
for result:=FirstIndex to LastIndex do
if Value[result]=AValue then Exit;
result:=-1;
end;
Function TChartValueList.Locate(Const AValue:TChartValue):Integer;
Begin
result:=Locate(AValue,0,Count-1);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |