use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class TimeDataWithIrregularIntervalsAndLocalizedTexts method getChart.
@Override
protected Component getChart() {
// localizations
final Lang fi = new Lang();
fi.setDecimalPoint(",");
fi.setShortMonths(new String[] { "Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu" });
fi.setMonths(new String[] { "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" });
fi.setWeekdays(new String[] { "Ma", "Ti", "Ke", "To", "Pe", "La", "Su" });
final Lang en = new Lang();
en.setDecimalPoint(".");
en.setShortMonths(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
en.setMonths(new String[] { "January", "February", "March", "April", "May", "June", "Jule", "August", "September", "October", "November", "December" });
en.setWeekdays(new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" });
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Lumen syvyys Vikjafjellet-tunturilla, Norja");
configuration.getSubTitle().setText("Lokalisointiesimerkki");
configuration.getTooltip().setFormatter("");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setDateTimeLabelFormats(new DateTimeLabelFormats());
configuration.getxAxis().getDateTimeLabelFormats().setMonth("%B");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Lumen syvyys (m)"));
yAxis.setMin(0);
DataSeries ls = new DataSeries();
PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
plotOptionsSpline.setDataLabels(new DataLabels(true));
plotOptionsSpline.setEnableMouseTracking(false);
plotOptionsSpline.getDataLabels().setFormatter("return Highcharts.dateFormat('%a %d %B',this.x);");
ls.setPlotOptions(plotOptionsSpline);
ls.setName("Talvi 2009-2010");
Object[][] data3 = getData3();
for (int i = 0; i < data3.length; i++) {
Object[] ds = data3[i];
DataSeriesItem item = new DataSeriesItem((Date) ds[0], (Double) ds[1]);
ls.add(item);
}
configuration.addSeries(ls);
chart.drawChart(configuration);
final Button enButton = new Button("English");
enButton.setId("en-button");
enButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ChartOptions.get().setLang(en);
}
});
final Button fiButton = new Button("Finnish");
fiButton.setId("fi-button");
fiButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ChartOptions.get().setLang(fi);
}
});
HorizontalLayout horizontalLayout = new HorizontalLayout(enButton, fiButton);
horizontalLayout.setSpacing(false);
VerticalLayout verticalLayout = new VerticalLayout(horizontalLayout, chart);
verticalLayout.setSpacing(false);
verticalLayout.setMargin(false);
return verticalLayout;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class ServerSideEvents method createDataSeries.
private DataSeries createDataSeries(Number yvalue) {
final DataSeries series = new DataSeries();
series.add(new DataSeriesItem(20, yvalue));
series.add(new DataSeriesItem(40, yvalue.intValue() + 10));
series.add(new DataSeriesItem(60, yvalue.intValue() - 15));
series.add(new DataSeriesItem(80, yvalue));
series.setId("" + id);
series.setName("Test Series " + id);
++id;
return series;
}
use of com.vaadin.addon.charts.model.DataSeries 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.DataSeries in project charts by vaadin.
the class LibraryData method getChart.
@Override
protected Component getChart() {
chart = new Chart(ChartType.BAR);
chart.setSizeFull();
Configuration config = chart.getConfiguration();
boolean inverted = config.getChart().getInverted();
config.getChart().setInverted(!inverted);
config.getLegend().setEnabled(false);
YAxis axis = new YAxis();
axis.setTitle("Pages");
config.addyAxis(axis);
series = new DataSeries();
config.setSeries(series);
updateChart();
return chart;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class BubbleChartMaxSizePercentage method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BUBBLE);
Configuration conf = chart.getConfiguration();
conf.setTitle((String) null);
DataSeries dataSeries = new DataSeries();
dataSeries.add(item(9, 81, 13));
dataSeries.add(item(98, 5, 39));
dataSeries.add(item(51, 50, 23));
dataSeries.add(item(41, 22, -36));
dataSeries.add(item(58, 24, -30));
dataSeries.add(item(78, 37, -16));
dataSeries.add(item(55, 56, 3));
dataSeries.add(item(18, 45, 20));
dataSeries.add(item(42, 44, -22));
dataSeries.add(item(3, 52, 9));
dataSeries.add(item(31, 50, 47));
dataSeries.add(item(79, 91, 13));
dataSeries.add(item(93, 23, -27));
dataSeries.add(item(44, 83, -28));
PlotOptionsBubble opts = new PlotOptionsBubble();
opts.setNegativeColor(getThemeColors()[3]);
opts.setMaxSize(50, Unit.PERCENTAGE);
opts.setMinSize("3");
conf.setPlotOptions(opts);
conf.addSeries(dataSeries);
return chart;
}
Aggregations