Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin charts Color
I'd like to know how to set one color by bar of a bar graph.
XAxis xaxis = new XAxis(); xaxis.setCategories( "COL1", "COL2", ); 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: http://demo.vaadin.com/charts/#ModifyOnePoint and it works as expected.
Hope it helps
Thanks a lot for your answer, It's exactly what I was looking for.
That's works like you say.
andom r = new Random(); temporaryStatusChartSeries.get(0).setY(r.nextInt(19)); temporaryStatusChartSeries.get(1).setY(r.nextInt(19)); temporaryStatusChartSeries.get(2).setY(r.nextInt(19)); temporaryStatusChartSeries.update(temporaryStatusChartSeries.get(0)); temporaryStatusChartSeries.update(temporaryStatusChartSeries.get(1)); temporaryStatusChartSeries.update(temporaryStatusChartSeries.get(2));