English 中文(简体)
How to Fill the gradient color in JFreeChart PieChart3D?
原标题:

I want to fill the PieChart3D with a gradient color, I am using JFreeChart for drawing the graph. but it is not filling with gradient color rather than it is filled with a solid color.. Here is the code I am using for changing the color.

public void setColor(PiePlot3D plot, PieDataset dataset) {
        GradientPaint gp0 = new GradientPaint(1.0f, 1.0f, Color.BLACK,
                0.3f, 2.1f, Color.lightGray);
        GradientPaint gp1 = new GradientPaint(0.5f, 0.5f, Color.green,
                0.0f, 0.0f, Color.lightGray);
        GradientPaint gp2 = new GradientPaint(0.5f, 0.5f, Color.red,
                0.0f, 0.0f, Color.lightGray);

        List<Comparable> keys = dataset.getKeys();
        int aInt;

        for (int i = 0; i < keys.size(); i++) {
            aInt = i % this.color.length;
            if (i == 0) {
                plot.setSectionPaint(keys.get(i), gp0);
                plot.setBackgroundPaint(gp0);
            }
            if (i == 1) {
                plot.setSectionPaint(keys.get(i), gp1);
            }
            if (i == 2) {
                plot.setSectionPaint(keys.get(i), gp2);
            }
        }
    }

any onle can please help me out on this? the above code is working for bar chart but not in piechart... I ahve also tried 2D with out any success..

问题回答

Is your pie chart still using your colors, but not in a gradient? The reason I ask is that if you are seeing the default colors then you need to change where your plot so it doesn t auto-populate the section colors. I haven t done this on a 3D plot, but I needed to for a 2D plot.

If this is the fix chart having start and end range of your pie is same then you can achive that by giving correct x-y cordinates.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签