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

Free Support Forum - aspose.com

How to add bubble next to Chart title & Chart Axis Text

Hi Aspose Team,

We need to add a bubble next to the Chart title & Chart Axis Text using Aspose Cells java.
Attaching the screenshot below for reference.
chart+bubble.png (43.3 KB)

Could you please help me in achieving it?

Thanks,
Sri

@SriG,

How to do it for the chart in MS Excel manually using chart options? Please create your desired chart in MS Excel manually, save the Excel file and provide us with steps details. We will check on how to do it via Aspose.Cells APIs.

PS. please zip the file prior attaching here.

Created a sample chart in MS Excel manually.

Column_Stacked+bubble.zip (16.5 KB)

@SriG,

I checked your chart, it is simple stacked column chart which can be easily created by Aspose.Cells for Java APIs. But you probably have added drawing shapes “bubbles” next to chart title and chart axis text manually, is not not? I asked you to provide an Excel file containing your expected chart (“add a bubble next to the Chart title & Chart Axis Text” automatically) using chart options provided by MS Excel. Please do the needful and provide details on how to create such bubbles automatically next to chart title and other axis text. Please note, it would be difficult to get chart title and each axis text location and then place shapes manually next to them via the APIs, we might not get accurate results.

Thanks for your response.
There is no direct option to add bubbles with the chart options provided by MS Excel. So I’ve added them with shapes. I see there is no direct solution to implement this.
Is there an alternate option to add shapes next to the chart title and each axis text with Aspose cells?
Column_Stacked+bubble-new.zip (12.3 KB)

@SriG,

As I told you, if there is no way in MS Excel to automatically add those bubble shapes next to chart title and axis text then there would be also no chart related options in Aspose.Cells APIs to do the task. Aspose.Cells does support to add shapes in chart, see the document on how to add shapes/controls to chart for your reference. But it would be hard to accurately place the shapes at proper positions for your custom needs via the APIs.

@SriG
We have added your request (CELLSNET-50017) to our tracing system , we will check it ASAP.

Hi @SriG
The Excel Chart may not support setting bubble properties, but we can provide the location of chart title and category axis,
then you can call the function, set the location, and insert the bubble shape into the chart.
Please try new patch:
Aspose.Cells21.12.1 For .Net2_AuthenticodeSigned.Zip (5.6 MB)
Aspose.Cells21.12.1 For .Net4.0.Zip (5.6 MB)
Aspose.Cells21.12.1 For .NetStandard20.Zip (5.6 MB)

I wrote a sample program, Please open it, then use Aspose.Cells 21.12.1 to run it.
With this code, you can open a chart with no bubble, calculate to get the position, then insert bubbles or other shapes, and output a chart with bubble.

CELLSNET-50017.zip (23.1 KB)

Hi @SriG
Please use aspose-cells-21.12.1-java.
aspose-cells-21.12.1-java.zip (7.5 MB)

And java sample code:

    Workbook book = new Workbook("Column_Stacked+bubble.xlsx");
	Chart chart = book.getWorksheets().get(1).getCharts().get(0);
	chart.calculate();
	
	//Title
    //1, get position
    Title title = chart.getTitle();
    double title_height = title.getHeight() * chart.getChartObject().getHeight() / 4000; //pixel
    //2, add a circle after Title, Diameter = TitleHeight, 1/4000 unit
    Shape shape_title = chart.getShapes().addShapeInChart(MsoDrawingType.OVAL, PlacementType.MOVE,
        title.getX() + title.getWidth(),
        title.getY(),
        title.getX() + title.getWidth() + (int)(title_height / chart.getChartObject().getWidth() * 4000),
        title.getY() + title.getHeight());
    shape_title.getFill().getSolidFill().setColor(Color.getGreen());
    
  //3, CategoryAxis
    Axis axis = chart.getCategoryAxis();
    TickLabelItem[] items = axis.getTickLabels().getTickLabelItems();
    for (int i = 0; i < items.length; i++)
    {
        TickLabelItem item = items[i];

        //add a circle after CategoryAxis, Diameter = AxisHeight, scale unit
        Shape shape2 = chart.getShapes().addShapeInChartByScale(MsoDrawingType.OVAL, PlacementType.MOVE,
            item.getWidth() + item.getX(),
            item.getY(),  //This is the Position
            item.getWidth() + item.getX() + item.getHeight() * chart.getActualChartSize()[1] / chart.getActualChartSize()[0],
            item.getHeight() + item.getY());
        shape2.getFill().getSolidFill().setColor(Color.getRed());
    }
            
    book.save("Column_Stacked+bubble_Out.xlsx");

The issues you have found earlier (filed as CELLSNET-50017) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao