Search code examples
delphiteechart

Steema TeeChart. I clicked on which bar?


Steema TeeChart VCL/FMX Delphi X3 Enterprise

I have a chart that has 10 vertical bars. When I click a bar I will display detail information about that bar. I need the label of the bar I just clicked.


Solution

  • To get the label text of the just clicked value (in your case a vertical bar), you can inspire in the following method written for the OnClickSeries event:

    procedure TForm1.Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
      ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    begin
      ShowMessage(Series.Labels[ValueIndex]);
    end;