Page 1 of 1

How to add the Y values and display it in Tooltip

Posted: Tue Nov 08, 2005 12:32 pm
by 9524848
Hi,
I have created a graph with two series. I am interested is displaying the the sum of the Y values(series1 Y value + series2 Yvalue) in Tooltip.
I would like to display the sum for both Mouse over and On Click events.

Is it possible?. If yes then please let me know how it can be done.

Thanks,
Mahendra

Should be possible

Posted: Tue Nov 08, 2005 1:32 pm
by 9083304
Hi Roger

As long as their x-axis is shared it should be no problem.

OnClickSeries:

sum = tChart1.Series(0).YValues.Value(ValueIndex) + tChart1.Series(1).YValues.Value(ValueIndex)

OnMouseEnterSeries:
Dim XVal as Double

XVal = tChart1.Axis.Bottom.CalcPosPoint(tChart1.Series(0).MouseValues.X)

sum = tChart1.Series(0).YValues.Value(XVal) + tChart1.Series(1).YValues.Value(XVal)

Try that.
Ross

Posted: Tue Nov 08, 2005 3:44 pm
by Pep
Hi Roger,

one way to do this could be to use the following code (using a TMarksTipTool) :

Code: Select all

procedure TForm1.ChartTool1GetText(Sender: TMarksTipTool;
  var Text: String);
begin
Text := floattostr(Series1.YValue[strtoint(text)] + Series2.YValue[strtoint(text)]);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ChartTool1.Style := smsXValue;
end;