Hi,
I am using aspose-cells-24.1.jar to create waterfall chart. I observe that the chart always comes up with default legends.
Increase, Decrease and Total, I am unable to remove these legends and add an custom legend.
tried with the sample code as shown below,
package aspose;
import com.aspose.cells.*;
public class WaterfallChart {
public static void main(String[] args) throws Exception {
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Insert data
cells.get("A1").putValue("Categories");
cells.get("A2").putValue("Start");
cells.get("A3").putValue("Positive Value 1");
cells.get("A4").putValue("Negative Value 1");
cells.get("A5").putValue("Positive Value 2");
cells.get("A6").putValue("End");
cells.get("B1").putValue("Values");
cells.get("B2").putValue(0);
cells.get("B3").putValue(20);
cells.get("B4").putValue(-10);
cells.get("B5").putValue(15);
cells.get("B6").putValue(25);
int chartIndex = worksheet.getCharts().add(ChartType.WATERFALL, 5, 0, 15, 5);
Chart waterfallChart = worksheet.getCharts().get(chartIndex);
waterfallChart.getNSeries().add("B2:B6", true);
waterfallChart.getNSeries().setCategoryData("A2:A6");
waterfallChart.getLegend().getLegendEntriesLabels().clear();
waterfallChart.getNSeries().get(0).setName("Sample Legend");
workbook.save("WaterfallChart.xlsx");
}
}
Can you please help. Thanks in Advance.
This Topic is created by amjad.sahi using Email to Topic tool.