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
I found a this Oracle Document on Styling charts with CSS and on that page scroll down to Setting Chart Colors for what you are specifically looking for.
How to set a color to linecharts?
The simplest way for this is the following CSS snippet:
.default-color0.chart-series-line { -fx-stroke: #e9967a; }
.default-color1.chart-series-line { -fx-stroke: #f0e68c; }
.default-color2.chart-series-line { -fx-stroke: #dda0dd; }
This unfortunately will not work by id or which series, but rather the order the series are placed in the graph. You can also set the line styles though by doing:
.chart-series-line {
-fx-stroke-width: 2px;
-fx-effect: null;
}
How to set a css class to series?
Unfortunately I do not see a way to do that. It would be nice to be able to create CSS rules based off the XYChart.Series name property, but I do not think that is possible.