Aspose.word.dll .NET: Kout out, Stike data point showing in empty area instead of at particular point

Hi Aspose team, I want to show chart data point label like hightlighted in green now i am able to show- highlighted in Red. please revert asap.

Your response is much appriciated to me.

@Amol_Hekade

Can you please provide more details about the chart you are working with and the specific code you are using to display the data point labels?

.Net & C# with aspose.total for .net using aspose.word.

@Amol_Hekade You can use the same approach as suggested in another your thread:
https://forum.aspose.com/t/aspose-word-series-data-point-labeling/312101/17

Simply add data label to the point in the middle of the line:

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 series1 = seriesColl.Add(
    "Series 1",
    new string[] { "1", "2", "3" },
    new double[] { 3, 3, 3 });
series1.Format.Stroke.On = true;
series1.Marker.Symbol = MarkerSymbol.None;

// Show data labels and set font color.
series1.HasDataLabels = true;
ChartDataLabelCollection dataLabels1 = series1.DataLabels;

// Set data label position.
dataLabels1[1].ShowValue = true;
dataLabels1[1].Font.Color = Color.Black;
dataLabels1[1].Format.Fill.Color = Color.Yellow;
dataLabels1[1].Position = ChartDataLabelPosition.Above;

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

// Show data labels and set font color.
series2.HasDataLabels = true;
ChartDataLabelCollection dataLabels2 = series2.DataLabels;

// Set data label position.
dataLabels2[1].ShowValue = true;
dataLabels2[1].Font.Color = Color.Black;
dataLabels2[1].Format.Fill.Color = Color.Yellow;
dataLabels2[1].Position = ChartDataLabelPosition.Above;

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

out.docx (8.6 KB)

Hi, But what happened to Price line, how to adjust Datalable automatically in empty space?

Please help me to draw chart same is i pasted in green highlitgh with 3 series and KO, KI and price and datalables for KO and KI.

We have to fix this for our client and this is urgent. Please help.

@Amol_Hekade

Could you please elaborate the problem? The proposes approach demonstrates the basic technique to draw horizontal line and data label above it.

I am drawing 3 lines , 1 For KO which is having value :102, KI = 85 and Price line has different values in rage of 50 to 110, and my Price line is intersecting at particular point to KI and KO series I vawant to show that data point on both lines.

@Amol_Hekade Could you please provide sample data and create the expected output document in MS Word? We will check your expected output and provide you more information.

Hi attaching sample chart document.
please help on this

Chart.docx (29.4 KB)

please find sample chart and data.

image.png (10.2 KB)
Chart.docx (29.4 KB)

I am waiting for response.

@Amol_Hekade The approach is the same as suggested above:

double[] price = new double[] { 2.5, 2, 3, 5, 2, 2, 3, 5, 2, 2, 3, 5 };
string[] categories = new string[price.Length];
double[] KO = new double[price.Length];
double[] KI = new double[price.Length];
for (int i = 0; i < price.Length; i++)
{
    KO[i] = 4;
    KI[i] = 2.5;
    categories[i] = "";
}

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

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

// Add series.
ChartSeries priceSeries = chart.Series.Add("Price", categories, price);
priceSeries.Smooth = true;
ChartSeries koSeries = chart.Series.Add("KO", categories, KO);
ChartSeries kiSeries = chart.Series.Add("KI", categories, KI);


// Show data labels and set font color.
koSeries.HasDataLabels = true;
ChartDataLabel koLabel = koSeries.DataLabels[2];

// Set data label position.
koLabel.ShowValue = true;
koLabel.Font.Color = Color.Black;
koLabel.Format.Fill.Color = Color.Yellow;
koLabel.Position = ChartDataLabelPosition.Above;

// Show data labels and set font color.
kiSeries.HasDataLabels = true;
ChartDataLabel kiLabel = kiSeries.DataLabels[5];

// Set data label position.
kiLabel.ShowValue = true;
kiLabel.Font.Color = Color.Black;
kiLabel.Format.Fill.Color = Color.Yellow;
kiLabel.Position = ChartDataLabelPosition.Above;

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

out.docx (8.7 KB)

Need help on dynamically decide 1 point for ko and 1 for ki, lable position should be decided dynamically where price line is intersecting , datalable potion varrie as price price line data. please help on dynamic thing.

I don’t know the exact position of lable, i have to show in empty area dinamically

How to decide this 2 and 5 dynamically which must come in empty area.

@Amol_Hekade Unfortunately, this is out of Aspose.Words scope, you should analyze you input data and determine where the line intersects.

Please create ticket for this and include in next release

@Amol_Hekade This is out of Aspose.Words scope, so I do not think we will provide a feature to analyze the chart data. Aspose.Words is document processing library not data analysis library.