DefaultCategoryDataset dataset = new DefaultCategoryDataset();
addValue(double double0, Comparable comparable, Comparable comparable2)
addValue(double double0, Comparable comparable, Comparable comparable2)
调试欢乐多
| | | |
| | | |
| | | |
__|__|___|__|________ 这样的是单系列
__
__ __| |
| | | | |
| |__ | | |
| | | | | |
__|__|__|___|__|__|______ 这样的是两个系列
addValue(double double0, Comparable comparable, Comparable comparable2)是画单系列的吧
String[] categoryNames = new String[] {"First Quater","Second Quater"};
Number[][] categoryData = new Integer[][] {{new Integer(20),new Integer(35)},{new Integer(40),new Integer(60)}};
CategoryDataset categoryDataset = new DefaultIntervalCategoryDataset
(seriesNames,
categoryNames,
categoryData,
categoryData);CategoryAxis categoryAxis = new CategoryAxis("");
ValueAxis valueAxis = new NumberAxis("");
BarRenderer renderer = new BarRenderer();
Plot plot = new CategoryPlot(categoryDataset,categoryAxis, valueAxis, renderer);
font=new Font("Sans",Font.CENTER_BASELINE,20);//这个地方是设置统计图标题的字体和大小
JFreeChart chart = new JFreeChart("", font, plot, false);还是我自己解决了,有没有人知道怎样可以显示中文
chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 1000F, 0.0F, Color.red));
chart.setTitle(new TextTitle(titles, new Font("隶书", Font.ITALIC, 15))); font=new Font("黑体",Font.TRUETYPE_FONT, 12); //
StandardLegend legend = (StandardLegend) chart.getLegend();
legend.setItemFont(font); //设置柱状图的前景色
CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setForegroundAlpha(0.9F); //获取plot的render对象(控制每个柱的外观和柱的label等属性)
BarRenderer render = (BarRenderer)plot.getRenderer();
render.setItemLabelsVisible(new Boolean(true)); //在每个柱上显示统计数据
render.setItemMargin(-2.5); //设置柱间距,数值越大表示间隔越大 //设置统计坐标轴的字体
CategoryAxis domain_axis = plot.getDomainAxis();
domain_axis.setTickLabelFont(font); //设置数值坐标轴的说明文字的字体和显示的角度
ValueAxis value_axis=plot.getRangeAxis();
value_axis.setLabelFont(font);
value_axis.setLabelAngle(1.570795); //以弧度为单位:角度×圆周率÷180
value_axis.setUpperMargin(0.25); //设置坐标轴顶部距柱状图距离占整个坐标轴程度的百分比
所以font=new Font("Sans",Font.CENTER_BASELINE,20);
可是不行