use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SplineUpdatingEachSecond method initDemo.
@Override
public void initDemo() {
// NOSONAR
final Random random = new Random();
final Chart chart = new Chart();
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Live random data");
XAxis xAxis = configuration.getxAxis();
xAxis.setType(AxisType.DATETIME);
xAxis.setTickPixelInterval(150);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Value"));
configuration.getTooltip().setEnabled(false);
configuration.getLegend().setEnabled(false);
final DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsSpline());
series.setName("Random data");
for (int i = -19; i <= 0; i++) {
series.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
configuration.setSeries(series);
runWhileAttached(chart, () -> {
final long x = System.currentTimeMillis();
final double y = random.nextDouble();
series.add(new DataSeriesItem(x, y), true, true);
}, 1000, 1000);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class Bullet method createBulletChart.
/**
* Create a bullet chart with shared configuration
*
* @param plotBandY1
* "from" value for the first plotband
* @param plotBandY2
* "to" value for the first plotband and "from" value for the
* second plotband
* @param plotBandY3
* "to" value for the second plotband and "from" value for the
* third plotband
* @param plotBandY4
* "to" value for the third plotband
* @param y
* Y value for the series item
* @param target
* Target value for the series item
* @param category
* Title to be used in the category
* @return Chart with shared configuration
*/
private Chart createBulletChart(Number plotBandY1, Number plotBandY2, Number plotBandY3, Number plotBandY4, Number y, Number target, String category) {
Chart chart = new Chart(ChartType.BULLET);
chart.setHeight("85px");
Configuration conf = chart.getConfiguration();
conf.getChart().setInverted(true);
conf.getChart().setMarginLeft(135);
conf.getLegend().setEnabled(false);
YAxis yAxis = conf.getyAxis();
yAxis.setGridLineWidth(0);
yAxis.setTitle("");
yAxis.addPlotBand(new PlotBand(plotBandY1, plotBandY2, new SolidColor("#666666")));
yAxis.addPlotBand(new PlotBand(plotBandY2, plotBandY3, new SolidColor("#999999")));
yAxis.addPlotBand(new PlotBand(plotBandY3, plotBandY4, new SolidColor("#bbbbbb")));
conf.getxAxis().addCategory(category);
conf.getTooltip().setPointFormat("<b>{point.y}</b> (with target at {point.target})");
PlotOptionsBullet options = new PlotOptionsBullet();
options.setPointPadding(0.25);
options.setBorderWidth(0);
options.setColor(SolidColor.BLACK);
options.getTargetOptions().setWidth("200%");
conf.setExporting(false);
DataSeries series = new DataSeries();
series.add(new DataSeriesItemBullet(y, target));
series.setPlotOptions(options);
conf.addSeries(series);
return chart;
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class DynamicChangingChart method getFunnelConfiguration.
private Configuration getFunnelConfiguration() {
DataSeries dataSeries = new DataSeries("Unique users");
dataSeries.add(new DataSeriesItem("Website visits", 15654));
dataSeries.add(new DataSeriesItem("Downloads", 4064));
dataSeries.add(new DataSeriesItem("Requested price list", 1987));
dataSeries.add(new DataSeriesItem("Invoice sent", 976));
dataSeries.add(new DataSeriesItem("Finalized", 846));
Configuration configuration = new Configuration();
configuration.setTitle("Sales funnel");
configuration.getLegend().setEnabled(false);
PlotOptionsFunnel options = new PlotOptionsFunnel();
options.setReversed(false);
options.setNeckWidth("30%");
options.setNeckHeight("30%");
options.setWidth("70%");
DataLabelsFunnel dataLabels = new DataLabelsFunnel();
dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
options.setDataLabels(dataLabels);
dataSeries.setPlotOptions(options);
configuration.addSeries(dataSeries);
return configuration;
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class DynamicChangingChart method getLineConfiguration.
private Configuration getLineConfiguration() {
Configuration configuration = new Configuration();
configuration.setTitle("Solar Employment Growth by Sector, 2010-2016");
configuration.setSubTitle("Source: thesolarfoundation.com");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle("Number of Employees");
Legend legend = configuration.getLegend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setVerticalAlign(VerticalAlign.MIDDLE);
legend.setAlign(HorizontalAlign.RIGHT);
PlotOptionsSeries plotOptionsSeries = new PlotOptionsSeries();
plotOptionsSeries.setPointStart(2010);
configuration.setPlotOptions(plotOptionsSeries);
configuration.addSeries(new ListSeries("Installation", 43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175));
configuration.addSeries(new ListSeries("Manufacturing", 24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434));
configuration.addSeries(new ListSeries("Sales & Distribution", 11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387));
configuration.addSeries(new ListSeries("Project Development", null, null, 7988, 12169, 15112, 22452, 34400, 34227));
configuration.addSeries(new ListSeries("Other", 12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111));
return configuration;
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class FunnelChart method initDemo.
@Override
public void initDemo() {
DataSeries dataSeries = new DataSeries("Unique users");
dataSeries.add(new DataSeriesItem("Website visits", 15654));
dataSeries.add(new DataSeriesItem("Downloads", 4064));
dataSeries.add(new DataSeriesItem("Requested price list", 1987));
dataSeries.add(new DataSeriesItem("Invoice sent", 976));
dataSeries.add(new DataSeriesItem("Finalized", 846));
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.setTitle("Sales funnel");
conf.getLegend().setEnabled(false);
PlotOptionsFunnel options = new PlotOptionsFunnel();
options.setReversed(false);
options.setNeckWidth("30%");
options.setNeckHeight("30%");
options.setWidth("70%");
DataLabelsFunnel dataLabels = new DataLabelsFunnel();
dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
options.setDataLabels(dataLabels);
dataSeries.setPlotOptions(options);
conf.addSeries(dataSeries);
add(chart);
}
Aggregations