Inserting Shape above a Chart Data Point

Is it possible to put or insert a shape above a chart data point?

@mhore1522 No, unfortunately, there is no way to insert shapes inside charts. Could you please create an expected output in MS Word and attach it here? We will check it and probably suggest you a way to achieve this using existing API.

@alexey.noskov Here’s a sample documentSample - Inserting Shape above a Chart Data Point.docx (28.2 KB)

@mhore1522 Thank you for additional information. In your document the shape is placed above the chart not in the chart itself. You can insert such shapes using Aspose.Words. the only problem is that there is no way to determine coordinates of data points. Chart layout is built on demand when document is rendered.
The following code can se used to place a shape above the chart:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a chart
Shape chartShape = builder.InsertChart(ChartType.Column, 300, 200);

// You can use LayoutCollector + LayoutEnumerator to determine rectangle couped by shape.
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
enumerator.Current = collector.GetEntity(chartShape);
RectangleF chartShapeRect = enumerator.Rectangle;

// Now we can create a chape and place it above the chart.
Shape rect = new Shape(doc, ShapeType.Rectangle);
rect.Width = 20;
rect.Height = 20;
rect.Rotation = 45;
rect.Stroke.Color = Color.DarkOrange;
rect.Fill.ForeColor = Color.Orange;
rect.RelativeVerticalPosition = RelativeVerticalPosition.Page;
rect.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
            
rect.Top = chartShapeRect.Top + 50;
rect.Left = chartShapeRect.Left + 50;

chartShape.ParentNode.AppendChild(rect);

doc.Save(@"C:\Temp\out.docx");

Is it possible to know the Y position of a specific data point?

I just like to add a line above the data point.

@mhore1522 I am afraid, no, there is no way to get coordinates of data points on the chart. As I mentioned, chart layout is built on demand when document is rendered.

@alexey.noskov, any way to achieve it?

A post was split to a new topic: Inserting Shape above a Chart Data Point using Aspose.Cells

@mhore1522 I have moved your last question into Aspose.Cell forum.
https://forum.aspose.com/t/inserting-shape-above-a-chart-data-point-using-aspose-cells/252162
My colleagues will reply you shortly.

@alexey.noskov, is there a way to achieve this in Aspose Word?

chart.NSeries[1].Type = Aspose.Cells.Charts.ChartType.Line;

@mhore1522 No, unfortunately, Aspose.Words does not support creation of composite charts at the moment. This feature request is logged as WORDSNET-12769 . We will keep you informed and let you know once it is supported.

The issues you have found earlier (filed as WORDSNET-12769) have been fixed in this Aspose.Words for .NET 24.5 update also available on NuGet.