I'm writing a test programm where you have to get over 70% to pass the test. I have setup a LineChart and one series, which takes the percent value and the date as coordinates. I want to color the nodes which are >= 70% green and the rest red. Here is a code fragment:
for(final XYChart.Data<String, Number> data : series.getData()){
System.out.println(data.getXValue());
if(percent>=70){
data.getNode().setStyle("-fx-background-color: green;");
}else{
data.getNode().setStyle("-fx-background-color: red;");
}
data.getNode().addEventHandler(MouseEvent.MOUSE_MOVED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// TODO Auto-generated method stub
data.getNode().setCursor(Cursor.HAND);
Tooltip.install(data.getNode(), new Tooltip("Am: \n"+data.getXValue()+"\nZu: "+data.getYValue()+"%"));
}
});
}
The problem is that I'm not able to color a specific node in one series. I hope someone is able to help me.