How to use Label instead of Double when adding a value in TChart Lazarus

When using TChart component, let say adding one bar series, how to change the value of the x axis using label instead of Double?

Currently I can only using addXY in bar series, with two numbers. Is it possible to add like (Apple, 1000), (Orange, 400), (Banana, 10)? Currently I am just using an index and add the fruit name as the label. I want to put the label not on the bar, but exactly in the x axis.

How to do such thing using TChart in Lazarus?


  • Assign the BarSeries' ListSource to the Marks.Source of the BottomAxis and set Marks.Style to smsLabel. Can only be done at runtime, and "smsLabel" requires unit TAChartUtils in the "uses" clause.

    procedure TForm1.FormCreate(Sender: TObject);
      Chart1Barseries1.AddXY(1, 1000, 'Apple');
      Chart1BarSeries1.AddXY(2, 400, 'Orange');
      Chart1BarSeries1.AddXY(3, 10, 'Banana');
      Chart1.BottomAxis.Marks.Source := Chart1BarSeries1.listSource;  // <---
      Chart1.BottomAxis.Marks.Style := smsLabel;                      // <---