Thanks for your help Dominik, the charts are exporting without smoothed
lines now. I had tried that solution earlier without luck, but figured I
should take another look since someone with better knowledge of the
framework suggested it. You have to get the reference to the CTLineSer
object within the CTLineChart and call setSmooth() on CTLineSer. The
CTLineChart.setSmooth() doesn't do anything as far as I can tell. Here is
the code that I used to get it working. I also added some context for other
users that may need more info on when/where to perform this.


        XSSFChart chart = (XSSFChart)drawing.createChart(anchor);

        // this will set blank values as gaps in the chart so you
        // can accurately plot data series of different lengths
        CTDispBlanksAs disp = CTDispBlanksAs.Factory.newInstance();
        disp.setVal(STDispBlanksAs.GAP);
        chart.getCTChart().setDispBlanksAs(disp);


        // setup chart, axes, data series, etc


        chart.plot(data, new ChartAxis[] { bottomAxis, leftAxis });

        // this must occur after the call to chart.plot above
        CTPlotArea plotArea = chart.getCTChart().getPlotArea();
        for (CTLineChart ch : plotArea.getLineChartList()) {
            for (CTLineSer ser : ch.getSerList()) {
                CTBoolean ctBool = CTBoolean.Factory.newInstance();
                ctBool.setVal(false);
                ser.setSmooth(ctBool);
            }
        }


On Mon, Jun 1, 2015 at 3:29 PM, Dominik Stadler <[email protected]>
wrote:

> I did not actually try this so it is completely untested, but
> something like the following should allow to access things inside the
> XML without actually needing to change or recompile POI:
>
>         XSSFChart xssfChart = (XSSFChart) chart;
>         CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
>         plotArea.getLineChartArray()[0].getSmooth();
>         CTBoolean ctBool = CTBoolean.Factory.newInstance();
>         ctBool.setVal(true);
>         plotArea.getLineChartArray()[0].setSmooth(ctBool);
>
> replace getLineChartArray() with any of the other chart types that is
> available and iterate over the array if you have multiple plots as
> part of a single chart.
>
> Dominik.
>
> On Mon, Jun 1, 2015 at 6:10 PM, Brad Curfman <[email protected]> wrote:
> > Dominik,
> >
> > I narrowed down the required XML to the following
> > Set the following property within the <c:ser> block for each data series
> to
> > be 0.
> >                 <c:smooth val="0"/>
> >
> > By default, the c:smooth attribute is not in the XML so Excel assumes it
> > should be 1 when rendering the chart.
> >
> > Can you point me to what class(es) I need to change to have that value
> set?
> > I'm just looking for the quick way to default this to 0 so I can generate
> > my own jar for my application.
> > I could then look into the changes necessary to incorporate this back
> into
> > the project which would provide an option to set this value to 1, but
> keep
> > the default of 0 since I wouldn't want to break the existing
> functionality.
> >
> >
> > On Wed, May 27, 2015 at 3:15 PM, Dominik Stadler <[email protected]
> >
> > wrote:
> >
> >> Hi,
> >>
> >> unfortunately support for charts is not very elaborate at the moment.
> >> You can maybe get a glimpse on the required changes in the XML format
> >> by doing the minimal necessary changes in Excel and saving the
> >> document in a second file.
> >>
> >> Then the DevTool OOXMLPrettyPrint (available in the POI sources) can
> >> help making the two files easier to diff so you can find out which
> >> changes are required. BTW, the .xlsx files are internally just zips,
> >> some diff-tools support comparing them directly if configured
> >> correctly, e.g. BeyondCompare.
> >>
> >> Thanks... Dominik.
> >>
> >> On Thu, May 14, 2015 at 7:36 AM, Brad Curfman <[email protected]>
> >> wrote:
> >> > I have successfully created an XLSX file containing line chart using
> >> POI, but the rendered chart smooths out the lines. You can right click
> one
> >> of the lines in the chart and disable the smoothing, but I need to
> generate
> >> an XLSX with smoothing disabled on all lines. How can this be done? I
> can't
> >> find any API methods available to set the smooth attribute. I did
> download
> >> the source and try to modify the SeriesLabelsRecord class to force the
> >> smooth attribute to false, but that didn't do anything. Any help is
> greatly
> >> appreciated.
> >> > Thanks,Brad
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to