0

Delphi 7 and TChart version 2014Delphi7

I have a 3d TChart with 16 bar series and 16 values. (a 16x16 3d bar chart)

When I move the mouse over the bottom axis I need to know the valueindex of the series the mouse is over.

I want to hide(transparency=75) all other values so only the bars for that index are displayed. (show only that index for all series so displayed is in effect a 1x16 chart)

How can I get the index the mouse is over?

Yeray
  • 5,009
  • 1
  • 13
  • 25
Steve
  • 640
  • 1
  • 7
  • 19
  • 1
    [`This post`](http://stackoverflow.com/a/20879970/960757) should be what you're looking for, I think. Not sure if your question is a duplicate though. – TLama Mar 17 '15 at 17:41
  • @TLama, the answer is in there, but question a bit different. – LU RD Mar 17 '15 at 20:13
  • Thank you, that gave me what I was looking for. @TLama if you post it as an answer I will give you the credit. – Steve Mar 18 '15 at 18:03
  • Thank you, but it would be unfair to Yeray. I've asked him for re-post. – TLama Mar 19 '15 at 10:02

1 Answers1

1

The Series' Clicked(X,Y) function returns -1 if the series isn't under the (X,Y) position (in pixels). If the series is under the (X,Y) position (in pixels), it returns the index of the point under the series.

Here you have a simple example using the OnMouseMove event:

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;

  for i:=0 to 2 do
    Chart1.AddSeries(TBarSeries).FillSampleValues(3);
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var seriesIndex, valueIndex: Integer;
begin
  Caption:='No series under the mouse';

  for seriesIndex:=Chart1.SeriesCount-1 downto 0 do
  begin
    valueIndex:=Chart1[seriesIndex].Clicked(X,Y);
    if valueIndex>-1 then
      Caption:='Series under the mouse. SeriesIndex: ' + IntToStr(seriesIndex) + ', ValueIndex: ' + IntToStr(valueIndex);
  end;
end;
Yeray
  • 5,009
  • 1
  • 13
  • 25