0

I need to change the color of bar in a bar chart. I do not want to use extra css file. Is there a method to do that in code?

...
@FXML
private void initialize(){

    orgNames.addAll(dc.getSortedAssignedOrg().values());
    orgNameAxis.setCategories(orgNames);
    orgNameAxis.setLabel("Name of Organizations");
    orgNameAxis.tickLabelFontProperty().set(Font.font(10));
    yAxis.setLabel("Saturation");
}
 public void setPersonData() {
    XYChart.Series<String, Number> series  = new XYChart.Series<>();

   for ( String entryOrg : dc.getSortedAssignedOrg().values()) {
       for(List<String> entryfuncType : dc.getFuncTypeOrg().values()){
           if(entryOrg.equals(entryfuncType.get(5)) && entryfuncType.contains("hasType")){
            int yellow =   Collections.frequency(
                       entryfuncType, "yellow");
            int green = Collections.frequency(entryfuncType, "Green");
            int typeNumber = Collections.frequency(entryfuncType, "hasType");
            float sat = (Float.parseFloat((entryfuncType.get(2))) * green )/ typeNumber;
            //change color
              series.getData().add(new XYChart.Data<String,Number>(entryOrg, sat));

           }
       }

   }

   barChart.getData().add(series);
   }
Iman
  • 769
  • 1
  • 13
  • 51

0 Answers0