Reputation: 195
I am trying to embed a JavaFX line chart in a Swing application. It is showing up fine inside my application, but when I try to change the lines widths, I get stuck. I don't know how the CSS styling is supposed to work. I see LineChart
has a setStyle()
method which I tried to utilize from an example:
lineChart.setStyle(".chart-series-line { \n"
+ " -fx-stroke-width: 2px;\n"
+ "}");
But no change is shown. I then tried to lookup my series :
for (int i = 0; i <= value; i++)
lineChart.lookupAll(".series" + i).forEach(n -> n.setStyle("-fx-stroke-width: 3px;"));
Now the lines changed width vertically but not horizontally.
Upvotes: 1
Views: 11149
Reputation: 3923
Add the following style in your CSS file :
.thick-chart .chart-series-line {
-fx-stroke-width: 2px;
}
and use StyleClass instead of Style :
lineChart.getStyleClass().add("thick-chart");
Upvotes: 0
Reputation: 195
It seems my problem came from the symbols.
I had 365 items on the x axis, which made it paint the symbols on top of each other making it look like i really thick line. I could fix this by disabling the symbols
lineChart.setCreateSymbols(false);
Upvotes: 3