简体   繁体   中英

How use dCharts Widget in a Vaadin project?

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

To use dCharts i have execute this step:

  1. Download .jar or copy dependency for maven/ivy from: https://vaadin.com/directory#!addon/dcharts-widget
  2. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM