use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class PieWithCustomBorder method getBrowserMarketShareSeries.
private DataSeries getBrowserMarketShareSeries() {
DataSeriesItem firefox = new DataSeriesItem("Firefox", 45.0);
firefox.setColor(createRadialGradient(new SolidColor(255, 128, 0), new SolidColor(128, 64, 0)));
DataSeriesItem ie = new DataSeriesItem("IE", 26.8);
ie.setColor(createRadialGradient(new SolidColor(0, 255, 255), new SolidColor(0, 128, 128)));
DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
chrome.setColor(createRadialGradient(new SolidColor(255, 255, 0), new SolidColor(128, 128, 0)));
chrome.setSliced(true);
chrome.setSelected(true);
DataSeriesItem safari = new DataSeriesItem("Safari", 8.5);
safari.setColor(createRadialGradient(new SolidColor(0, 128, 255), new SolidColor(0, 64, 128)));
DataSeriesItem opera = new DataSeriesItem("Opera", 6.2);
opera.setColor(createRadialGradient(new SolidColor(255, 0, 0), new SolidColor(128, 0, 0)));
DataSeriesItem others = new DataSeriesItem("Others", 0.7);
others.setColor(createRadialGradient(new SolidColor(0, 128, 0), new SolidColor(0, 64, 0)));
return new DataSeries(firefox, ie, chrome, safari, opera, others);
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class Basic3DPie method createChart.
public static Chart createChart() {
Chart chart = new Chart(ChartType.PIE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Browser market shares at a specific website, 2010");
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setCursor(Cursor.POINTER);
DataLabels dataLabels = new DataLabels(true);
dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
plotOptions.setDataLabels(dataLabels);
plotOptions.setDepth(45);
conf.setPlotOptions(plotOptions);
final 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);
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(60);
conf.getChart().setOptions3d(options3d);
chart.addPointClickListener(new PointClickListener() {
@Override
public void onClick(PointClickEvent event) {
Notification.show("Click: " + series.get(event.getPointIndex()).getName());
}
});
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class SerializationTest method serializeChart_configurationWithDrilldown_drilldownConfigurationLinkSerializedCorrectly.
@Test
public void serializeChart_configurationWithDrilldown_drilldownConfigurationLinkSerializedCorrectly() throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
Chart input = new Chart();
DataSeries dataSeries = new DataSeries();
ListSeries drilldownSeries = new ListSeries();
drilldownSeries.setId("id");
dataSeries.addItemWithDrilldown(new DataSeriesItem("foobar", 42), drilldownSeries);
input.getConfiguration().addSeries(dataSeries);
Chart output = serializeObject(input);
Drilldown outputDrilldown = output.getConfiguration().getDrilldown();
assertNotNull("Drilldown configuration link was null after serialization", outputDrilldown.getConfiguration());
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class SplineWithSymbols method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Monthly Average Temperature");
configuration.getSubTitle().setText("Source: WorldClimate.com");
configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Temperature"));
Labels labels = new Labels();
labels.setFormatter("this.value +'°'");
yAxis.setLabels(labels);
configuration.getTooltip().setShared(true);
configuration.getxAxis().setCrosshair(new Crosshair());
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
configuration.setPlotOptions(plotOptions);
plotOptions.setMarker(new Marker(true));
plotOptions.getMarker().setRadius(4);
plotOptions.getMarker().setLineColor(new SolidColor("#666666"));
plotOptions.getMarker().setLineWidth(1);
DataSeries ls = new DataSeries();
plotOptions = new PlotOptionsSpline();
Marker marker = new Marker();
marker.setSymbol(MarkerSymbolEnum.SQUARE);
plotOptions.setMarker(marker);
ls.setPlotOptions(plotOptions);
ls.setName("Tokyo");
ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
ls.get("26.5").getMarker().setSymbol(new MarkerSymbolUrl("http://www.highcharts.com/demo/gfx/sun.png"));
configuration.addSeries(ls);
ls = new DataSeries();
plotOptions = new PlotOptionsSpline();
marker = new Marker();
marker.setSymbol(MarkerSymbolEnum.DIAMOND);
plotOptions.setMarker(marker);
ls.setPlotOptions(plotOptions);
ls.setName("London");
ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
ls.get("3.9").getMarker().setSymbol(new MarkerSymbolUrl("http://www.highcharts.com/demo/gfx/snow.png"));
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.DataSeries in project charts by vaadin.
the class TimeDataWithIrregularIntervals method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Snow depth in the Vikjafjellet mountain, Norway");
configuration.getSubTitle().setText("An example of irregular time data in Highcharts JS");
configuration.getTooltip().setFormatter("");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setDateTimeLabelFormats(new DateTimeLabelFormats("%e. %b", "%b"));
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Snow depth (m)"));
yAxis.setMin(0);
configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>\'+ Highcharts.dateFormat('%e. %b', this.x) +': '+ this.y +' m'");
DataSeries ls = new DataSeries();
ls.setPlotOptions(new PlotOptionsSpline());
ls.setName("Winter 2007-2008");
Object[][] data1 = getData1();
for (int i = 0; i < data1.length; i++) {
Object[] ds = data1[i];
DataSeriesItem item = new DataSeriesItem((Instant) ds[0], (Double) ds[1]);
ls.add(item);
}
configuration.addSeries(ls);
ls = new DataSeries();
ls.setPlotOptions(new PlotOptionsSpline());
ls.setName("Winter 2008-2009");
Object[][] data2 = getData2();
for (int i = 0; i < data2.length; i++) {
Object[] ds = data2[i];
DataSeriesItem item = new DataSeriesItem((Instant) ds[0], (Double) ds[1]);
ls.add(item);
}
configuration.addSeries(ls);
ls = new DataSeries();
ls.setPlotOptions(new PlotOptionsSpline());
ls.setName("Winter 2009-2010");
Object[][] data3 = getData3();
for (int i = 0; i < data3.length; i++) {
Object[] ds = data3[i];
DataSeriesItem item = new DataSeriesItem((Instant) ds[0], (Double) ds[1]);
ls.add(item);
}
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
Aggregations