javafx barchart bar colors


I am trying to change the color of all the bars of a series in javafx barcharts. See for example:

All the bars for 2005 are in series3 and are painted in light blue. I would like to paint them, say, in red.

The css has the .data<n>.chart-bar selectors, but they change the colors of all the bars at the same position in all series, and not those of a same serie. E.g. .data0.chart-bar would change all the colors for Austria. Does anyone know a solution?

7/18/2014 4:18:22 PM

Oh.. I know I had this in here somewhere....

Aha! found it! change these properties to the colors you want, for your example, to change series3 it would be the .default-color2.chart-bar bit:

.default-color0.chart-bar { -fx-bar-fill: #f9d900; }
.default-color1.chart-bar { -fx-bar-fill: #a9e200; }
.default-color2.chart-bar { -fx-bar-fill: #22bad9; }
.default-color3.chart-bar { -fx-bar-fill: #0181e2; }
.default-color4.chart-bar { -fx-bar-fill: #2f357f; }
.default-color5.chart-bar { -fx-bar-fill: #860061; }
.default-color6.chart-bar { -fx-bar-fill: #c62b00; }
.default-color7.chart-bar { -fx-bar-fill: #ff5700; }

To help in the future, here's the link to caspian.css (default stylesheet for Java 7) and modena.css (default stylesheet for Java 8) which are perhaps the most useful files in javafx css land, ever. They list every default style that gets applied to javafx, and therefore, lists most (not all) of the properties you could ever want to override in javafx with your own .css Good luck!

7/18/2014 4:35:51 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow