Page 1 of 1

TCursor tool options

Posted: Mon Sep 10, 2007 5:17 pm
by 9345006
Hi,

I would very much like to see another version of the Cursor tool that didn't just display the value of a single series.

This would be a vertical line that showed the values of all series it goes through at the point it's cutting the line.

Image

thanks,
nisbus

Posted: Wed Sep 12, 2007 10:12 am
by narcis
Hi nisbus,

You can easily achieve that as shown in the interpolating example I posted here.

Hope this helps!

Posted: Thu Sep 13, 2007 1:06 am
by 9345006
Thank you,

This example does exactly what I am trying to do except it shows the values in the chart title.

I would like just the value at the x coordinate of the cursor and the y coordinate of the series (as my screenshot implied).

If I try to use Canvas.TextOut for example how would I then get the y coordinate of each series at the x coordinate of the cursortool?

thanks,
nisbus

Posted: Thu Sep 13, 2007 1:26 am
by 9345006
I added some thing to your code with the TextOut of the charts canvas and it works pretty well except that the chart always erases my text immediately after drawing the textout.
How can I make it stick?

Code: Select all

procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
var
  i: Integer;
  ypos : integer;
  idx : integer;
begin
  With Chart1.Title.Text do
  begin
    Clear;
    for i:=0 to Chart1.SeriesCount - 1 do
    begin
      idx := Chart1[i].XValues.Locate(Round(XValue));
      if idx > -1 then
      begin
        ypos := Chart1[i].CalcYPos(idx);
        Chart1.Canvas.TextOut(x,ypos,FloatToStr(InterpolateLineSeries(Chart1[i],XValue))+#13#10);
      end;
        Add(Chart1[i].Name + ': Y('+FloatToStr(XValue)+')= ' +
            FloatToStr(InterpolateLineSeries(Chart1[i],XValue))+#13#10);
    end;
  end;
thanks,
nisbus

Posted: Thu Sep 13, 2007 8:14 am
by narcis
Hi nisbus,

I couldn't see your screenshot because the image doesn't open properly. Maybe you didn't add it as an URL.

Regarding the problem you are having, it is most likely that it is erased because of the tool being moved again. Maybe the easiest way to solve this would be an annotation or rectangle tool setting its position to custom. You can see an example here.

Posted: Thu Sep 13, 2007 12:12 pm
by 9345006
I added it as an url but my webserver seems to be down :(

Thank you, I managed to get the results I wanted using a combination of TCursorTool and TAnnotationTool.


thanks,
nisbus