Vaadin charts Color


I’d like to know how to set one color by bar of a bar graph.

XAxis xaxis = new XAxis();

ListSeries chartSeries= new ListSeries();
chartSeries.setData(0,  0,  0);

I see several solutions:

1 - use DataSeriesItem,
The problem is I want to use the chart.updatePoint(0, newValue) to update ona refresh buttton event a database request.
I think I cannot do this with it.

2 - Use PlotOptionsColumn

PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn(); plotOptionsColumn.setColorByPoint(true); chartSeries.setPlotOptions(plotOptionsColumn); The problem is I have two graph on the same screen and the first column of each chat will be the same color.

Is there another way to do that?

Thanks in advance.



You are right, color by point option will use the theme color in same order for different charts.

If you want to define the color for each point you should use DataSeries and DataSeriesItem, those items allows setting the color individually, you can’t use updatePoint, but you can use
update(DataSeriesItem item)
. I haven’t tried it right now, but it’s basically the same that this demo does but with a different chart type:
and it works as expected.

Hope it helps

Hi Guillermo,
Thanks a lot for your answer, It’s exactly what I was looking for.
That’s works like you say.

        Random r = new Random();