When I upgraded the version from 18.9 to 19.6, my chart`s secondaryVerticalAxis and VerticalAxis coincide


#23

@ximoon,

I am talking about the same. We have Vertical and Secondary Vertical axis on opposite side. Therefore, I requested you to please share the snapshot and issue pointed in that. As far as the issue associated with this thread is concerned, it was related to Vertical and Secondary Vertical axis plotted together.


#24

This is snapshot of generate file. That’s my question in red.QQ截图20190806114957.png (67.7 KB)


#25

@ximoon,

I have observed the information shared by you and have created an issue with ID SLIDESJAVA-37726 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.


#26

@ximoon,

Can you please try using following sample code on your end.

// Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();

// Access first slide
ISlide sld = pres.getSlides().get_Item(0);

// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);

// Setting chart Title
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.hasTitle();

// Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);

// Setting the index of chart data sheet
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();
int s = chart.getChartData().getSeries().size();
s = chart.getChartData().getCategories().size();

// Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"),chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"),chart.getType());

// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));

// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);

// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));

// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.RED);

// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
series.setPlotOnSecondAxis(true);

// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60));

// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.GREEN);

// create custom labels for each of categories for new series
// first label will be show Category name
IDataLabel lbl = series.getDataPoints().get_Item(0).getLabel();
lbl.getDataLabelFormat().setShowCategoryName(true);

lbl = series.getDataPoints().get_Item(1).getLabel();
lbl.getDataLabelFormat().setShowSeriesName(true);

// Show value for third label
lbl = series.getDataPoints().get_Item(2).getLabel();
lbl.getDataLabelFormat().setShowValue(true);
lbl.getDataLabelFormat().setShowSeriesName(true);
lbl.getDataLabelFormat().setSeparator("/");

// Move Primary and Secondary vertical axis
chart.getAxes().getSecondaryHorizontalAxis().setTickLabelPosition(TickLabelPositionType.High);
chart.getAxes().getSecondaryHorizontalAxis().setCrossType(CrossesType.Maximum);
chart.getAxes().getSecondaryHorizontalAxis().setVisible(false);

// Save presentation with chart
pres.save("AsposeChart.pptx", SaveFormat.Pptx);

#27

It is ok.Thanks!


#28

Can u tell me what is mean of chart.getAxes().getSecondaryHorizontalAxis().setCrossType(CrossesType.Maximum)
and why it is ok when i add this code?


#29

@ximoon,

I suggest you to please try using following sample code on your end.

// Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();

// Access first slide
ISlide sld = pres.getSlides().get_Item(0);

// Add chart with default data
IChart chart = sld.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);

// Setting chart Title
chart.getChartTitle().addTextFrameForOverriding("Sample Title");
chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
chart.getChartTitle().setHeight(20);
chart.hasTitle();

// Set first series to Show Values
chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);

// Setting the index of chart data sheet
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();
int s = chart.getChartData().getSeries().size();
s = chart.getChartData().getCategories().size();

// Adding new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Series 1"),chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Series 2"),chart.getType());

// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));

// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);

// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));

// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);

// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
series.setPlotOnSecondAxis(true);

// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 60));

// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.GREEN);

// create custom labels for each of categories for new series
// first label will be show Category name
IDataLabel lbl = series.getDataPoints().get_Item(0).getLabel();
lbl.getDataLabelFormat().setShowCategoryName(true);

lbl = series.getDataPoints().get_Item(1).getLabel();
lbl.getDataLabelFormat().setShowSeriesName(true);

// Show value for third label
lbl = series.getDataPoints().get_Item(2).getLabel();
lbl.getDataLabelFormat().setShowValue(true);
lbl.getDataLabelFormat().setShowSeriesName(true);
lbl.getDataLabelFormat().setSeparator("/");

// Move Primary and Secondary vertical axis
chart.getAxes().getSecondaryHorizontalAxis().setTickLabelPosition(TickLabelPositionType.High);
chart.getAxes().getSecondaryVerticalAxis().setTickLabelPosition(TickLabelPositionType.High);

// Save presentation with chart
pres.save("AsposeChart.pptx", SaveFormat.Pptx);

#30

This code doesn’t solve my problem.But the last one was solved.


#31

@ximoon,

I am sorry, I am unable to understand your following comments. Can you please elaborate and also give example output along with issue being highlighted in that.