Вопрос

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; }");
Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top