use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class Spline method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.SPLINE);
chart.setTimeline(true);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("AAPL Stock Price");
configuration.getTooltip().setEnabled(true);
DataSeries dataSeries = new DataSeries();
for (StockPrices.PriceData data : StockPrices.fetchAaplPrice()) {
DataSeriesItem item = new DataSeriesItem();
item.setX(data.getDate());
item.setY(data.getPrice());
dataSeries.add(item);
}
configuration.addSeries(dataSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(1);
configuration.setRangeSelector(rangeSelector);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SVGGeneratorTest method createAreaChartConfiguration.
private Configuration createAreaChartConfiguration() {
Configuration configuration = new Configuration();
configuration.setTitle("First Chart for Flow");
configuration.getChart().setType(ChartType.AREA);
Tooltip tooltip = configuration.getTooltip();
tooltip.setEnabled(true);
tooltip.setShared(true);
PlotOptionsSeries options = new PlotOptionsSeries();
options.setPointStart(0);
options.setPointIntervalUnit(IntervalUnit.DAY);
configuration.setPlotOptions(options);
configuration.addSeries(new ListSeries("Tokyo", 20, 12, 34, 23, 65, 8, 4, 7, 76, 19, 20, 8));
configuration.addSeries(new ListSeries("Miami", 34, 29, 23, 65, 8, 4, 7, 7, 59, 8, 9, 19));
XAxis x = new XAxis();
x.setType(AxisType.DATETIME);
x.getLabels().setFormat("{value:%a}");
configuration.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
configuration.addyAxis(y);
return configuration;
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SVGGeneratorTest method exportWithCustomLang.
@Test
public void exportWithCustomLang() throws IOException, InterruptedException {
Configuration conf = createAreaChartConfiguration();
ExportOptions options = new ExportOptions();
Lang lang = createLang();
options.setLang(lang);
String svg = svgGenerator.generate(conf, options);
Path pieChartPath = Paths.get("src", "test", "resources", "custom-lang.svg");
String expectedSVG = readUtf8File(pieChartPath);
assertEquals(replaceIds(expectedSVG), replaceIds(svg));
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SVGGeneratorTest method createPieChartConfiguration.
private Configuration createPieChartConfiguration() {
Configuration conf = new Configuration();
conf.setTitle("Browser market shares in January, 2018");
conf.getChart().setType(ChartType.PIE);
Tooltip tooltip = new Tooltip();
tooltip.setValueDecimals(1);
conf.setTooltip(tooltip);
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setAllowPointSelect(true);
plotOptions.setCursor(Cursor.POINTER);
plotOptions.setShowInLegend(true);
conf.setPlotOptions(plotOptions);
DataSeries series = new DataSeries();
DataSeriesItem chrome = new DataSeriesItem("Chrome", 61.41);
chrome.setSliced(true);
chrome.setSelected(true);
series.add(chrome);
series.add(new DataSeriesItem("Internet Explorer", 11.84));
series.add(new DataSeriesItem("Firefox", 10.85));
series.add(new DataSeriesItem("Edge", 4.67));
series.add(new DataSeriesItem("Safari", 4.18));
series.add(new DataSeriesItem("Sogou Explorer", 1.64));
series.add(new DataSeriesItem("Opera", 6.2));
series.add(new DataSeriesItem("QQ", 1.2));
series.add(new DataSeriesItem("Others", 2.61));
conf.setSeries(series);
return conf;
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SVGGeneratorTest method generateSVGFromChartWithoutTitle.
@Test
public void generateSVGFromChartWithoutTitle() throws IOException, InterruptedException {
Configuration conf = createColumnWithoutTitle();
String svg = svgGenerator.generate(conf);
Path pieChartPath = Paths.get("src", "test", "resources", "column-without-title.svg");
String expectedSVG = readUtf8File(pieChartPath);
assertEquals(replaceIds(expectedSVG), replaceIds(svg));
}
Aggregations