I have a JavaFX app where I want the user to be able to control the symbols, linestyles, etc. in a lineChart. Rather than create multiple stylesheets, I want to build this functionality into the Java code. Thanks to Jewelsea's excellent previously posted example, I can dynamically change the line style, which is great! But I'm not managing to change the default symbol style.
It is not clear to me how much of the .css statements can be used verbatim inline in a call to node.setStyle. Ie, I see that '-fx-*' commands work from Java code. But symbols in the .css file are defined with a different syntax, and merely inserting the css lines into my code in Java is not working.
Here is an example from my code:
StringBuilder styleString = new StringBuilder();
// do some stylin'
switch (getLineStyle.getValue().toString()) {
case "Line and points":
styleString.append("-fx-stroke: blue; -fx-stroke-width: 2; ");
styleString.append(
".chart-symbol {-fx-background-color: blue; -fx-background-radius: 3px;}");
engChart.setCreateSymbols(true);
break;
case "Line only":
styleString.append("-fx-stroke: blue; -fx-stroke-width: 2; ");
engChart.setCreateSymbols(false);
break;
In case "lines and points", I am able to control the color and width using this code, but the attempt to control the symbols fails miserably. I took the syntax from here:
http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#introscenegraph
If there is a better reference to use to do this sort of control inline, I'd appreciate knowing what it is.
Can anyone tell me how I might manipulate the symbols properly, inline? Thanks.