use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class SplineUpdatingEachSecondWithTwoLines method getChart.
@Override
protected Component getChart() {
final Random random = new Random();
final Chart chart = new Chart();
chart.setWidth("500px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Live random data");
XAxis xAxis = configuration.getxAxis();
xAxis.setType(AxisType.DATETIME);
xAxis.setTickPixelInterval(150);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Value"));
yAxis.setPlotLines(new PlotLine(0, 1, new SolidColor("#808080")));
configuration.getTooltip().setEnabled(false);
configuration.getLegend().setEnabled(false);
final DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsSpline());
series.setName("Random data");
for (int i = -19; i <= 0; i++) {
series.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
final DataSeries series2 = new DataSeries();
series2.setPlotOptions(new PlotOptionsSpline());
series2.setName("Random data");
for (int i = -19; i <= 0; i++) {
series2.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
runWhileAttached(chart, new Runnable() {
@Override
public void run() {
long x = System.currentTimeMillis();
series.add(new DataSeriesItem(x, random.nextDouble()), true, true);
series2.add(new DataSeriesItem(x, random.nextDouble()), true, true);
}
}, 1000, 1000);
configuration.setSeries(series, series2);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class SplineWithItemLabels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.SPLINE);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Wind speed during two days");
configuration.getSubTitle().setText("October 6th and 7th 2009 at two locations in Vik i Sogn, Norway");
configuration.getxAxis().setType(AxisType.DATETIME);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Wind speed (m/s)"));
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
configuration.setPlotOptions(plotOptions);
plotOptions.setMarker(new Marker(false));
plotOptions.setPointInterval(ONE_HOUR);
plotOptions.setPointStart(toDate("2009,09,06"));
DataSeries ds = new DataSeries();
ds.setName("Hestavollane");
ds.setData(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, 7.7, 7.7, 7.4, 7.0, 7.1, 5.8, 5.9, 7.4, 8.2, 8.5, 9.4, 8.1, 10.9, 10.4, 10.9, 12.4, 12.1, 9.5, 7.5, 7.1, 7.5, 8.1, 6.8, 3.4, 2.1, 1.9, 2.8, 2.9, 1.3, 4.4, 4.2, 3.0, 3.0);
DataSeriesItem item = new DataSeriesItem();
item.setY(4.51);
item.setDataLabels(getDataLabels());
ds.add(item);
configuration.addSeries(ds);
ds = new DataSeries();
ds.setName("Voll");
ds.setData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0, 0.0, 0.4, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6, 1.2, 1.7, 0.7, 2.9, 4.1, 2.6, 3.7, 3.9, 1.7, 2.3, 3.0, 3.3, 4.8, 5.0, 4.8, 5.0, 3.2, 2.0, 0.9, 0.4, 0.3, 0.5, 0.4);
item = new DataSeriesItem();
item.setY(0.27);
item.setDataLabels(getDataLabels());
ds.add(item);
configuration.addSeries(ds);
return chart;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class Migration method abstractclassPlotoptions.
public void abstractclassPlotoptions(PointOptions options) {
DataSeries series = null;
DataSeries series2 = null;
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
PlotOptionsLine plotOptions2 = new PlotOptionsLine();
setCommonProperties(plotOptions);
setCommonProperties(plotOptions);
series.setPlotOptions(plotOptions);
series2.setPlotOptions(plotOptions2);
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class ChartExportDemo method createChartConf.
private static Configuration createChartConf() {
Configuration conf = new Configuration();
conf.getChart().setType(ChartType.PIE);
conf.setTitle("Browser market shares at a specific website, 2010");
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setCursor(Cursor.POINTER);
Labels dataLabels = new Labels();
dataLabels.setEnabled(true);
dataLabels.setColor(new SolidColor(0, 0, 0));
dataLabels.setConnectorColor(new SolidColor(0, 0, 0));
dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
plotOptions.setDataLabels(dataLabels);
conf.setPlotOptions(plotOptions);
DataSeries series = new DataSeries();
series.add(new DataSeriesItem("Firefox", 45.0));
series.add(new DataSeriesItem("IE", 26.8));
DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
chrome.setSliced(true);
chrome.setSelected(true);
series.add(chrome);
series.add(new DataSeriesItem("Safari", 8.5));
series.add(new DataSeriesItem("Opera", 6.2));
series.add(new DataSeriesItem("Others", 0.7));
conf.setSeries(series);
return conf;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class ChartTypes method chartTypesWaterfallDataModel.
public void chartTypesWaterfallDataModel() {
// Define the colors
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
// The data
DataSeries series = new DataSeries();
// The beginning balance
DataSeriesItem start = new DataSeriesItem("Start", 306503);
SolidColor balanceColor = SolidColor.KHAKI;
start.setColor(balanceColor);
series.add(start);
// Deltas
series.add(new DataSeriesItem("Predators", -3330));
series.add(new DataSeriesItem("Slaughter", -103332));
series.add(new DataSeriesItem("Reproduction", +104052));
WaterFallSum end = new WaterFallSum("End");
end.setColor(balanceColor);
// Not intermediate (default)
end.setIntermediate(false);
series.add(end);
conf.addSeries(series);
}
Aggregations