use of com.vaadin.addon.charts.model.DataSeriesItem 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.DataSeriesItem 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.DataSeriesItem 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.DataSeriesItem 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;
}
use of com.vaadin.addon.charts.model.DataSeriesItem 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;
}
Aggregations