问题
I was looking for a 'free alternative to Vaadin Charts and found DCharts Widget, but I can not find guides or complete documentation to' use. Does anyone know how to import and use this widget? The guides to get started?
- Vaadin: 7.4
- Apache Tomcat V8
- JDK 1.8
回答1:
To use dCharts i have execute this step:
- Download .jar or copy dependency for maven/ivy from: https://vaadin.com/directory#!addon/dcharts-widget
- Follow the instructions in this official page based on your installation method. (I have choose to download .jar and compile it with Vaadin Plug-in for Eclipse)
Small exemple of code:
final VerticalLayout layout = new VerticalLayout();
DataSeries dataSeries = new DataSeries()
.add(1, 5, 8, 2, 3);
SeriesDefaults seriesDefaults = new SeriesDefaults()
.setRenderer(SeriesRenderers.BAR);
Axes axes = new Axes()
.addAxis(
new XYaxis().setRenderer(AxisRenderers.CATEGORY)
.setTicks(new Ticks()
.add("a", "b", "c", "d", "e")));
Highlighter highlighter = new Highlighter()
.setShow(false);
Options options = new Options()
.setSeriesDefaults(seriesDefaults)
.setAxes(axes)
.setHighlighter(highlighter);
DCharts chart = new DCharts()
.setDataSeries(dataSeries)
.setOptions(options)
.show();
layout.addComponent(chart);
来源:https://stackoverflow.com/questions/40265243/how-use-dcharts-widget-in-a-vaadin-project