/*
* Copyright Massimiliano Dessì (desmax74@yahoo.it)
*
* Licensed for non-commecial use,
* under Apache License Version 2.0
* (http://www.apache.org/licenses/LICENSE-2.0),
*
* for commercial use, under
* GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*/
package org.magicbox.chart;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.SpiderWebPlot;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.Dataset;
import org.magicbox.dto.SpedizioneCriteria;
//TODO da rifare
public class XYChart {
public XYChart(SpedizioneCriteria criteria) {
SpiderWebPlot spiderwebplot = valorizzaDataset();
chart = new JFreeChart(null, null, spiderwebplot, false);
}
public XYChart(Dataset dataset) {
SpiderWebPlot spiderwebplot = valorizzaDataset(dataset);
chart = new JFreeChart(null, null, spiderwebplot, false);
}
public JFreeChart getGraph() {
return chart;
}
private SpiderWebPlot valorizzaDataset(Dataset dataset) {
DefaultCategoryDataset defaultcategorydataset = (DefaultCategoryDataset) dataset;
SpiderWebPlot spiderwebplot = new SpiderWebPlot(defaultcategorydataset);
spiderwebplot.setInteriorGap(0.40000000000000002D);
return spiderwebplot;
}
private SpiderWebPlot valorizzaDataset() {
String s = "Primo";
String s1 = "Secondo";
String s2 = "Terzo";
String s3 = "Gennaio";
String s4 = "Febbraio";
String s5 = "Marzo";
String s6 = "Aprile";
DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
/* blue */
defaultcategorydataset.addValue(1.0D, s, s3);
defaultcategorydataset.addValue(4D, s, s4);
defaultcategorydataset.addValue(3D, s, s5);
defaultcategorydataset.addValue(5D, s, s6);
// defaultcategorydataset.addValue(5D, s, s7);
/* verde */
defaultcategorydataset.addValue(5D, s1, s3);
defaultcategorydataset.addValue(7D, s1, s4);
defaultcategorydataset.addValue(6D, s1, s5);
defaultcategorydataset.addValue(8D, s1, s6);
// defaultcategorydataset.addValue(4D, s1, s7);
/* rosa */
defaultcategorydataset.addValue(4D, s2, s3);
defaultcategorydataset.addValue(3D, s2, s4);
defaultcategorydataset.addValue(2D, s2, s5);
defaultcategorydataset.addValue(3D, s2, s6);
// defaultcategorydataset.addValue(6D, s2, s7);
SpiderWebPlot spiderwebplot = new SpiderWebPlot(defaultcategorydataset);
spiderwebplot.setInteriorGap(0.40000000000000002D);
return spiderwebplot;
}
private JFreeChart chart;
}