We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set DataLabels to ShowValueFromCell and give a cell range in Bubble chart (C# .NET)

Hi Team,

We are having a bubble chart, where in the linked data excel, we have four column,

1st column: For data label purpose
2nd column: for X position of bubble
3rd column: for Y position of bubble
4th Column: for Bubble size.

Everything is good, but we are confused how to set my datalabels to take values from 1st Column.
In PPT, i have a direct option in format to select a range. But in aspose when we try to set SetShowLabelValueFromCell as true, it is not working. and we also dont know where to set Cell range for this purpose.

Below is the code we have used to enable showLabelValueFromCell.

series.getDataPoints().get_Item(datapointindex).getLabel().getDataLabelFormat().setShowValue( true );

series.getDataPoints().get_Item(datapointindex).getLabel().getDataLabelFormat().setShowLabelValueFromCell(true);

Could you please help us in resolving this issue.

PFA ppt for referPresentation1.zip (45.0 KB)
ence.

Thanks,
Sagar.

@sagar465,

I have observed your requirements and suggest you to please observe and tailor the following sample code as per your needs that can set the value of labels from chart workbook. I hope the shared information will be helpful.

public static void TestChartLabel()
{
    
    String lbl0 = "Label 0 cell value";
    String lbl1 = "Label 1 cell value";
    String lbl2 = "Label 2 cell value";
    Presentation pres = new Presentation();

    ISlide slide = pres.getSlides().get_Item(0);


    IChart chart = slide.getShapes().addChart(ChartType.Bubble, 50, 50, 600, 400, true);

    IChartSeriesCollection series = chart.getChartData().getSeries();

    series.get_Item(0).getLabels().getDefaultDataLabelFormat().setShowLabelValueFromCell (true);

    IChartDataWorkbook wb = chart.getChartData().getChartDataWorkbook();

    series.get_Item(0).getLabels().get_Item(0).setValueFromCell (wb.getCell(0, "A10", lbl0));
    series.get_Item(1).getLabels().get_Item(0).setValueFromCell (wb.getCell(0, "A11", lbl1));
    series.get_Item(2).getLabels().get_Item(0).setValueFromCell (wb.getCell(0, "A12", lbl2));

    pres.save("resultchart.pptx", SaveFormat.Pptx);

}

Hi @mudassir.fayyaz ,

PFA a screenshot on how the chart is working in our case. In our case there is only one series with multiple datapoints. So we have to set the Label text on datapoint level. we have done that with reference from ur code above, but by default the datalabels are being taken from Column2 which are my Y position values of bubbles.

Could you please check this scenario as well and help us.Capture.PNG (19.7 KB)

Thanks,
Sagar

@sagar465,

Can you please share the working sample project reproducing the issue on your end so that we may investigate that further on our end to help you further.