You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Brad Curfman <wc...@hotmail.com> on 2015/05/14 07:36:36 UTC

How to create a line chart without smoothed lines

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 		 	   		  

RE: How to create a line chart without smoothed lines

Posted by "Tripathi, Shiv Deepak" <sh...@philips.com>.
Hi Brad,


Dear Team,

I am facing problem in merging two different custom layout problems. Problem is as follows:

When I am reading the file and generating merge file in out put I see it as only one custom format and that is of second presentation where as count is perfect and problem is – first presentations slide layout (Custom) not appearing in output

Can anyone please help me.


Thanks,
deepak



-----Original Message-----
From: bradcurfman@gmail.com [mailto:bradcurfman@gmail.com] On Behalf Of Brad Curfman
Sent: Tuesday, June 09, 2015 3:48 AM
To: POI Users List
Subject: Re: How to create a line chart without smoothed lines

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 <do...@gmx.at>
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 <br...@curfman.net> 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
> > <dominik.stadler@gmx.at
> >
> > 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
> >> <wc...@hotmail.com>
> >> 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: user-unsubscribe@poi.apache.org For
> >> additional commands, e-mail: user-help@poi.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional
> commands, e-mail: user-help@poi.apache.org
>
>

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

Re: How to create a line chart without smoothed lines

Posted by Brad Curfman <br...@curfman.net>.
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 <do...@gmx.at>
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 <br...@curfman.net> 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 <dominik.stadler@gmx.at
> >
> > 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 <wc...@hotmail.com>
> >> 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: user-unsubscribe@poi.apache.org
> >> For additional commands, e-mail: user-help@poi.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: How to create a line chart without smoothed lines

Posted by Dominik Stadler <do...@gmx.at>.
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 <br...@curfman.net> 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 <do...@gmx.at>
> 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 <wc...@hotmail.com>
>> 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: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to create a line chart without smoothed lines

Posted by Brad Curfman <br...@curfman.net>.
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 <do...@gmx.at>
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 <wc...@hotmail.com>
> 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: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: How to create a line chart without smoothed lines

Posted by Dominik Stadler <do...@gmx.at>.
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 <wc...@hotmail.com> 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: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org