José
José

Reputation: 3179

Change color and line type of LineChart symbols

I want to change the colors of LineChar symbols, currently the color are automatically asigned by JavaFX when i add a new series to the graph.

It will be also nice if i can change the line type, i want to have some symbols with doted lines others with solid lines.

Upvotes: 0

Views: 2617

Answers (1)

José
José

Reputation: 3179

There is a detailed answer in How to set specific color to JavaFX XYChart.Series?

For my use case that use dynamic series, i end up with something like:

String seriesClass = null;
for(String styleClass : series.getNode().getStyleClass())
{
    if(styleClass.startsWith("series"))
    {
        for(javafx.scene.Node n : _chart.lookupAll("." + seriesClass))
        {
             n.setStyle("-fx-stroke-dash-array: 10 10");
        }
        break;
    }
}

Here the style just change line types , but you can also update other CSS properties.

Upvotes: 1

Related Questions