Make sure to assign unique IDs to your charts in your code:
...
final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
lineChart.setId("chart1");
...
final LineChart<Number,Number> lineChart2 = new LineChart<Number,Number>(xAxis,yAxis);
lineChart2.setId("chart2");
...
To style each chart individually using CSS, refer to the chart ID with the #id
selector:
If you want one Line chart series to be black and another to be yellow:
#chart1 .default-color0.chart-series-line {
-fx-stroke: black;
}
#chart2 .default-color0.chart-series-line {
-fx-stroke: yellow;
}
For more information on styling JavaFX charts with CSS, check out Styling Charts with CSS.