http://www.jfree.org/phpBB2/viewtopic.p ... 16&start=0
http://www.jfree.org/phpBB2/viewtopic.p ... 12&start=0
http://www.jfree.org/phpBB2/viewtopic.p ... 04&start=0
http://www.jfree.org/phpBB2/viewtopic.p ... 30&start=0
but my charts are ignoring the colour settings
this is what i made
Code: Select all
public static class PieRenderer {
public PieRenderer() {}
public PiePlot setColor(PiePlot plot, PieDataset dataset) {
for (int i = 0; i < dataset.itemCount; i++) {
String valore = dataset.getKey(i)
//println "valore dell'indice ${i}: ${valore}"
HashMap<String, Color> mappaColori = generaMappaColoriTipiChiamate()
Color colore = mappaColori.get(valore)
println " plot.setSectionPaint(${i}, ${colore.toString()}), valore: ${valore}"
plot.setSectionPaint(i, colore)
}
return plot
}
def generaMappaColoriTipiChiamate() {
def colori = new HashMap<String, Color>()
colori.put("IDRO-SANITARIO", java.awt.Color.BLUE)
colori.put("IDRO-SANITARIA", java.awt.Color.BLUE)
colori.put("ANTINCENDIO", java.awt.Color.ORANGE)
colori.put("ANTI-INTRUSIONE", java.awt.Color.DARK_GRAY)
colori.put("ASCENSORI", java.awt.Color.BLACK)
colori.put("CONDIZIONAMENTO", java.awt.Color.WHITE)
colori.put("EDILE", java.awt.Color.LIGHT_GRAY)
colori.put("ELETTRICA", java.awt.Color.YELLOW)
colori.put("SERVIZIO ENERGIA-TERMICO", java.awt.Color.RED)
colori.put("SERVIZIO ENERGIA - TERMICO", java.awt.Color.RED)
colori.put("SPECIALI", java.awt.Color.RED)
colori.put("VERDE/NEVE", java.awt.Color.GREEN)
colori.put("VIDEOSORVEGLIANZA", java.awt.Color.PINK)
return colori
}
}
then, when i want to render the chart
PieRenderer renderer = new PieRenderer();
Code: Select all
PlotPie plotPie = new PiePlot(pieDatasetTipiChiuse);
plotPie.setDirection(Rotation.CLOCKWISE)
plotPie.setStartAngle(90)
plotPie.setBackgroundPaint(Color.white)
plotPie.setLabelGenerator(new CustomLabelGenerator()) // this class is used for generation of customized labels
plotPie.setLabelOutlinePaint(Color.WHITE)
plotPie.setLabelFont(new Font("SansSerif", Font.PLAIN, 10))
JFreeChart chart3 = new JFreeChart(plotPie)
renderer.setColor(plotPie, pieDatasetTipiChiuse);
final File file3 = new File("tipiChiuseLotto" + numLotto + ".png");
ChartUtilities.saveChartAsPNG(file3, chart3, 500, 400, info);
the output is coerent with the colour i want, but not the chart
here the output
Code: Select all
plot.setSectionPaint(0, java.awt.Color[r=255,g=255,b=255]), valore: CONDIZIONAMENTO
plot.setSectionPaint(1, java.awt.Color[r=64,g=64,b=64]), valore: ANTI-INTRUSIONE
plot.setSectionPaint(2, java.awt.Color[r=255,g=0,b=0]), valore: SERVIZIO ENERGIA-TERMICO
plot.setSectionPaint(3, java.awt.Color[r=255,g=0,b=0]), valore: SPECIALI
plot.setSectionPaint(4, java.awt.Color[r=255,g=255,b=0]), valore: ELETTRICA
someone can help me?