条形图系列变化的 TChart 大小

TChart size of bar-series changes

我有几个时期(月)的数据。当 select 显示一个时间段时,将显示多个饼图。在该表单上,用户可以单击 select 下一个或上一个时期,然后重新绘制图表以反映该时期的数据。到目前为止一切顺利。

PieCharts 最多可包含 7 个饼图(用户请求)。如果值超过 7 个(我没有使用 OtherPie 功能),则会创建一个 'Other'-饼图,当您单击该 'other'-饼图时,会显示一个条形图。该条形图系列的值被添加到饼图的图例中。工作正常。

现在我 select 10 月期间,单击另一个饼图,条形图变为可见。我 select 下一个时期,单击其他饼图,条形图再次可见。但后来我回到上一时期,点击另一个饼图,条形图变得可见,但小得多!太小 ! 再选下一个perioda,bar-chart还好,回去,bar-chart小

请查看问题的屏幕录像:TChart Issue.wmv

奇怪的是,我第一次显示 10 月期间的条形图时,一切正常,但第二次显示时却以那种小格式显示。在我看来,似乎发生了 属性 变化或其他事情。但是,那可能是错误的思维方向......

我查看了数据,尝试了几个属性,目前正在尝试缩放选项。我也向Steema求助,目前没有结果。

procedure FillChart(AChart: TChart; AOverviewItemList: TOverviewItemList; APieSeries: TPieSeries; ABarSeries: TBarSeries);
  var
    i:                  integer;
    vOVitem:            TOverviewItem;
    LValue:             double;
    LOtherValue:        double;
    LUseOtherPieIdx:    integer;
    LLabel:             string;
    t:                  integer;
  begin
    LSortedGraphItems.Clear;

    { because my users don't want to use the standard functionality of the     }
    { 'other'-slices, I first add the items to a stringlist, sort that list    }
    { so I can then use the first 6 values for the pie, and if there are more  }
    { values I create an 'other'-pie myself and put the values in a bar-series }

    { here the stringlist will be filled }
    for vOVItem in AOverviewItemList do
    begin
      LValue := vOVItem.Details[0].Periods[APeriod].Total;
      LLabel := vOVItem.ResultItem.Description;
      if abs(LValue) > 0 then
      begin
        LSortedGraphItems.Add(Format('%10.5f=%s',[LValue, LLabel]));
      end;
    end;

    { determine when to use values for otherpie, There should never be }
    { more than 7 pies in the pie-chart. }
    LUseOtherPieIdx := max(0, LSortedGraphItems.Count - 7);

    LSortedGraphItems.Sort;

    { always start clean }
    LOtherValue := 0;
    ABarSeries.Clear;

    { add values to either the pie- or the bar-series }
    for i := 0 to LSortedGraphItems.Count-1 do
    begin
      lValue  := StrToFloatDef(LSortedGraphItems.Names[i], 0);
      LLabel  := LSortedGraphItems.ValueFromIndex[i];

      if LValue < 0 then
      begin
        LValue := abs(LValue);
        LLabel := '-'+LLabel;
      end;

      if (LUseOtherPieIdx > 0) and (i <= LUseOtherPieIdx) then
      begin
        LOtherValue := LOtherValue + LValue;

        ABarSeries.Add(LValue, LLabel);
      end else
      begin
        APieSeries.Add(LValue, LLabel);
        APieSeries.Tag := 0;
      end;
    end;

    { add a 'other'-pie if necessary }
    if (LOtherValue > 0)then
    begin
      APieSeries.Add(LOtherValue, Translate('Other'));
      APieSeries.Tag := 1;
    end;
  end;

我的一位同事提出了以下解决方案。添加 BarSeries 的值后 add

AChart.LeftAxis.Maximum := ABarSeries.MaxYValue;

一种或一种解释是 LeftAxis 的属性第一次没有问题,但被 november 的值覆盖了。回到 10 月,将 LeftAxis 属性设置为适合 11 月的值,使 10 月柱看起来太小。