当前位置:编程学习 > JAVA >>

JFreeChart柱状图



求大神解决。

柱状图的颜色顺序从上到下 和 旁边的凡例的颜色顺序是相反的,目的就是要求颜色一致。

关键代码如下,

//chart本体の作成
JFreeChart chart;

GraphReportSettingBean oldBean = user.getGraphReportSettingBean(key);

try {
CategoryDataset dataset1 = createOriginalDatasetForCategory(out, user, key);

if(bNoData_) {
return;
}

if(graphType_==graphTypeBar){
if(isStackedBarChart){
chart = ChartFactory.createStackedBarChart(title, xLabel, yLabel, dataset1, PlotOrientation.VERTICAL, false, true, true);
}else{
chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataset1, PlotOrientation.VERTICAL, false, true, true);
}

}else if(graphType_==graphTypeLine){
if(isStackedLineChart){//積み上げ棒グラフは存在しないのでエリアチャートで代替
chart = ChartFactory.createStackedAreaChart(title, xLabel, yLabel, dataset1, PlotOrientation.VERTICAL, false, true, true);
}else{
chart = ChartFactory.createLineChart(title, xLabel, yLabel, dataset1, PlotOrientation.VERTICAL, false, true, true);

}

}else if(graphType_==graphTypeSpider){
SpiderWebPlot plot = new SpiderWebPlot(dataset1);
chart = new JFreeChart(plot);
chart.removeLegend();

}else if(graphType_==graphTypePie){//Pie系チャートではグラフ上に別のグラフを重ね合わせることが出来ない。MultiplePieChartを使えってことらしい。
chart = ChartFactory.createMultiplePieChart(title, dataset1, TableOrder.BY_ROW, false, true, true);

}else{
throw new Exception();
}

chart.setBackgroundPaint(new Color(255,255,255));//chartの背景色

//凡例の設定
if(legendPosition_!=null && !legendPosition_.equals("")){
LegendTitle legend = new LegendTitle(chart.getPlot());
if(legendPosition_.equals("LEFT")){//凡例の表示位置
legend.setPosition(RectangleEdge.LEFT);
}else if(legendPosition_.equals("TOP")){
legend.setPosition(RectangleEdge.TOP);
}else if(legendPosition_.equals("BOTTOM")){
legend.setPosition(RectangleEdge.BOTTOM);
}else{
legend.setPosition(RectangleEdge.RIGHT);
}
legend.setFrame(new BlockBorder(new Color(0,0,0)));//凡例の枠
legend.setBackgroundPaint(new Color(255,255,255));//凡例の背景色
chart.addLegend(legend);
}
 

跪求解决啊~~ 大神 求解决 --------------------编程问答-------------------- 不要沉~~ 我顶一下~ --------------------编程问答--------------------
补充:Java ,  Java相关
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,