cal.setTimeInMillis(dt.getTime() + milliseconds);
return cal.getTime();
}
private void showSplineWithPlotBands() {
InvientChartsConfig chartConfig = new InvientChartsConfig();
chartConfig.getGeneralChartConfig().setType(SeriesType.SPLINE);
chartConfig.getTitle().setText("Wind speed during two days");
chartConfig
.getSubtitle()
.setText(
"October 6th and 7th 2009 at two locations in Vik i Sogn, Norway");
//
chartConfig
.getTooltip()
.setFormatterJsFunc(
"function() {"
+ " return '' + $wnd.Highcharts.dateFormat('%e. %b %Y, %H:00', this.x) +': '+ this.y +' m/s'; "
+ "}");
DateTimeAxis xAxis = new DateTimeAxis();
LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
xAxesSet.add(xAxis);
chartConfig.setXAxes(xAxesSet);
NumberYAxis yAxis = new NumberYAxis();
yAxis.setTitle(new AxisTitle("Wind speed (m/s)"));
yAxis.setMin(0.0);
yAxis.setMinorGrid(new MinorGrid());
yAxis.getMinorGrid().setLineWidth(0);
yAxis.setGrid(new Grid());
yAxis.getGrid().setLineWidth(0);
NumberPlotBand numberBand = new NumberPlotBand("Light air");
numberBand.setRange(new NumberRange(0.3, 1.5));
numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
numberBand.setLabel(new PlotLabel("Light air"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
numberBand = new NumberPlotBand("Light breeze");
numberBand.setRange(new NumberRange(1.5, 3.3));
numberBand.setColor(new RGBA(0, 0, 0, 0.0f));
numberBand.setLabel(new PlotLabel("Light breeze"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
numberBand = new NumberPlotBand("Gentle breeze");
numberBand.setRange(new NumberRange(3.3, 5.5));
numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
numberBand.setLabel(new PlotLabel("Gentle breeze"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
numberBand = new NumberPlotBand("Moderate breeze");
numberBand.setRange(new NumberRange(5.5, 8.0));
numberBand.setColor(new RGBA(0, 0, 0, 0.0f));
numberBand.setLabel(new PlotLabel("Moderate breeze"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
numberBand = new NumberPlotBand("Fresh breeze");
numberBand.setRange(new NumberRange(8.0, 11.0));
numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
numberBand.setLabel(new PlotLabel("Fresh breeze"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
numberBand = new NumberPlotBand("Strong breeze");
numberBand.setRange(new NumberRange(11.0, 14.0));
numberBand.setColor(new RGBA(0, 0, 0, 0.0f));
numberBand.setLabel(new PlotLabel("Strong breeze"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
numberBand = new NumberPlotBand("High wind");
numberBand.setRange(new NumberRange(14.0, 15.0));
numberBand.setColor(new RGBA(68, 170, 213, 0.1f));
numberBand.setLabel(new PlotLabel("High wind"));
numberBand.getLabel().setStyle("{ color: '#606060' }");
yAxis.getPlotBands().add(numberBand);
LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
yAxesSet.add(yAxis);
chartConfig.setYAxes(yAxesSet);
SplineConfig splineCfg = new SplineConfig();
splineCfg.setLineWidth(4);
splineCfg.setHoverState(new SeriesState());
splineCfg.getHoverState().setLineWidth(5);
//
SymbolMarker symbolMarker = new SymbolMarker(false);
splineCfg.setMarker(symbolMarker);
symbolMarker.setSymbol(Symbol.CIRCLE);
symbolMarker.setHoverState(new MarkerState());
symbolMarker.getHoverState().setEnabled(true);
symbolMarker.getHoverState().setRadius(5);
symbolMarker.getHoverState().setLineWidth(1);
splineCfg.setPointStart((double) getPointStartDate(2009, 8, 6));
splineCfg.setPointInterval(3600000.0);
chartConfig.addSeriesConfig(splineCfg);
InvientCharts chart = new InvientCharts(chartConfig);
DateTimeSeries series = new DateTimeSeries("Hestavollane", splineCfg, true);
series.setSeriesPoints(getDateTimePoints(series, 4.3, 5.1, 4.3, 5.2,
5.4, 4.7, 3.5, 4.1, 5.6, 7.4, 6.9, 7.1, 7.9, 7.9, 7.5, 6.7,