如何设置 jfreechart 柱体间的距离 和jfreechart在linux下的中文乱码问题
以下是柱状的设置的代码:
DefaultCategoryDataset dataset = new DefaultCategoryDataset();dataset.addValue( InnerTraffic/SampleRate , " 区域内流量流量 " , " 区域内流量流量 " );dataset.addValue( InterTraffic/SampleRate , " 跨区域流量 " , " 跨区域流量 " );dataset.addValue( AverageUserSpeed , " 域内平均下载速度 " , " 跨区域流量 " );JFreeChart chart = ChartFactory.createBarChart3D( "流量统计图" , "统计周期(单位:天)" , " 流量大小(单位:kb) ,流量速度(单位:kb/s)" ,dataset,PlotOrientation.VERTICAL, true , false , false );chart.setBackgroundPaint(Color.WHITE);CategoryPlot plot = chart.getCategoryPlot();CategoryAxis domainAxis = plot.getDomainAxis();// domainAxis.setVerticalCategoryLabels( false );plot.setDomainAxis(domainAxis);domainAxis.setMaximumCategoryLabelWidthRatio(1);domainAxis.setCategoryMargin(0.01);domainAxis.setLowerMargin(0.05);domainAxis.setUpperMargin(0.05);//中文乱码解决 Font font = new Font("SimSun", 10, 12); // x轴外围字体 plot.getDomainAxis().setLabelFont(font); // x轴刻度字体 plot.getDomainAxis().setTickLabelFont(font); // y轴外围字体 plot.getRangeAxis().setLabelFont(font); // y轴刻度字体 plot.getRangeAxis().setTickLabelFont(font); // 标题字体 chart.getTitle().setFont(font);// 下面 chart.getLegend().setItemFont(font); BarRenderer3D renderer = new BarRenderer3D(); renderer.setBaseOutlinePaint(Color.BLACK); // 设置每个地区所包含的平行柱的之间距离 renderer.setItemMargin(0.01); // 显示每个柱的数值,并修改该数值的字体属性 renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); // 设置柱的透明度 plot.setForegroundAlpha(0.8f); renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, session); String graphURL =request.getContextPath()+"/DisplayChart?filename="+filename;