use of com.vaadin.addon.charts.Chart in project charts by vaadin.
the class ColumnWithNativeLazyDrilldown method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
conf = chart.getConfiguration();
conf.setTitle("Browser market share, April, 2011");
conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
conf.getLegend().setEnabled(false);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total percent market share");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
column.getDataLabels().setFormatter("this.y +'%'");
conf.setPlotOptions(column);
Tooltip tooltip = new Tooltip();
tooltip.setHeaderFormat("<span style=\"font-size:11px\">{series.name}</span><br>");
tooltip.setPointFormat("<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>");
conf.setTooltip(tooltip);
DataSeries series = new DataSeries();
series.setName("Browser brands");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setColorByPoint(true);
series.setPlotOptions(plotOptionsColumn);
DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
item.setId("MSIE");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Firefox", 21.63);
item.setId("Firefox");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Chrome", 11.94);
item.setId("Chrome");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Safari", 7.15);
item.setId("Safari");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Opera", 2.14);
item.setId("Opera");
series.addItemWithDrilldown(item);
conf.addSeries(series);
drillSeries = new HashMap<String, DataSeries>();
DataSeries drill = new DataSeries("MSIE versions");
String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
drill.setData(categories, ys);
drillSeries.put("MSIE", drill);
drill = new DataSeries("Firefox versions");
categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
drill.setData(categories, ys);
drillSeries.put("Firefox", drill);
drill = new DataSeries("Chrome versions");
categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
drill.setData(categories, ys);
drillSeries.put("Chrome", drill);
drill = new DataSeries("Safari versions");
categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
drill.setData(categories, ys);
drillSeries.put("Safari", drill);
drill = new DataSeries("Opera versions");
categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
ys = new Number[] { 0.12, 0.37, 1.65 };
drill.setData(categories, ys);
drillSeries.put("Opera", drill);
chart.setDrilldownCallback(new DrilldownCallback() {
@Override
public Series handleDrilldown(DrilldownEvent event) {
return getPointDrilldown(event.getItem());
}
});
return chart;
}
use of com.vaadin.addon.charts.Chart in project charts by vaadin.
the class ColumnWithNativeLazyDrilldownByIndex method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
conf = chart.getConfiguration();
conf.setTitle("Browser market share, April, 2011");
conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
conf.getLegend().setEnabled(false);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total percent market share");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
column.getDataLabels().setFormatter("this.y +'%'");
conf.setPlotOptions(column);
Tooltip tooltip = new Tooltip();
tooltip.setEnabled(false);
conf.setTooltip(tooltip);
topCategories = new String[] { "MSIE", "Firefox", "Chrome", "Safari", "Opera" };
DataSeries series = new DataSeries();
series.setName("Browser brands");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setColorByPoint(true);
series.setPlotOptions(plotOptionsColumn);
DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Firefox", 21.63);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Chrome", 11.94);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Safari", 7.15);
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Opera", 2.14);
series.addItemWithDrilldown(item);
conf.addSeries(series);
drillSeries = new HashMap<String, DataSeries>();
DataSeries drill = new DataSeries("MSIE versions");
String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
drill.setData(categories, ys);
drillSeries.put("MSIE", drill);
drill = new DataSeries("Firefox versions");
categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
drill.setData(categories, ys);
drillSeries.put("Firefox", drill);
drill = new DataSeries("Chrome versions");
categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
drill.setData(categories, ys);
drillSeries.put("Chrome", drill);
drill = new DataSeries("Safari versions");
categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
drill.setData(categories, ys);
drillSeries.put("Safari", drill);
drill = new DataSeries("Opera versions");
categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
ys = new Number[] { 0.12, 0.37, 1.65 };
drill.setData(categories, ys);
drillSeries.put("Opera", drill);
chart.setDrilldownCallback(new DrilldownCallback() {
@Override
public Series handleDrilldown(DrilldownEvent event) {
return getPointDrilldown(event.getItemIndex());
}
});
return chart;
}
use of com.vaadin.addon.charts.Chart in project charts by vaadin.
the class ColumnWithNativeLazyDrilldownMultipleSeries method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
conf = chart.getConfiguration();
conf.setTitle("Browser market share, April, 2011");
conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
conf.getLegend().setEnabled(false);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total percent market share");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
column.getDataLabels().setFormatter("this.y +'%'");
conf.setPlotOptions(column);
Tooltip tooltip = new Tooltip();
tooltip.setHeaderFormat("<span style=\"font-size:11px\">{series.name}</span><br>");
tooltip.setPointFormat("<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>");
conf.setTooltip(tooltip);
createSeries(1);
createSeries(2);
drillSeries = new HashMap<String, DataSeries>();
addDrillSeries(1);
addDrillSeries(2);
chart.setDrilldownCallback(new DrilldownCallback() {
@Override
public Series handleDrilldown(DrilldownEvent event) {
return getPointDrilldown(event.getItem());
}
});
return chart;
}
use of com.vaadin.addon.charts.Chart in project charts by vaadin.
the class ColumnWithNegativeValues method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Column chart with negative values"));
PlotOptionsColumn column = new PlotOptionsColumn();
column.setMinPointLength(3);
conf.setPlotOptions(column);
XAxis xAxis = new XAxis();
xAxis.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
conf.addxAxis(xAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("function() { return ''+ this.series.name +': '+ this.y +'';}");
conf.setTooltip(tooltip);
conf.setCredits(new Credits(false));
conf.addSeries(new ListSeries("John", 5, 0.1, 4, 7, 2));
conf.addSeries(new ListSeries("Jane", 2, -2, -0.1, 2, 1));
conf.addSeries(new ListSeries("Joe", 3, 4, 4, -2, 5));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.Chart in project charts by vaadin.
the class BasicBarNoTitle method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BAR);
Configuration conf = chart.getConfiguration();
conf.getTitle().setText(null);
XAxis x = new XAxis();
x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
x.setTitle((String) null);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
AxisTitle title = new AxisTitle("Population (millions)");
title.setAlign(VerticalAlign.MIDDLE);
y.setTitle(title);
conf.addyAxis(y);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name +': '+ this.y +' millions'");
conf.setTooltip(tooltip);
PlotOptionsBar plot = new PlotOptionsBar();
plot.setDataLabels(new DataLabels(true));
conf.setPlotOptions(plot);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.RIGHT);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(-100);
legend.setY(100);
legend.setFloating(true);
legend.setBorderWidth(1);
legend.setBackgroundColor(new SolidColor("#FFFFFF"));
legend.setShadow(true);
conf.setLegend(legend);
conf.disableCredits();
List<Series> series = new ArrayList<Series>();
series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
conf.setSeries(series);
chart.drawChart(conf);
return chart;
}
Aggregations