zoukankan      html  css  js  c++  java
  • JFreeChat学习柱状图方法补充

          //获得Plot对象
          CategoryPlot plot = chart.getCategoryPlot();


          //设置网格背景颜色
          plot.setBackgroundPaint(Color.white);
         
          //设置网格竖线颜色
          plot.setDomainGridlinePaint(Color.pink);
         
          //设置网格横线颜色
          plot.setRangeGridlinePaint(Color.pink);
         
          //显示每个柱的数值,并修改该数值的字体属性
          BarRenderer3D renderer = new BarRenderer3D();
          renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
          renderer.setBaseItemLabelsVisible(true);
         
          //默认的数字显示在柱子中,通过如下两句可调整数字的显示
          //注意:此句很关键,若无此句,那数字的显示会被覆盖,给人数字没有显示出来的问题
          renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
          renderer.setItemLabelAnchorOffset(10D);
         
          //设置每个地区所包含的平行柱的之间距离
          renderer.setItemMargin(0.3);
         
          //设置地区、销量的显示位置,相当于执行上面的内容
          plot.setRenderer(renderer);
         
          //将下方的“肉类”放到上方
          plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);


          //将默认放在左边的“销量”放到右方
          plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    顺便上图啦:

  • 相关阅读:
    GCC内置函数
    父类子类的拷贝构造与赋值
    外传三 动态内存申请的结果
    外传二 函数的异常规格说明
    外传一 异常处理深度解析
    第69课 技巧,自定义内存管理
    第68课 拾遗,令人迷惑的写法
    第67课 经典问题解析五
    第66课 C++中的类型识别
    第65课 C++中的异常处理(下)
  • 原文地址:https://www.cnblogs.com/liuhuapiaoyuan/p/3113471.html
Copyright © 2011-2022 走看看