use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicLineWithAutoRotation method getChart.
@Override
protected Component getChart() {
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(false);
layout.setMargin(false);
final Chart chart = new Chart(ChartType.LINE);
chart.setHeight("400px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Monthly Average Temperature");
configuration.getSubTitle().setText("Source: WorldClimate.com");
configuration.getxAxis().setCategories("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
XAxis xAxis = configuration.getxAxis();
xAxis.getLabels().setAutoRotation(new Number[] { -10, -20, -30, -40, 50, -60, -70, -80, -90 });
ListSeries ls = new ListSeries();
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);
configuration.addSeries(ls);
ls = new ListSeries();
ls.setName("New York");
ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
configuration.addSeries(ls);
layout.addComponent(chart);
final Slider slider = new Slider("Width (50 - 100)", 50, 100);
slider.setWidth("200px");
slider.setValue(100d);
layout.addComponent(slider);
layout.addComponent(new Button("Set min width", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
slider.setValue(50d);
}
}));
slider.addValueChangeListener(event -> {
double newValue = slider.getValue();
chart.setWidth((float) newValue, Unit.PERCENTAGE);
});
return layout;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicLineWithDataLabels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.LINE);
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 (°C)"));
configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setDataLabels(new DataLabels(true));
plotOptions.setEnableMouseTracking(false);
configuration.setPlotOptions(plotOptions);
ListSeries ls = new ListSeries();
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);
configuration.addSeries(ls);
ls = new ListSeries();
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);
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class Migration method exampleResult.
public Chart exampleResult() {
Chart chart = new Chart();
Configuration config = chart.getConfiguration();
config.setTitle("Charts migration");
config.getTitle().setAlign(HorizontalAlign.LEFT);
Crosshair xCrossHair = new Crosshair();
xCrossHair.setColor(SolidColor.BLACK);
xCrossHair.setDashStyle(DashStyle.SOLID);
xCrossHair.setWidth(10);
xCrossHair.setZIndex(0);
config.getxAxis().setCrosshair(xCrossHair);
Crosshair yCrossHair = new Crosshair();
yCrossHair.setColor(new SolidColor("#880000"));
yCrossHair.setDashStyle(DashStyle.DOT);
yCrossHair.setWidth(5);
yCrossHair.setZIndex(1);
config.getyAxis().setCrosshair(yCrossHair);
config.getLegend().setEnabled(false);
config.getTooltip().setEnabled(false);
ListSeries ls = new ListSeries();
ls.setName("Data");
ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
PlotOptionsAreaspline plotOptions = new PlotOptionsAreaspline();
plotOptions.setColor(SolidColor.BURLYWOOD);
plotOptions.setDataLabels(new DataLabels(false));
ls.setPlotOptions(plotOptions);
config.setSeries(ls);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class ChartConfiguration method plotOptionsSnippet2.
public void plotOptionsSnippet2(Configuration conf) {
ListSeries series = new ListSeries(50, 60, 70, 80);
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
plotOptions.setStacking(Stacking.NORMAL);
series.setPlotOptions(plotOptions);
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicUse method basicUseDataSnippet1.
public void basicUseDataSnippet1() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
ListSeries series = new ListSeries("Diameter");
series.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
conf.addSeries(series);
}
Aggregations