Search code examples
javajavafxpie-chart

Set JavaFX PieChart label color via css


I have a PieChart in my Java application which looks just like this:

PieChartFullImage

A picture of a label (very hard to see):

The Label

Since the pie chart is rendered on a solid gray background, (which is basically the same color as the labels' text) the labels are virtually invisible. So, my question is, is there any CSS code that would change the color of a PieChart label's text, and if so, what is it?


Solution

  • For any future users below is answer with css code:

    You can find more here : http://docs.oracle.com/javafx/2/charts/css-styles.htm

    .chart-pie-label-line {
        -fx-stroke: #8b4513;
        -fx-fill: #8b4513;
    }
    
    .chart-pie-label { /*this is what you need for labels*/
        -fx-fill: #8b4513;
        -fx-font-size: 1em;
    } 
    .chart-legend {
       -fx-background-color:  #fafad2;
       -fx-stroke: #daa520;
    }
    

    enter image description here