Both Primary and Secondary Axis Titles Are Getting Displayed on the Primary Axis

Hello,

Using the below code, I’ve created a combo chart with Bar and Line and enabled Axis titles for the primary and secondary value axis. Noticed two following issues.

  1. Both primary and secondary value axis titles are getting overlapped
  2. Both axis titles are getting displayed on the primary axis

Need help in fixing the overlap issues and updating the axis title text.

Generated ppt file: ComboChart-01.zip (35.1 KB)

The below code is used for creating the combo chart:

Presentation pres = new Presentation();
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400);
chart.getChartTitle().addTextFrameForOverriding("Chart Title");
chart.getChartTitle().setHeight(20);
chart.getChartTitle().setOverlay(false);
chart.setTitle(true);
chart.getLegend().setPosition(LegendPositionType.Bottom);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(12);
// Setting the index of the chart data sheet
final int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();

// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Jan"));
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Feb"));
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Mar"));
chart.getChartData().getCategories().add(fact.getCell(0, 4, 0, "Apr"));
chart.getChartData().getCategories().add(fact.getCell(0, 5, 0, "May"));

// Adding new series
IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Total Revenue"), ChartType.ClusteredColumn);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 34.912));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 21.919));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 49.198));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 4, 1, 45.214));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 5, 1, 26.871));

// Adding new series
IChartSeries series1 = chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Price 2020"), ChartType.Line);
// Now populating series data
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 10.312));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 9.272));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 12.696));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 4, 2, 11.313));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 5, 2, 11.379));

chart.getAxes().getVerticalAxis().setTitle(true);

chart.getChartData().getSeries().get_Item(1).setPlotOnSecondAxis(true);
chart.getAxes().getSecondaryVerticalAxis().setPlotOrderReversed(true);
chart.getAxes().getSecondaryVerticalAxis().setTickLabelPosition(TickLabelPositionType.High);
chart.getAxes().getSecondaryVerticalAxis().setTitle(true);

pres.save(dataDir + "ComboChart-01.pptx", SaveFormat.Pptx);

@SrideviG,
Thank you for reporting on the issue. I’ve reproduced the issues you described.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39284

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@SrideviG,
Our developers have investigated the case. Please try using the following code example:

Presentation pres = new Presentation();
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.VolumeHighLowClose, 50, 50, 600, 400);
chart.getChartTitle().addTextFrameForOverriding("Chart Title");
chart.getChartTitle().setHeight(20);
chart.getChartTitle().setOverlay(false);
chart.setTitle(true);
chart.getLegend().setPosition(LegendPositionType.Bottom);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(12);

// Setting the index of the chart data sheet
final int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();

// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Jan"));
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Feb"));
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Mar"));
chart.getChartData().getCategories().add(fact.getCell(0, 4, 0, "Apr"));
chart.getChartData().getCategories().add(fact.getCell(0, 5, 0, "May"));

// Adding new series
IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Total Revenue"), ChartType.ClusteredColumn);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 34.912));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 21.919));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 49.198));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 4, 1, 45.214));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 5, 1, 26.871));

//series.setPlotOnSecondAxis(true);

// Adding new series
IChartSeries series1 = chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Price 2020"), ChartType.Line);
series1.setPlotOnSecondAxis(true);
// Now populating series data
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 10.312));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 9.272));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 12.696));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 4, 2, 11.313));
series1.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 5, 2, 11.379));

chart.getAxes().getVerticalAxis().setTitle(true);
chart.getAxes().getVerticalAxis().getTitle().setOverlay(false);
chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("Vertical");

chart.getAxes().getSecondaryVerticalAxis().setTitle(true);
chart.getAxes().getSecondaryVerticalAxis().getTitle().setOverlay(false);
chart.getAxes().getSecondaryVerticalAxis().getTitle().addTextFrameForOverriding("Secondary");
chart.getAxes().getSecondaryVerticalAxis().setPlotOrderReversed(true);

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

Result: output.zip (32.9 KB)