use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicLineWithShadow 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.getChart().setShadow(true);
ListSeries ls = new ListSeries();
ls.setData(1, 2, 3, 4, 5, 6, 7);
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicLineWithTickCount 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();
Labels xLabels = new Labels();
xLabels.setAutoRotation(new Number[] { -10, -20, -30, -40, 50, -60, -70, -80, -90 });
xAxis.setLabels(xLabels);
final YAxis yAxis = configuration.getyAxis();
yAxis.setTickAmount(10);
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("Tick count (2 - 16)", 2, 16);
slider.setWidth("200px");
slider.setValue(10d);
layout.addComponent(slider);
layout.addComponent(new Button("Set max amount", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
slider.setValue(16d);
}
}));
slider.addValueChangeListener(event -> {
double newValue = slider.getValue();
yAxis.setTickAmount(newValue);
chart.drawChart();
});
return layout;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicLineWithTickPositions method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setId("chart");
Configuration config = chart.getConfiguration();
config.setTitle("Customized crosshairs");
config.getxAxis().setTickPositions(new Integer[] { 1, 2, 4, 8, 16 });
config.getxAxis().setGridLineWidth(1);
config.getyAxis().setTickPositions(new Integer[] { 0, 160, 240, 280, 300, 310 });
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);
config.setSeries(ls);
chart.drawChart(config);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class Basic3DColumnWithGradientBackground method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle("Monthly Average Rainfall");
conf.setSubTitle("Source: WorldClimate.com");
XAxis x = new XAxis();
x.setCategories(new String[] { "Jan", "Feb", "Mar", "Apr" });
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
conf.addyAxis(y);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.x +': '+ this.y +' mm'");
conf.setTooltip(tooltip);
PlotOptionsColumn plot = new PlotOptionsColumn();
plot.setPointPadding(0.2);
plot.setBorderWidth(0);
plot.setGroupZPadding(10);
conf.setPlotOptions(plot);
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(5);
options3d.setBeta(30);
options3d.setDepth(100);
options3d.setViewDistance(200);
Frame frame = new Frame();
options3d.setFrame(frame);
frame.setBack(new Back());
GradientColor c = GradientColor.createLinear(0, 0, 1, 0);
c.addColorStop(0, SolidColor.RED);
c.addColorStop(1, SolidColor.AQUAMARINE);
frame.getBack().setColor(c);
frame.getBack().setSize(1);
conf.getChart().setOptions3d(options3d);
conf.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BorderColorTest method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BAR);
chart.setHeight("450px");
chart.setWidth("100%");
chart.getConfiguration().addSeries(new ListSeries(1, 2, 3));
chart.getConfiguration().getChart().setBorderWidth(5);
chart.getConfiguration().getChart().setBorderColor(new SolidColor("green"));
chart.getConfiguration().getChart().setBorderRadius(25);
return chart;
}
Aggregations