use of com.vaadin.addon.charts.model.DataSeriesItem 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.DataSeriesItem 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.DataSeriesItem in project charts by vaadin.
the class ChartPluginExamples method createHeatMap.
public static Chart createHeatMap() {
final Chart chart = new Chart(CustomChartTypes.MAP);
chart.setWidth("800px");
chart.setHeight("500px");
final Configuration configuration = chart.getConfiguration();
ChartModel model = new ChartModel();
configuration.setChart(model);
model.setType(CustomChartTypes.MAP);
model.setBorderWidth(1);
model.setZoomType(ZoomType.XY);
model.setInverted(false);
configuration.getTitle().setText("Vaadin Charts Test for complex highcharts plugin");
XAxis xAxis = configuration.getxAxis();
xAxis.setEndOnTick(false);
xAxis.setGridLineWidth(0);
xAxis.getLabels().setEnabled(false);
xAxis.setLineWidth(0);
xAxis.setMinPadding(0);
xAxis.setMaxPadding(0);
xAxis.setStartOnTick(false);
xAxis.setTickWidth(0);
YAxis yAxis = configuration.getyAxis();
yAxis.setEndOnTick(false);
yAxis.setGridLineWidth(0);
yAxis.getLabels().setEnabled(false);
yAxis.setLineWidth(0);
yAxis.setMinPadding(0);
yAxis.setMaxPadding(0);
yAxis.setStartOnTick(false);
yAxis.setTickWidth(0);
yAxis.setTitle("");
yAxis.setReversed(true);
Legend legend = configuration.getLegend();
legend.setHorizontalAlign(HorizontalAlign.LEFT);
legend.setVerticalAlign(VerticalAlign.BOTTOM);
legend.setFloating(true);
legend.setLayout(LayoutDirection.VERTICAL);
configuration.setExporting(false);
MapSeries series = new MapSeries();
series.addValueRange(new ValueRange(null, 3, new SolidColor(19, 64, 117, 0.05)));
series.addValueRange(new ValueRange(3, 10, new SolidColor(19, 64, 117, 0.2)));
series.addValueRange(new ValueRange(10, 30, new SolidColor(19, 64, 117, 0.4)));
series.addValueRange(new ValueRange(30, 100, new SolidColor(19, 64, 117, 0.5)));
series.addValueRange(new ValueRange(100, 300, new SolidColor(19, 64, 117, 0.6)));
series.addValueRange(new ValueRange(300, 1000, new SolidColor(19, 64, 117, 0.8)));
series.addValueRange(new ValueRange(1000, null, new SolidColor(19, 64, 117, 1)));
Random random = new Random();
for (String c : Locale.getISOCountries()) {
DataSeriesItem p = new DataSeriesItem(c.toLowerCase(), random.nextInt(1200));
series.add(p);
}
configuration.addSeries(series);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.DataSeriesItem 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.DataSeriesItem 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