use of com.vaadin.addon.charts.model.PlotOptionsArearange in project charts by vaadin.
the class WebXYChartSelection method createScatterChart.
private Chart createScatterChart() {
final Chart scatterChart = new Chart(ChartType.SCATTER);
scatterChart.setId("chart");
scatterChart.getConfiguration().getChart().setZoomType(ZoomType.XY);
scatterChart.getConfiguration().disableCredits();
scatterChart.getConfiguration().setTitle("Selections as area ranges");
scatterChart.getConfiguration().setSubTitle("Drag with mouse to make selections. Click the legend items to toggle visibility.");
PlotOptionsScatter scatterOptions = new PlotOptionsScatter();
scatterOptions.setAnimation(false);
scatterOptions.setPointStart(1);
DataSeries series = new DataSeries();
series.setPlotOptions(scatterOptions);
series.setName("Original");
Random random = new Random(0);
for (int i = 0; i < 20; i++) {
DataSeriesItem dsi = new DataSeriesItem();
dsi.setY(random.nextInt(10));
dsi.setX(random.nextInt(10));
series.add(dsi);
}
scatterChart.getConfiguration().addSeries(series);
scatterChart.addChartSelectionListener(new ChartSelectionListener() {
@Override
public void onSelection(ChartSelectionEvent event) {
double xStart = event.getSelectionStart();
double xEnd = event.getSelectionEnd();
double yStart = event.getValueStart();
double yEnd = event.getValueEnd();
Number[][] data = new Number[][] { { xStart, yStart, yEnd }, { xEnd, yStart, yEnd } };
PlotOptionsArearange areaRangePlot = new PlotOptionsArearange();
areaRangePlot.setFillOpacity(0.1f);
areaRangePlot.setLineWidth(0);
RangeSeries selectionSeries = new RangeSeries("Selection", data);
selectionSeries.setPlotOptions(areaRangePlot);
scatterChart.getConfiguration().addSeries(selectionSeries);
scatterChart.drawChart();
areaRangePlot.setAnimation(false);
}
});
scatterChart.drawChart();
return scatterChart;
}
use of com.vaadin.addon.charts.model.PlotOptionsArearange in project charts by vaadin.
the class ColorThreshold method getChart.
@Override
protected Component getChart() {
Chart chart = (Chart) super.getChart();
PlotOptionsArearange plotOptions = new PlotOptionsArearange();
// make "value" under -5 blue. Default threshold value is 0
plotOptions.setNegativeColor(getThemeColors()[1]);
plotOptions.setThreshold(-5);
chart.getConfiguration().setPlotOptions(plotOptions);
return chart;
}
Aggregations