vaadin charts heatmap color gradient with stops

Hello!
According to this https://github.com/vaadin/book-examples/blob/master/src/com/vaadin/book/examples/addons/charts/HeatMapExample.java book example the simple gradient:
37 // Set colors for the extremes
38 conf.getColorAxis().setMinColor(new SolidColor(“#8080ff”));
39 conf.getColorAxis().setMaxColor(SolidColor.RED);
works and the custom gradient:
41 // TODO This doesn’t work to define multiple color stops
42 // conf.getColorAxis().setPlotBands(new PlotBand{
43 // new PlotBand(0, 60, SolidColor.GREEN),
44 // new PlotBand(60, 80, SolidColor.YELLOW),
45 // new PlotBand(80, 100, SolidColor.RED)});
don’t works yet.
I try to configure a heatmap for displaying a traffic light color gradient. I have four different integer values 0=white, 1=green, 2=yellow and 3=red in my data series.
I have tried it with:
conf.getColorAxis().setStops(new Stop { new Stop(0, SolidColor.WHITE), new Stop(1, SolidColor.GREEN), new Stop(2, SolidColor.YELLOW), new Stop(3, SolidColor.RED) });
In that case the gradient is drawn between white and green. Yellow and red are ignored.
Is there some workaround about this issue? I use vaadin-charts 3.0.0-alpha9.

Stanislav, I recomend you to use http://demo.vaadin.com/charts/#HeatMapExample as an example.
I also recomend you to use beta1, we released last week. There were some helper methods introduced, from example
for stops, you don’t need to create an array, but use a varargs syntax.

Now to your question.
The first parameter in the Stop constructor should be
float
not
int
, it’s basically a percent of all values. So, in your example use 0 , 0.33, 0.66, 1.
You can go to a Heat map example, I"ve linked above and add these 4 lines.

Stop stop1 = new Stop(0.1f, SolidColor.GREEN);
Stop stop2 = new Stop(0.5f, SolidColor.YELLOW);
Stop stop3 = new Stop(0.9f, SolidColor.RED);
config.getColorAxis().setStops(stop1,stop2,stop3);

Privet Dima,

I have another 3 questions about the heatmap:

  1. Is there a possibility to implement the heatmap-xAxis of type AxisType.DATETIME? (I can not get the same automated label distribution as of datetime Axis if i use the combination of HeatSeries / AxisType.CATEGORY)
  2. How can i get the x-Value into SeriesTooltip? (this.x, series.x and point.x don’t works in headerFormat-String).
  3. If i set the title of ColorAxis (conf.getColorAxis().getTitle().setText(“…”)), i can’t see it. Why?

Gruß
Stanislav

…sorry, i use vaadin 7.7.6 and charts 3.1.0