javamysqleclipsevaadinvaadin-charts

Color an individual bar in a vaadin basic bar chart


I have a basic bar chart in my project

Chart chart = new Chart(ChartType.BAR);

How could I get the 10th or 20th bar in my chart and set the color of that individual bar?


Solution

  • If you are using DataSeries you could set the color for a concrete DataSeriesItem via DataSeriesItem.setColor() method.

    for example, starting from the Chart instance

    DataSeries dataSeries = (DataSeries) chart.getConfiguration().getSeries().get(0); 
    dataSeries.get(10).setColor(SolidColor.RED);