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

Free Support Forum - aspose.com

Unable to set x and y value as datalabel for bubble chart

Hi,
15:33
i am generating bubble chart using aspose slides 16.8.0 license version but i am unable to set datalable for x value.when i am setting the showvalue attribute to true then only y axis value is displaying as datalable but i want to display both x and y value as data label.

My code to generate bubble chart: -
IChart chart = isSlide.getShapes().addChart(ChartType.Bubble,, 0, 0, 400, 400);
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Delete demo series
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
// Add new series
IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(0, 0, 0, "X value"), ChartType.Bubble);
series.getDataPoints().addDataPointForBubbleSeries(fact.getCell(defaultWorksheetIndex, 1,0, 2.4), fact.getCell(defaultWorksheetIndex, 1, 1, 2.8), fact.getCell(defaultWorksheetIndex, 1, 2, 3.8));
series.getDataPoints().addDataPointForBubbleSeries(fact.getCell(defaultWorksheetIndex, 2, 0, 3.2), fact.getCell(defaultWorksheetIndex, 2, 1, 4.2), fact.getCell(defaultWorksheetIndex, 2, 2, 2.8));
series.getDataPoints().addDataPointForBubbleSeries(fact.getCell(defaultWorksheetIndex, 3, 0, 4.3), fact.getCell(defaultWorksheetIndex, 3, 1, 2.9), fact.getCell(defaultWorksheetIndex, 3, 2, 8.8));
series.getDataPoints().addDataPointForBubbleSeries(fact.getCell(defaultWorksheetIndex, 4, 0, 9.1), fact.getCell(defaultWorksheetIndex, 4,1, 3.9), fact.getCell(defaultWorksheetIndex, 4, 2, 6.8));
series.getDataPoints().addDataPointForBubbleSeries(fact.getCell(defaultWorksheetIndex, 5, 0, 3.6), fact.getCell(defaultWorksheetIndex, 5, 1, 5.9), fact.getCell(defaultWorksheetIndex, 5, 2, 1.8));


series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getLabels().getDefaultDataLabelFormat().setSeparator("\n");
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.Center);
chart.getAxes().getVerticalAxis().setMajorTickMark(TickMarkType.None);
chart.getAxes().getHorizontalAxis().setMajorTickMark(TickMarkType.None);
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);

15:35
please give me a solution.
15:36

Hi Pravin,

I have observed your requirements and suggest you to please add following lines in your application.

series.getLabels().getDefaultDataLabelFormat().setShowCategoryName(true);

I hope the shared information will be helpful.

Many Thanks,

thanks…its working…