use of com.vaadin.addon.charts.model.PlotOptionsScatter 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.PlotOptionsScatter in project charts by vaadin.
the class ScatterWithRegressionLine method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
Color[] colors = getThemeColors();
XAxis x = new XAxis();
x.setMin(-0.5);
x.setMax(5.5);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
conf.addyAxis(y);
conf.setTitle("Scatter plot with regression line");
DataSeries series = new DataSeries();
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setColor(colors[1]);
series.setPlotOptions(plotOptions);
series.setName("Regression Line");
List<DataSeriesItem> list = new ArrayList<DataSeriesItem>();
list.add(new DataSeriesItem(0, 1.11));
list.add(new DataSeriesItem(5, 4.51));
series.setData(list);
plotOptions.setMarker(new Marker(true));
plotOptions.setEnableMouseTracking(true);
Hover hover = new Hover();
hover.setLineWidth(0);
States states = new States();
states.setHover(hover);
plotOptions.setStates(states);
conf.addSeries(series);
ListSeries listSeries = new ListSeries("Observations", 1, 1.5, 2.8, 3.5, 3.9, 4.2);
PlotOptionsScatter plotOptions2 = new PlotOptionsScatter();
listSeries.setPlotOptions(plotOptions2);
Marker marker = new Marker(true);
marker.setRadius(4);
plotOptions2.setMarker(marker);
conf.addSeries(listSeries);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsScatter in project charts by vaadin.
the class ScatterAndPolygon method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart(ChartType.SCATTER);
Configuration conf = chart.getConfiguration();
chart.setId("chart");
conf.getChart().setZoomType(ZoomType.XY);
conf.disableCredits();
conf.setTitle("Height vs Weight");
conf.setSubTitle("Polygon series in Vaadin Charts.");
Tooltip tooltip = conf.getTooltip();
tooltip.setHeaderFormat("<b>{series.name}</b><br>");
tooltip.setPointFormat("{point.x} cm, {point.y} kg");
XAxis xAxis = conf.getxAxis();
xAxis.setStartOnTick(true);
xAxis.setEndOnTick(true);
xAxis.setShowLastLabel(true);
xAxis.setTitle("Height (cm)");
YAxis yAxis = conf.getyAxis();
yAxis.setTitle("Weight (kg)");
PlotOptionsScatter plotOptionsScatter = new PlotOptionsScatter();
DataSeries scatter = new DataSeries();
scatter.setPlotOptions(plotOptionsScatter);
scatter.setName("Observations");
fillScatter(scatter);
DataSeries polygon = new DataSeries();
PlotOptionsPolygon plotOptionsPolygon = new PlotOptionsPolygon();
plotOptionsPolygon.setEnableMouseTracking(false);
polygon.setPlotOptions(plotOptionsPolygon);
polygon.setName("Target");
polygon.add(new DataSeriesItem(153, 42));
polygon.add(new DataSeriesItem(149, 46));
polygon.add(new DataSeriesItem(149, 55));
polygon.add(new DataSeriesItem(152, 60));
polygon.add(new DataSeriesItem(159, 70));
polygon.add(new DataSeriesItem(170, 77));
polygon.add(new DataSeriesItem(180, 70));
polygon.add(new DataSeriesItem(180, 60));
polygon.add(new DataSeriesItem(173, 52));
polygon.add(new DataSeriesItem(166, 45));
conf.addSeries(polygon);
conf.addSeries(scatter);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsScatter in project charts by vaadin.
the class Basic3DScatter method createScatterChart.
private Chart createScatterChart() {
final Chart scatterChart = new Chart(ChartType.SCATTER);
scatterChart.setId("chart");
scatterChart.getConfiguration().disableCredits();
scatterChart.getConfiguration().setTitle("Points of a sphere");
PlotOptionsScatter scatterOptions = new PlotOptionsScatter();
scatterOptions.setAnimation(false);
scatterOptions.setPointStart(1);
DataSeries higherX = new DataSeries();
higherX.setName("Higher X");
DataSeries higherY = new DataSeries();
higherY.setName("Higher Y");
DataSeries higherZ = new DataSeries();
higherZ.setName("Higher Z");
fillSeries(higherX, higherY, higherZ);
scatterChart.getConfiguration().addSeries(higherX);
scatterChart.getConfiguration().addSeries(higherY);
scatterChart.getConfiguration().addSeries(higherZ);
XAxis x = scatterChart.getConfiguration().getxAxis();
x.setGridLineWidth(1);
x.setExtremes(-3, 3);
if (getCurrentTheme().getxAxis().getGridLineColor() != null) {
x.setGridLineColor(getCurrentTheme().getxAxis().getGridLineColor());
}
YAxis y = scatterChart.getConfiguration().getyAxis();
y.setExtremes(-1, 1);
ZAxis z = scatterChart.getConfiguration().getzAxis();
z.setMin(-1);
z.setMax(1);
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(10);
options3d.setBeta(30);
options3d.setDepth(80);
options3d.setViewDistance(40);
Frame frame = new Frame();
Bottom bottom = new Bottom();
bottom.setSize(1);
frame.setBottom(bottom);
options3d.setFrame(frame);
scatterChart.getConfiguration().getChart().setOptions3d(options3d);
scatterChart.drawChart();
return scatterChart;
}
use of com.vaadin.addon.charts.model.PlotOptionsScatter in project charts by vaadin.
the class ThreeDAxisConfiguration method createScatterChart.
private Chart createScatterChart() {
final Chart scatterChart = new Chart(ChartType.SCATTER);
scatterChart.setWidth("450px");
scatterChart.setId("chart");
scatterChart.getConfiguration().disableCredits();
scatterChart.getConfiguration().setTitle("Points of a sphere");
PlotOptionsScatter scatterOptions = new PlotOptionsScatter();
scatterOptions.setAnimation(false);
scatterOptions.setPointStart(1);
DataSeries higherX = new DataSeries();
higherX.setName("Higher X");
DataSeries higherY = new DataSeries();
higherY.setName("Higher Y");
DataSeries higherZ = new DataSeries();
higherZ.setName("Higher Z");
fillSeries(higherX, higherY, higherZ);
scatterChart.getConfiguration().addSeries(higherX);
scatterChart.getConfiguration().addSeries(higherY);
scatterChart.getConfiguration().addSeries(higherZ);
XAxis x = scatterChart.getConfiguration().getxAxis();
x.setGridLineWidth(1);
x.setExtremes(-3, 3);
if (getCurrentTheme().getxAxis().getGridLineColor() != null) {
x.setGridLineColor(getCurrentTheme().getxAxis().getGridLineColor());
}
setAxisConfiguration(scatterChart.getConfiguration().getxAxis());
setAxisConfiguration(scatterChart.getConfiguration().getyAxis());
setAxisConfiguration(scatterChart.getConfiguration().getzAxis());
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(10);
options3d.setBeta(60);
options3d.setDepth(200);
options3d.setViewDistance(40);
Frame frame = new Frame();
Bottom bottom = new Bottom();
bottom.setSize(1);
frame.setBottom(bottom);
options3d.setFrame(frame);
scatterChart.getConfiguration().getChart().setOptions3d(options3d);
scatterChart.drawChart();
return scatterChart;
}
Aggregations