I am trying to style my JavaFX linechart, but can\'t find any way to set color to specific series. I know, that I can style via CSS, but I can\'t find how to set ID or CLASS
jewelsea's answer seems to state that you have to put a style-class on every node of the series. I'm using the following code to style the series of an area chart and only assign a class to the node associated with the series. Example code is in Scala, but should be easy to translate.
When creating the series, I add a series-specific style class:
val s = new XYChart.Series[Number, Number]() //create a new series
s.setName(seriesName) //set its name (display in legend)
s.getNode.getStyleClass.add("series-" + seriesName) //add specific style class
Then inside the css-file I do the following to change the fill color of the series 'butterwings':
.series-butterwings *.chart-series-area-fill{
-fx-fill: #aab597;
}
This works, because the node for the series area is below the series node (which is a group in case of area chart).