Displaying javafx 2 linechart values on hover -
i have been using this example project, , works nice.
my question: possible offset hovered node such not overlay underlying data point. example centers hovered node right on "normal" node. kind of gets in way on chart lot of data points.
a simple solution set custom translation displayed label
. following code extracted example.
private label createdatathresholdlabel(int priorvalue, int value) { final label label = new label(value + ""); label.settranslatey(-25); //move label 25 pixels label.getstyleclass().addall("default-color0", "chart-line-symbol", "chart-series-line"); label.setstyle("-fx-font-size: 20; -fx-font-weight: bold;"); if (priorvalue == 0) { label.settextfill(color.darkgray); } else if (value > priorvalue) { label.settextfill(color.forestgreen); } else { label.settextfill(color.firebrick); } label.setminsize(label.use_pref_size, label.use_pref_size); return label; }
Comments
Post a Comment