Aspose.word Series data point labeling

Need urgen help on ploting such kind of graph, which shows series with data points.

@Amol_Hekade

Can you please provide more details about the type of graph you are trying to plot and the specific Aspose product you are using?

Aspose.word.dll for .net c#

@Amol_Hekade Could you please create the expected output in MS Word and attach it here in DOCX format? This will help us to understand what chart element you would like to use.

out.docx (8.6 KB)

Attaching sample here
which is created in Microsoft word document.

@Amol_Hekade As I can see the horizontal line in the attached document is emulated using series in the chart. You can achieve the same using Aspose.Words by adding a series with the same Y values. The label is emulated by data label:
https://reference.aspose.com/words/net/aspose.words.drawing.charts/chartdatalabel/

defaultSeries.DataLabels.Position= ChartDataLabelPosition.OutsideEnd

is not working giving an error.

ChartDataLabelPosition.BestFit is also not working

@alexey.noskov Can you please help me, I want to set DataLabel position on respctive line, right now it is far from line.

I stuck due to this only. Please help on this

DataLabel position On SeriesLine or After series Line

Or You can help me this type of datalable position

It urgent, I am stucked in this.

@Amol_Hekade

This is expected. Different chart types support different data label position. This is described in remarks:
https://reference.aspose.com/words/net/aspose.words.drawing.charts/chartdatalabel/position/

You can use the following code to add such data label:

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

// Insert column chart.
Shape shape = builder.InsertChart(ChartType.Scatter, 432, 252);
Chart chart = shape.Chart;
ChartSeriesCollection seriesColl = chart.Series;

// Delete default generated series.
seriesColl.Clear();

// Add series.
ChartSeries series = seriesColl.Add(
    "Series 1",
    new double[] { 1, 2, 3 },
    new double[] { 3, 3, 3 });
series.Format.Stroke.On = true;
series.Marker.Symbol = MarkerSymbol.None;

// Show data labels and set font color.
series.HasDataLabels = true;
ChartDataLabelCollection dataLabels = series.DataLabels;

// Set data label position.
dataLabels[2].ShowValue = true;
dataLabels[2].Font.Color = Color.Black;
dataLabels[2].Format.Fill.Color = Color.Yellow;
dataLabels[2].Position = ChartDataLabelPosition.Center;

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

out.docx (8.5 KB)

My chart is Line chart please help on this.

@Amol_Hekade The same code works for line charts:

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

// Insert column chart.
Shape shape = builder.InsertChart(ChartType.Line, 432, 252);
Chart chart = shape.Chart;
ChartSeriesCollection seriesColl = chart.Series;

// Delete default generated series.
seriesColl.Clear();

// Add series.
ChartSeries series = seriesColl.Add(
    "Series 1",
    new string[] { "1", "2", "3" },
    new double[] { 3, 3, 3 });
series.Format.Stroke.On = true;
series.Marker.Symbol = MarkerSymbol.None;

// Show data labels and set font color.
series.HasDataLabels = true;
ChartDataLabelCollection dataLabels = series.DataLabels;

// Set data label position.
dataLabels[2].ShowValue = true;
dataLabels[2].Font.Color = Color.Black;
dataLabels[2].Format.Fill.Color = Color.Yellow;
dataLabels[2].Position = ChartDataLabelPosition.Center;

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

out.docx (8.5 KB)