Change BarChart Legend color

Peter Penzov peter.penzov at gmail.com
Fri Apr 3 13:46:48 UTC 2015


Hi All,
   I have a question about changing dynamically the color of the BarChart.
I'm using this code to change the chart Label for now successfully:

Legend legend = (Legend) schart.lookup(".chart-legend");
            Legend.LegendItem li1 = new Legend.LegendItem("Over 8", new
Rectangle(10, 4, Color.NAVY));
            Legend.LegendItem li2 = new Legend.LegendItem("Over 5 up to 8",
new Rectangle(10, 4, Color.FIREBRICK));
            Legend.LegendItem li3 = new Legend.LegendItem("Below 5", new
Rectangle(10, 4, Color.ORANGE));
            legend.getItems().setAll(li1, li2, li3);

But Label is from the internal package com.sun.javafx.charts.Legend and I
may have problems into the next JVM versions.

Is there other way to change BarChart label colors. Please refer to this
link for more information:

http://stackoverflow.com/questions/29121687/change-color-in-barchart-legend

Also are there any plans to make Label public package?

BR,
Peter


More information about the openjfx-dev mailing list