0

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?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
William Roberts
  • 319
  • 2
  • 5
  • 21

2 Answers2

0

When I have to customize elements in Vaadin I usually try one of the following:

  • from java classes, isolate the component and use a setter method if existing
  • do the changes from CSS, a starting point is here or here.
  • do the changes from javascript, this is a good starting point here

My recommendation is in this order.

I hope it helps.

Community
  • 1
  • 1
Laurentiu
  • 74
  • 2
0

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);
Jose Luis Martin
  • 10,459
  • 1
  • 37
  • 38