use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class UtcTimeDataAndTooltipDateFormat method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.setTitle("Time and date in tooltip");
configuration.getChart().setType(ChartType.SPLINE);
configuration.getxAxis().setType(AxisType.DATETIME);
// Finnish convention for date formatting
configuration.getTooltip().setXDateFormat("%d.%m. %Y %H:%M");
// This test uses UTC time stamps, this way chart is independent about
// execution environment, unlike when using Date
TimeZone timeZone = TimeZone.getTimeZone("GMT");
Calendar c = Calendar.getInstance(timeZone);
c.set(Calendar.MILLISECOND, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.HOUR_OF_DAY, 12);
c.set(2013, 2, 11);
DataSeries dataSeries = new DataSeries();
Number[] values = new Number[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 };
Random r = new Random(0);
for (Number number : values) {
c.add(Calendar.MINUTE, r.nextInt(30));
DataSeriesItem item = new DataSeriesItem(c.getTimeInMillis(), number);
dataSeries.add(item);
}
configuration.addSeries(dataSeries);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class ChartTypes method chartTypesPieDataSnippet2.
public void chartTypesPieDataSnippet2() {
DataSeriesItem earth = new DataSeriesItem("Earth", 12800);
earth.setSliced(true);
DataSeries series = new DataSeries();
series.add(earth);
}
use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class ChartTypes method chartTypesPolygon.
public void chartTypesPolygon() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.setTitle("Height vs Weight");
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 optionsScatter = new PlotOptionsScatter();
DataSeries scatter = new DataSeries();
scatter.setPlotOptions(optionsScatter);
scatter.setName("Observations");
scatter.add(new DataSeriesItem(160, 67));
scatter.add(new DataSeriesItem(180, 75));
conf.addSeries(scatter);
DataSeries polygon = new DataSeries();
PlotOptionsPolygon optionsPolygon = new PlotOptionsPolygon();
optionsPolygon.setEnableMouseTracking(false);
polygon.setPlotOptions(optionsPolygon);
polygon.setName("Target");
polygon.add(new DataSeriesItem(153, 42));
polygon.add(new DataSeriesItem(149, 46));
polygon.add(new DataSeriesItem(173, 52));
polygon.add(new DataSeriesItem(166, 45));
conf.addSeries(polygon);
}
use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class ChartTypes method chartTypesScatterSnippet1.
public void chartTypesScatterSnippet1() {
Chart chart = new Chart(ChartType.SCATTER);
chart.setWidth("500px");
chart.setHeight("500px");
// Modify the default configuration a bit
Configuration conf = chart.getConfiguration();
conf.setTitle("Random Sphere");
// Disable legend
conf.getLegend().setEnabled(false);
PlotOptionsScatter options = new PlotOptionsScatter();
// ... Give overall plot options here ...
conf.setPlotOptions(options);
DataSeries series = new DataSeries();
for (int i = 0; i < 300; i++) {
double lng = Math.random() * 2 * Math.PI;
double lat = Math.random() * Math.PI - Math.PI / 2;
double x = Math.cos(lat) * Math.sin(lng);
double y = Math.sin(lat);
double z = Math.cos(lng) * Math.cos(lat);
DataSeriesItem point = new DataSeriesItem(x, y);
Marker marker = new Marker();
// Make settings as described later
point.setMarker(marker);
series.add(point);
}
conf.addSeries(series);
}
use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.
the class ChartTypes method chartTypesPieDataSnippet1.
public void chartTypesPieDataSnippet1() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
DataSeries series = new DataSeries();
series.add(new DataSeriesItem("Mercury", 4900));
series.add(new DataSeriesItem("Venus", 12100));
conf.addSeries(series);
}
Aggregations