更改 xy 值图中的 x 轴标签

change x-axis label in xy value plot

我正在尝试更改 Delphi 中 xyplot 上的标签。除了在数据点旁边显示一个标签之外,x 轴也需要一个标签(目前它显示整数 x 值)。现在已经尝试了一段时间,但无法弄清楚如何更改 x 轴标签。也许我需要另一种图表类型?

所以问题是如何将 x 轴上的标签(不是图中 xy 点旁边的标签)更改为字符串。

for ScenarioIndex := 1 to Mymodel.GetSimulationSetting.GetNumberOfScenarios do
begin
  ScenarioList := Mymodel.GetSimulationSetting.GetScenarioSettingList;
  ScenarioSetting := ScenarioList.Items[ScenarioIndex-1] ;

  //Series1.OnGetMarkText := Series1GetMarkText

  for RunIndex := 1 to Mymodel.GetSimulationSetting.GetNumberOfRuns do
  begin
    for KPIIndex := Low(KPI) to High(KPI) do
    begin
      YValue := ScenarioSetting.GetKPI(RunIndex-1 + KPIIndex * Mymodel.GetSimulationSetting.GetNumberOfRuns);
      XValue := ScenarioIndex;

      if YValue > MaxY then
        MaxY := YValue;
      if YValue < MinY then
        MinY := YValue;
          ScenarioResultChart.Series[KPIIndex].XLabel[1];

      //Add a point to the chart
      ScenarioResultChart.Series[KPIIndex].AddXY(XValue, YValue, inttostr(RunIndex * 100), stringtocolor(KPIinfo[KPIIndex,1]));
      ScenarioResultChart.Series[KPIIndex].Marks.Visible := True;
      ScenarioResultChart.Series[KPIIndex].Marks.Transparent := True;
      ScenarioResultChart.Series[KPIIndex].Marks.Font.Size := 10;
      ScenarioResultChart.Series[KPIIndex].Marks.Arrow.Color := clBlue;
      ScenarioResultChart.Series[KPIIndex].Marks.Arrow.Show;
      //ScenarioResultChart
    end;
  end;
end;

要在轴上显示自己的文本而不是 X 值,请将相应轴的 LabelStyle 更改为 talText 并使用 OnGetAxisLabel 事件:

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
  ValueIndex: Integer; var LabelText: string);
begin
  case ValueIndex of
    0: LabelText := 'first';
    1: LabelText := 'second';
    else
      LabelText := 'smth';
  end;
end;