简体   繁体   中英

javafx barchart bar colors

I am trying to change the color of all the bars of a series in javafx barcharts. See for example: http://docs.oracle.com/javafx/2/charts/bar-chart.htm :

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. Eg .data0.chart-bar would change all the colors for Austria. Does anyone know a solution?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM