Aspose.Slides ライブラリを使用して StackedColumn チャートを処理する必要があるプロジェクトに取り組んでいます。グラフの各列には、対応するカウンター値があり、このサンプル スライドのように表示する必要があります。
基本的に、各ラベルは、対応する列の幅の中央に対して対称に表示する必要があります。
5 列で、ラベルはテンプレートのようにきれいに表示されます。ただし、それよりも少ない場合、ラベルは次のように表示されます。
系列のデータ ポイントの追加と各データ ポイントのラベルの追加を担当するコードは次のとおりです。
dataSeries.DataPoints.AddDataPointForBarSeries(itemValueCell);
dataSeries.Format.Fill.FillType = fillType;
dataSeries.Format.Fill.SolidFillColor.Color = fillColour;
dataSeries.ParentSeriesGroup.Overlap = 100;
dataSeries.ParentSeriesGroup.GapWidth = 75;
var counter = workbook.GetCell(index, rowIndex, 7, item.Counter);
dataSeries.DataPoints[index - 1].Label.ValueFromCell = itemNameCell;
slide.Shapes.AddAutoShape(ShapeType.Rectangle, startX + dataSeries.GapWidth / 4.0f + (index - 1) * dataSeries.GapWidth * 1.85f, startY, dataSeries.GapWidth / 2.0f, 20);
var label = ((AutoShape)slide.Shapes[slide.Shapes.Count() - 1]);
label.TextFrame.Text = counter.Value.ToString();
label.FillFormat.FillType = FillType.NoFill;
label.LineFormat.FillFormat.FillType = FillType.NoFill;
label.TextFrame.TextFrameFormat.CenterText = NullableBool.True;
label.TextFrame.TextFrameFormat.AutofitType = TextAutofitType.Normal;
label.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid;
label.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.FromArgb(0, 173, 219);
各データポイントの ActualWidth を取得しようとしましたが、ゼロ値しか取得できませんでした。フィールドの値は、チャート全体 (またはおそらくパワーポイント ファイル全体) がレンダリングされた後にのみ設定されるようです。コードから各列の動的な幅の値を取得する方法を知っている人はいますか (レンダリングされる前でも)?