Reputation: 2581
I am trying in this code to style dynamically my AreaChart
series but it's not working. I want to change each series background without passing by CSS.
XYChart.Series series1 = new XYChart.Series();
series1.getNode().setStyle("chart-series-area-fill { -fx-fill: transparent; }");
Upvotes: 3
Views: 1430
Reputation: 159291
Solution
Use the following code after you have shown the chart on a stage:
// look up first series fill.
Node node = ac.lookup(".default-color0.chart-series-area-fill");
// set the first series fill to translucent pale green
node.setStyle("-fx-fill: rgba(152, 251, 152, 0.5);");
Why your approach does not work
You can't apply a css selector in a setStyle call, according to the javadoc:
this variable contains style properties and values and not the selector portion of a style rule.
Upvotes: 2