I’m attaching a excel sheet here I want a sample program to create a similar chart using aspose cells version 25.6.
It’s a nested stacked column chart with 3rd and 6th column without any color fill so that I can only see the labels. we can provide a white background to label with different text color.
Sample Stacked Column Chart.zip (11.7 KB)
@VaradS
Please try as the following codes:
public static void main(String[] args) throws Exception {
String dir = System.getProperty("user.dir") + "/";
// Load workbook
Workbook w = new Workbook(dir + "Sample Stacked Column Chart.xlsx");
// Add new worksheet
w.getWorksheets().add();
// Get the 3rd worksheet (index 2)
Worksheet worksheet = w.getWorksheets().get(2);
ChartCollection charts = worksheet.getCharts();
// Add stacked column chart
int chartIndex = charts.add(ChartType.COLUMN_STACKED, 0, 0, 20, 10);
Chart chart = charts.get(chartIndex);
// Add data series from range
chart.getNSeries().add("'1-DataSheet'!E6:E11", true);
chart.getNSeries().add("'1-DataSheet'!E12:E17", true);
// Show data labels
chart.getNSeries().get(0).getDataLabels().setValueShown(true);
chart.getNSeries().get(1).getDataLabels().setValueShown(true);
// Modify specific points
int[] cols = {2, 5};
for (int col : cols) {
// Set area formatting to none
chart.getNSeries().get(0).getPoints().get(col).getArea().setFormatting(FormattingType.NONE);
chart.getNSeries().get(1).getPoints().get(col).getArea().setFormatting(FormattingType.NONE);
// Set font color to red
chart.getNSeries().get(0).getPoints().get(col).getDataLabels().getFont().setColor(Color.RED);
chart.getNSeries().get(1).getPoints().get(col).getDataLabels().getFont().setColor(Color.RED);
}
// Save output file
w.save(dir + "dest.xlsx");
}