栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

JFreeChart在同一数据系列的不同区域中使用不同的颜色

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JFreeChart在同一数据系列的不同区域中使用不同的颜色

看起来线之间的着色的处理是在

drawFirstPassShape

线条颜色似乎基于先前的点

对您的修改

XYLineAndShapeRenderer
使用渐变填充来混合线条颜色。

XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(){        @Override        public Paint getItemPaint(int row, int col) { Paint cpaint = getItemColor(row, col); if (cpaint == null) {     cpaint = super.getItemPaint(row, col); } return cpaint;        }    public Color getItemColor(int row, int col) {        System.out.println(col + "," + dataset.getY(row, col));        double y = dataset.getYValue(row, col);        if(y<=3) return Color.black;        if(y<=4) return Color.green;;        if(y<=5) return Color.red;;        if(y<=6) return Color.yellow;;        if(y<=10) return Color.orange;;        return null;    }    @Override    protected void drawFirstPassShape(Graphics2D g2, int pass, int series,        int item, Shape shape) {        g2.setStroke(getItemStroke(series, item));        Color c1 = getItemColor(series, item);        Color c2 = getItemColor(series, item - 1);        GradientPaint linePaint = new GradientPaint(0, 0, c1, 0, 300, c2);        g2.setPaint(linePaint);        g2.draw(shape);    }};

我已删除,

ColorUtil.hex2Rgb
因为我无权访问该类/方法。您可能需要修改
GradientPaint
以考虑
点之间的距离/渐变。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/609535.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号