use of com.vaadin.flow.component.charts.Chart in project flow-components by vaadin.
the class ColumnWithNativeLazyDrilldownMultipleSeries method initDemo.
@Override
public void initDemo() {
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));
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<>();
addDrillSeries(1);
addDrillSeries(2);
chart.setDrilldownCallback(event -> getPointDrilldown(event.getItem()));
add(chart);
}
use of com.vaadin.flow.component.charts.Chart in project flow-components by vaadin.
the class Timeline method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.TIMELINE);
Configuration conf = chart.getConfiguration();
conf.getxAxis().setVisible(false);
conf.getyAxis().setVisible(false);
conf.setTitle("Timeline of Space Exploration");
conf.setSubTitle("Info source: <a href=\"https://en.wikipedia.org/wiki/Timeline_of_space_exploration\">www.wikipedia.org</a>");
conf.getTooltip().setEnabled(true);
DataSeries series = new DataSeries();
series.add(new DataSeriesItemTimeline("First dogs", "1951: First dogs in space", "22 July 1951 First dogs in space (Dezik and Tsygan)"));
series.add(new DataSeriesItemTimeline("Sputnik 1", "1957: First artificial satellite", "4 October 1957 First artificial satellite. First signals from space."));
series.add(new DataSeriesItemTimeline("First human spaceflight", "1961: First human spaceflight (Yuri Gagarin)", "First human spaceflight (Yuri Gagarin), and the first human-crewed orbital flight"));
series.add(new DataSeriesItemTimeline("First human on the Moon", "1969: First human on the Moon", "First human on the Moon, and first space launch from a celestial body other than the Earth. First sample return from the Moon"));
conf.addSeries(series);
add(chart);
}
use of com.vaadin.flow.component.charts.Chart in project flow-components by vaadin.
the class Treemap method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.TREEMAP);
Configuration conf = chart.getConfiguration();
conf.getTooltip().setEnabled(true);
PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.STRIPES);
plotOptions.setAlternateStartingDirection(true);
Level level1 = new Level();
level1.setLevel(1);
level1.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SLICEANDDICE);
DataLabels dataLabels = new DataLabels();
dataLabels.setEnabled(true);
dataLabels.setAlign(HorizontalAlign.LEFT);
dataLabels.setVerticalAlign(VerticalAlign.TOP);
level1.setDataLabels(dataLabels);
plotOptions.setLevels(level1);
TreeSeries series = createSeries();
series.setPlotOptions(plotOptions);
chart.getConfiguration().addSeries(series);
chart.getConfiguration().setTitle("Fruit consumption");
add(chart);
}
use of com.vaadin.flow.component.charts.Chart in project flow-components by vaadin.
the class WindRose method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.setTitle("Wind rose for South Shore Met Station, Oregon");
conf.setSubTitle("Source: or.water.usgs.gov");
XAxis xAxis = conf.getxAxis();
xAxis.setCategories("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
YAxis yAxis = conf.getyAxis();
yAxis.setReversedStacks(false);
yAxis.setTitle("Frequency (%)");
yAxis.setMin(0);
yAxis.setEndOnTick(false);
yAxis.setShowLastLabel(true);
yAxis.getLabels().setFormatter("function() { return this.value + '%';}");
conf.getTooltip().setValueSuffix("%");
conf.getPane().setSize("85%");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setStacking(Stacking.NORMAL);
plotOptionsColumn.setGroupPadding(0);
plotOptionsColumn.setPointPlacement(PointPlacement.ON);
conf.setPlotOptions(plotOptionsColumn);
Legend legend = conf.getLegend();
legend.setAlign(HorizontalAlign.RIGHT);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setY(100);
legend.setLayout(LayoutDirection.VERTICAL);
DataSeries series = new DataSeries();
series.setName("< 0.5 m/s");
series.setData(1.81, 0.62, 0.82, 0.59, 0.62, 1.22, 1.61, 2.04, 2.66, 2.96, 2.53, 1.97, 1.64, 1.32, 1.58, 1.51);
conf.addSeries(series);
series = new DataSeries();
series.setName("0.5-2 m/s");
series.setData(1.78, 1.09, 0.82, 1.22, 2.2, 2.01, 3.06, 3.42, 4.74, 4.14, 4.01, 2.66, 1.71, 2.4, 4.28, 5);
conf.addSeries(series);
series = new DataSeries();
series.setName("2-4 m/s");
series.setData(0.16, 0, 0.07, 0.07, 0.49, 1.55, 2.37, 1.97, 0.43, 0.26, 1.22, 1.97, 0.92, 0.99, 1.28, 1.32);
conf.addSeries(series);
series = new DataSeries();
series.setName("4-6 m/s");
series.setData(0, 0, 0, 0, 0, 0.3, 2.14, 0.86, 0, 0, 0.49, 0.79, 1.45, 1.61, 0.76, 0.13);
conf.addSeries(series);
series = new DataSeries();
series.setName("6-8 m/s");
series.setData(0, 0, 0, 0, 0, 0.13, 1.74, 0.53, 0, 0, 0.13, 0.3, 0.26, 0.33, 0.66, 0.23);
conf.addSeries(series);
series = new DataSeries();
series.setName("8-10 m/s");
series.setData(0, 0, 0, 0, 0, 0, 0.39, 0.49, 0, 0, 0, 0, 0.1, 0, 0.69, 0.13);
conf.addSeries(series);
series = new DataSeries();
series.setName("> 10 m/s");
series.setData(0, 0, 0, 0, 0, 0, 0.13, 0, 0, 0, 0, 0, 0, 0, 0.03, 0.07);
conf.addSeries(series);
add(chart);
}
use of com.vaadin.flow.component.charts.Chart in project flow-components by vaadin.
the class ColumnRange method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.COLUMNRANGE);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Temperature variation by day");
DataSeries dataSeries = new DataSeries("Temperatures");
for (StockPrices.RangeData data : StockPrices.fetchDailyTempRanges()) {
dataSeries.add(new DataSeriesItem(data.getDate(), data.getMin(), data.getMax()));
}
configuration.setSeries(dataSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(2);
configuration.setRangeSelector(rangeSelector);
chart.setTimeline(true);
add(chart);
}
Aggregations