【问题标题】:change x-axis label in xy value plot更改 xy 值图中的 x 轴标签
【发布时间】:2019-08-12 18:11:46
【问题描述】:

我正在尝试在 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 值而不是等距网格值来制作标签?
  • 您好 MBo,感谢您抽出宝贵时间回答问题...不,它在 x 轴上显示 1(值)的位置现在应该显示例如“场景 1:基线”例如,在它显示 2 的地方,它应该显示“Scenario extra LT”。我们只在 x=1 、 x=2 、 x=3 等上添加点...
  • 好的,我改了答案
  • 看起来不错 :) 将尝试实施并让您知道....谢谢!

标签: delphi plot label teechart


【解决方案1】:

要在轴上显示自己的文本而不是 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;

【讨论】:

    猜你喜欢
    • 2019-09-02
    • 2012-07-01
    • 2016-09-03
    • 2018-02-06
    • 2021-04-08
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    相关资源
    最近更新 更多