1
votes

Hi I'm using apache poi 3.17 and I made a bar chart using the org.openxmlformats.schemas.drawingml.x2006.chart.CTChart interface, like the image below:

I need to set the min and max value for the left axis. Something like 0 and 1 to adjust the columns.

Using org.apache.poi.ss.usermodel.charts.ValueAxis I can do that with the methods: setMinimum(0) and setMaximum(1) .

Is that possible ? using the package org.openxmlformats.schemas.drawingml.x2006.chart. If yes which class or iterface should I use?

enter image description here

Anyone can help me?

The code I use to set CTValAx is below and I get in this answer here

          CTValAx ctValAx = ctPlotArea.addNewValAx(); 
          ctValAx.addNewAxId().setVal(123457); 
          ctScaling = ctValAx.addNewScaling();
          ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX);
          ctValAx.addNewDelete().setVal(false);
          ctValAx.addNewAxPos().setVal(STAxPos.L);
          ctValAx.addNewCrossAx().setVal(123456); 
          ctValAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
1
Please show at least the code where you are setting the CTValAx.Axel Richter
@AxelRichter This part of code I get from another question. I believe that was you that answered. Sorry I'm a beginner developer and my knowledge about java and poi is so smallmakeItEasier
Yes but at the time I had answered, the linked documentation of grepcode.com was available as information resource. Now it is down and so we need doing javadoc our own to get information.Axel Richter

1 Answers

2
votes

Unfortunately there is not a API documentation of org.openxmlformats.schemas.drawingml.x2006.chart public available. So we need downloading the sources of ooxml-schemas from http://central.maven.org/maven2/org/apache/poi/ooxml-schemas/1.4/ for example and doing javadoc with those.

Then we will find org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx providing addNewScaling() which returns a CTScaling which provides addNewMax() and addNewMin() which are returning CTDouble and provide setVal(double val).

    CTScaling ctScaling = ...
    ...
    CTValAx ctValAx = ctPlotArea.addNewValAx(); 
    ctValAx.addNewAxId().setVal(123457); //id of the val axis
    ctScaling = ctValAx.addNewScaling();
    ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX);

    ctScaling.addNewMin().setVal(0.2);
    ctScaling.addNewMax().setVal(0.7);

    ctValAx.addNewDelete().setVal(false);
    ctValAx.addNewAxPos().setVal(STAxPos.L);
    ctValAx.addNewCrossAx().setVal(123456); //id of the cat axis
    ctValAx.addNewCrosses().setVal(STCrosses.AUTO_ZERO); //this val axis crosses the cat axis at zero
    ctValAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
    ...