use of com.vaadin.flow.component.charts.model.Title in project flow-components by vaadin.
the class AreaSpline method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.AREASPLINE);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Average fruit consumption during one week"));
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.LEFT);
legend.setFloating(true);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(150);
legend.setY(100);
conf.setLegend(legend);
XAxis xAxis = new XAxis();
xAxis.setCategories(new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" });
PlotBand plotBand = new PlotBand(4.5, 6.5, SolidColor.BLUE);
plotBand.setZIndex(1);
xAxis.setPlotBands(plotBand);
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle(new AxisTitle("Fruit units"));
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
// Customize tooltip formatting
tooltip.setShared(true);
tooltip.setValueSuffix(" units");
conf.setTooltip(tooltip);
PlotOptionsArea plotOptions = new PlotOptionsArea();
conf.setPlotOptions(plotOptions);
ListSeries o = new ListSeries("John", 3, 4, 3, 5, 4, 10);
// You can also add values separately
o.addData(12);
conf.addSeries(o);
conf.addSeries(new ListSeries("Jane", 1, 3, 4, 3, 3, 5, 4));
add(chart);
}
use of com.vaadin.flow.component.charts.model.Title in project flow-components by vaadin.
the class ColumnWithNegativeValues method initDemo.
@Override
public void initDemo() {
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));
add(chart);
}
Aggregations