Search code examples
javafxcolorsgetcolor

JavaFX get PieChart Color


Is there a way to get the default Pie Chart color in JavaFX? I've been looking for solutions but I couldn't get any. I have seen a way to set the color of the Pie Chart, and then work my way to get the Color value. However, I want to just use the default color of the PieChart provided by JavaFX, and just return it so I could use it for something else. Is there a way to do it?


Solution

  • With JavaFX 8+ the default CSS theme called Modena and you can find a lot of information in this Github gist. All the charts are using the same color palette which is :

    CHART_COLOR_1: #f3622d;
    CHART_COLOR_2: #fba71b;
    CHART_COLOR_3: #57b757;
    CHART_COLOR_4: #41a9c9;
    CHART_COLOR_5: #4258c9;
    CHART_COLOR_6: #9a42c8;
    CHART_COLOR_7: #c84164;
    CHART_COLOR_8: #888888;
    

    keep in mind that although the link above is a good way to find some properties is always recommended to read the JavaFX CSS Reference Guide