use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class AreaSplineRange method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.AREASPLINERANGE);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Temperature variation by day");
Tooltip tooltip = configuration.getTooltip();
tooltip.setValueSuffix("°C");
DataSeries dataSeries = new DataSeries("Temperatures");
for (StockPrices.RangeData data : StockPrices.fetchDailyTempRanges()) {
dataSeries.add(new DataSeriesItem(data.getDate(), data.getMin(), data.getMax()));
}
configuration.setSeries(dataSeries);
chart.setTimeline(true);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class Candlestick method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.CANDLESTICK);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("AAPL Stock Price");
DataSeries dataSeries = new DataSeries();
PlotOptionsCandlestick plotOptionsCandlestick = new PlotOptionsCandlestick();
DataGrouping grouping = new DataGrouping();
grouping.addUnit(new TimeUnitMultiples(TimeUnit.WEEK, 1));
grouping.addUnit(new TimeUnitMultiples(TimeUnit.MONTH, 1, 2, 3, 4, 6));
plotOptionsCandlestick.setDataGrouping(grouping);
dataSeries.setPlotOptions(plotOptionsCandlestick);
for (StockPrices.OhlcData data : StockPrices.fetchAaplOhlcPrice()) {
OhlcItem item = new OhlcItem();
item.setX(data.getDate());
item.setLow(data.getLow());
item.setHigh(data.getHigh());
item.setClose(data.getClose());
item.setOpen(data.getOpen());
dataSeries.add(item);
}
configuration.setSeries(dataSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(4);
configuration.setRangeSelector(rangeSelector);
chart.setTimeline(true);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class AreaRange method initDemo.
@Override
public void initDemo() {
chart = new Chart(ChartType.AREARANGE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Temperature variation by day");
conf.getxAxis().setType(AxisType.DATETIME);
conf.getxAxis().setCrosshair(new Crosshair());
Tooltip tooltip = new Tooltip();
tooltip.setShared(true);
tooltip.setValueSuffix("°C");
conf.setTooltip(tooltip);
RangeSeries data = new RangeSeries("Temperatures", getRawData());
conf.setSeries(data);
chart.drawChart();
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class Bubble method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.BUBBLE);
Configuration conf = chart.getConfiguration();
conf.setTitle((String) null);
DataSeries dataSeries = new DataSeries("All bubbles shown");
dataSeries.add(item(9, 81, 13));
dataSeries.add(item(98, 5, 39));
dataSeries.add(item(51, 50, 23));
dataSeries.add(item(41, 22, -36));
dataSeries.add(item(58, 24, -30));
dataSeries.add(item(78, 37, -16));
dataSeries.add(item(55, 56, 3));
dataSeries.add(item(18, 45, 20));
dataSeries.add(item(42, 44, -22));
dataSeries.add(item(3, 52, 9));
dataSeries.add(item(31, 18, 47));
dataSeries.add(item(79, 91, 13));
dataSeries.add(item(93, 23, -27));
dataSeries.add(item(44, 83, -28));
PlotOptionsBubble opts = new PlotOptionsBubble();
opts.setMaxSize("120");
opts.setMinSize("3");
conf.setPlotOptions(opts);
conf.addSeries(dataSeries);
DataSeries dataSeries2 = new DataSeries("Negative bubbles hidden");
dataSeries2.add(item(13, 30, 10));
dataSeries2.add(item(23, 20, -10));
dataSeries2.add(item(23, 40, 10));
opts = new PlotOptionsBubble();
opts.setDisplayNegative(false);
dataSeries2.setPlotOptions(opts);
conf.addSeries(dataSeries2);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Configuration in project flow-components by vaadin.
the class SVGGeneratorTest method generateSVGFromValidConfiguration.
@Test
public void generateSVGFromValidConfiguration() throws IOException, InterruptedException {
Configuration conf = createPieChartConfiguration();
String svg = svgGenerator.generate(conf);
Path pieChartPath = Paths.get("src", "test", "resources", "pie.svg");
String expectedSVG = readUtf8File(pieChartPath);
assertEquals(replaceIds(expectedSVG), replaceIds(svg));
}
Aggregations