use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class ChartWithExternalDataProviderWithChangingData method createChart.
public static Chart createChart(Series ds) {
final Chart chart = new Chart(ChartType.AREA);
final Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Data from Vaadin DataProvider");
configuration.getLegend().setEnabled(false);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Data values"));
yAxis.setMin(0.6);
yAxis.setStartOnTick(false);
yAxis.setShowFirstLabel(false);
configuration.getTooltip().setShared(true);
PlotOptionsArea plotOptions = new PlotOptionsArea();
GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
fillColor.addColorStop(0, new SolidColor("#4572A7"));
fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
plotOptions.setFillColor(fillColor);
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Marker marker = plotOptions.getMarker();
marker.setEnabled(false);
Hover hoverState = new Hover(true);
hoverState.setRadius(5);
hoverState.setLineWidth(1);
marker.getStates().setHover(hoverState);
plotOptions.getStates().setHover(new Hover(true));
plotOptions.setShadow(false);
configuration.setPlotOptions(plotOptions);
configuration.setSeries(ds);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class StackedAndGroupedColumn method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Total fruit consumption, grouped by gender"));
XAxis xAxis = new XAxis();
xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setAllowDecimals(false);
yAxis.setMin(0);
yAxis.setTitle(new AxisTitle("Number of fruits"));
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("function() { return '<b>'+ this.x +'</b><br/>'" + "+this.series.name +': '+ this.y +'<br/>'+'Total: '+ this.point.stackTotal; }");
conf.setTooltip(tooltip);
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
plotOptions.setStacking(Stacking.NORMAL);
conf.setPlotOptions(plotOptions);
ListSeries serie = new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 });
serie.setStack("male");
conf.addSeries(serie);
serie = new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 });
serie.setStack("male");
conf.addSeries(serie);
serie = new ListSeries("Jane", new Number[] { 2, 5, 6, 2, 1 });
serie.setStack("female");
conf.addSeries(serie);
serie = new ListSeries("Janet", new Number[] { 3, 0, 4, 4, 3 });
serie.setStack("female");
conf.addSeries(serie);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class ContainerWithLotsOfData method createChart.
public static Chart createChart(Series container) {
final Chart chart = new Chart();
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.AREA);
configuration.getTitle().setText("Data from Vaadin Container");
configuration.getLegend().setEnabled(false);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Exchange rate"));
yAxis.setMin(0.6);
yAxis.setStartOnTick(false);
yAxis.setShowFirstLabel(false);
configuration.getTooltip().setShared(true);
PlotOptionsArea plotOptions = new PlotOptionsArea();
GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
fillColor.addColorStop(0, new SolidColor("#4572A7"));
fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
plotOptions.setFillColor(fillColor);
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Marker marker = plotOptions.getMarker();
marker.setEnabled(false);
Hover hoverState = new Hover(true);
hoverState.setRadius(5);
hoverState.setLineWidth(1);
marker.getStates().setHover(hoverState);
plotOptions.getStates().setHover(new Hover(true));
plotOptions.setShadow(false);
configuration.setPlotOptions(plotOptions);
configuration.setSeries(container);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class PercentageArea method createNewChart.
public static Chart createNewChart() {
Chart chart = new Chart(ChartType.AREA);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Historic and Estimated Worldwide Population Distribution by Region"));
conf.setSubTitle(new Subtitle("Source: Wikipedia.org"));
XAxis xAxis = new XAxis();
xAxis.setTickmarkPlacement(TickmarkPlacement.ON);
xAxis.setCategories("1750", "1800", "1850", "1900", "1950", "1999", "2050");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle(new AxisTitle("Percent"));
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name + ': ' +this.x +': '+ Highcharts.numberFormat(this.percentage, 1) +'% ('+ Highcharts.numberFormat(this.y, 0, ',') +' millions)'");
conf.setTooltip(tooltip);
PlotOptionsArea plotOptions = new PlotOptionsArea();
plotOptions.setStacking(Stacking.PERCENT);
plotOptions.setLineWidth(1);
Marker marker = new Marker();
plotOptions.setMarker(marker);
conf.setPlotOptions(plotOptions);
conf.addSeries(new ListSeries("Asia", 502, 635, 809, 947, 1402, 3634, 5268));
conf.addSeries(new ListSeries("Africa", 106, 107, 111, 133, 221, 767, 1766));
conf.addSeries(new ListSeries("Europe", 163, 203, 276, 408, 547, 729, 628));
conf.addSeries(new ListSeries("America", 18, 31, 54, 156, 339, 818, 1201));
conf.addSeries(new ListSeries("Ocenia", 2, 2, 2, 6, 13, 30, 46));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle 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