Roman,

You are very much welcome to contribute. Support for Excel charts is a
commonly asked question on the mailing lists and it would be a really
valuable contribution.

I think it would be good to design the chart API in terms of common ss
interfaces, so that in future we will have both XSSF and HSSF
implementations.  XSSFChartData would become ChartData in
org.apache.poi.ss.usermodel.charts, etc.

The proposed architecture of classes looks good. Do you already have a
sample implementation or you just planning it? In any case, don't
hesitate to attach it to Bugzilla (Bug 51196 or a new one).
Hoping to see it in the upcoming release of POI 3.8!

Regards,
Yegor

On Sat, May 14, 2011 at 11:14 AM, Roman Kashitsyn
<[email protected]> wrote:
>
> Hello. In my current project I have to create xlsx charts programmaticaly.
> As I can see, at the moment POI has not enought capabilities for that. So I
> want to collaborate with POI developers to teach POI to work with charts. I
> have proposed code to allow user create new charts (
> http://apache-poi.1045710.n5.nabble.com/DO-NOT-REPLY-Bug-51196-New-PATCH-Patch-to-simplify-XSSFChart-creation-tp4392907p4392907.html
> patch 51196 ), but they still have to fill chart content by themselves.
>
>
> The next step is to allow users to create different charts without direct
> xmlbeans library usage. ECMA-376 describes 16 chart types. So we need to
> organize classes in some rational model. I thought a lot about it and here
> is my proposal: lets add to XSSFChart factory method, say,
> plot(XSSFChartData), to plot a specific data on a chart. XSSFChartData will
> be an interface (or an abstract class) that incapsulates specific plot logic
> (i.e. working with CTPlotArea).
>
> The implementation could be something like that:
>
>
> /* XSSFChartData.java */
> public interface XSSFChartData() {
>    void fillChart(CTPlotArea ctArea);
> }
>
> /* XSSFChart.java */
> public void plot(XSSFChartData data) {
>    data.fillChart(getCTChart().getPlotArea());
> }
>
> /* XSSFScetterChartData.java */
> public class XSSFScetterChartData implements XSSFChartData {
>    public void fillChart(CTPlotArea area) {
>        CTScetterChart scetterChart = area.addNewScetterChart();
>        /* .... */
>    }
> }
>
>
> Here is a code snippet illustrating the idea:
>
> XSSFChart chart = drawing.createChart(anchor);
> XSSFScetterChartData chartData = new XSSFScetterChartData();
> XSSFScetterChartData.Serie serie = chartData.addSerie();
> serie.setXValues(range);
> serie.setYValues(anotherRange);
> chart.plot(chartData);
>
>
>
> I think proposed class names not the best ones, if you know better ones -
> welcome.
>
>
>
> Here are the benefits of such approach:
>
> no any if\switches: polymorphism rules;
> the same data can be plotted in multiple charts - orthogonality is always a
> plus;
>
> I think a new package should be introduced to contain chart data classes
> (suppose, org.apache.poi.xssf.usermodel.charts).
>
>
> What do you think about all this?
>
> Thank you in advance
>
> Roman Kashitsyn
>
>
>
> --
> View this message in context: 
> http://apache-poi.1045710.n5.nabble.com/XSSF-Chart-model-tp4395176p4395176.html
> Sent from the POI - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to