图例颜色列表的?

解决方案 »

  1.   

    举个例子,不知道是不是楼主要的:饼图:
    chart = ChartFactory.createPieChart("", data, false,
            false, false); PiePlot pie = (PiePlot)chart.getPlot();
    pie.setSectionPaint(0,new Color(255,255,0));//设置颜色(图例和饼上份额的颜色)
    pie.setSectionPaint(1,new Color(255,0,255));
    pie.setSectionPaint(2,new Color(255,0,0));
    另外,像org.jfree.chart.plot.CategoryPlot
    这个类理有如下方法,允许你自己设置图例:setFixedLegendItemspublic void setFixedLegendItems(LegendItemCollection items)    Sets the fixed legend items for the plot. Leave this set to null if you prefer the legend items to be created automatically.    Parameters:
            items - the legend items (null permitted).
        See Also:
            getFixedLegendItems()
      

  2.   

    这里详细的说明,希望对LZ有帮助!
    http://blog.chinaunix.net/u1/59153/showart_973391.html
      

  3.   

    你说的图例是指生成的图片的颜色?是背景色?是前景色?
    还是比如柱状图的柱子的颜色?不是很清楚
    http://www.jfree.org/jfreechart/
    这是jfreechart的官网,里面有例子,也有API doc,楼主可以自己查一下,你想要的~~
      

  4.   


     public String createBarChart(CategoryDataset dataset, String xName, String yName,
                String chartTitle, String chartName) {
            JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // 图表标题
                    xName, // 目录轴的显示标签
                    yName, // 数值轴的显示标签
                    dataset, // 数据集
                    PlotOrientation.VERTICAL, // 图表方向:水平、垂直
                    true, // 是否显示图例(对于简单的柱状图必须是false)
                    true, // 是否生成工具
                    false // 是否生成URL链接
                    );
            Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, FONT_SIZE);
            chart.setTextAntiAlias(true);
            // create plot
            CategoryPlot plot = chart.getCategoryPlot();
            chart.setBackgroundPaint(Color.white);
            // 设置横虚线可见
            plot.setRangeGridlinesVisible(true);
            // 虚线色彩
            plot.setRangeGridlinePaint(Color.gray);
            // x轴设置
            CategoryAxis domainAxis = plot.getDomainAxis();
            // 轴标题
            domainAxis.setLabelFont(labelFont);
            domainAxis.setTickLabelPaint(Color.black); // 横轴下的字体颜色
            // 轴数值
            domainAxis.setTickLabelFont(labelFont);
            domainAxis.setLabelPaint(Color.black); // 横轴主字体颜色        // 设置距离图片左端距离
            domainAxis.setLowerMargin(BAR_POSITION);
            // 设置距离图片右端距离
            domainAxis.setUpperMargin(BAR_POSITION);
            plot.setDomainAxis(domainAxis);
            // 设置柱图背景色(注意,系统取色的时候要使用16位的模式来查看颜色编码,这样比较准确)
            plot.setBackgroundPaint(new Color(BAR_BACK_RCOLOR, BAR_BACK_GCOLOR, BAR_BACK_BCOLOR));
            NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
            numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            numberaxis.setAutoRangeIncludesZero(true);
            BarRenderer3D renderer = new BarRenderer3D();
            // 设置柱子宽度
            renderer.setMaximumBarWidth(BAR_WIDTH);
            // 设置柱子高度
            // renderer.setMinimumBarLength(0.2);
            // 设置柱子边框颜色
            // renderer.setBaseOutlinePaint(Color.BLACK);
            // 设置柱子边框可见
            // renderer.setDrawBarOutline(true);        // 设置柱的颜色
            renderer.setSeriesPaint(0, new Color(BAR_FRONT_RCOLOR, BAR_FRONT_GCOLOR, BAR_FRONT_BCOLOR));        // 设置每个地区所包含的平行柱的之间距离
            // renderer.setItemMargin(0.0);        // 显示每个柱的数值,并修改该数值的字体属性
            renderer.setIncludeBaseInRange(true);
            renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
            renderer.setBaseItemLabelsVisible(true);        plot.setRenderer(renderer);
            // 设置柱的透明度
            plot.setForegroundAlpha(1.0f);
            // 生成图表
            return makePicture(chart, chartName);
        }
    这是之前写的一个例子,但是不知道包不包含你想要的~~,仅供参考
      

  5.   

      public String createBarChart(CategoryDataset dataset, String xName, String yName,
                String chartTitle, String chartName) {
            JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // 图表标题
                    xName, // 目录轴的显示标签
                    yName, // 数值轴的显示标签
                    dataset, // 数据集
                    PlotOrientation.VERTICAL, // 图表方向:水平、垂直
                    true, // 是否显示图例(对于简单的柱状图必须是false)
                    true, // 是否生成工具
                    false // 是否生成URL链接
                    );
      

  6.   

    在跳出一个通用的颜色选择窗口后,你可以按照红、绿、蓝的方式来选择一个自己要求的颜色,还可以调节颜色的不透明度、饱和值、色调,然后返回所选择的颜色值。 Gtk2::ColorSelection图例: Gtk2
      

  7.   

    先谢谢了,但是我就是没找到怎么做才来问的.
    google都问了,但是没有相关的
      

  8.   

    呵呵,你看一下它官网有很多demo的,用jfreechart生成一些图表还是不错的~~
      

  9.   

    jfreechart.getPolt(); // 得到一个CategoryPlot
    plot.setBackgroundPaint(paintObject); // 实现Paint接口的对象都可以作为paintObject
    比如Color(设置纯色)、GradientPaint(设置渐变)、TexturePaint(甚至是材质)等等
      

  10.   

    那个应该是jfreechart默认的,你要改只能去改它的源代码了,改完后再生成.class,但这就麻烦了,能看就行了,默认的也挺好看了呀,我觉得没什么必要改的.
      

  11.   

    楼主看看这个jFreeChart教程