Search in sources :

Example 26 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.

the class SplineUpdatingEachSecondWithTwoLines method getChart.

@Override
protected Component getChart() {
    final Random random = new Random();
    final Chart chart = new Chart();
    chart.setWidth("500px");
    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"));
    yAxis.setPlotLines(new PlotLine(0, 1, new SolidColor("#808080")));
    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()));
    }
    final DataSeries series2 = new DataSeries();
    series2.setPlotOptions(new PlotOptionsSpline());
    series2.setName("Random data");
    for (int i = -19; i <= 0; i++) {
        series2.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
    }
    runWhileAttached(chart, new Runnable() {

        @Override
        public void run() {
            long x = System.currentTimeMillis();
            series.add(new DataSeriesItem(x, random.nextDouble()), true, true);
            series2.add(new DataSeriesItem(x, random.nextDouble()), true, true);
        }
    }, 1000, 1000);
    configuration.setSeries(series, series2);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) XAxis(com.vaadin.addon.charts.model.XAxis) Random(java.util.Random) PlotLine(com.vaadin.addon.charts.model.PlotLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 27 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.

the class SplineWithItemLabels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.SPLINE);
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Wind speed during two days");
    configuration.getSubTitle().setText("October 6th and 7th 2009 at two locations in Vik i Sogn, Norway");
    configuration.getxAxis().setType(AxisType.DATETIME);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Wind speed (m/s)"));
    PlotOptionsSpline plotOptions = new PlotOptionsSpline();
    configuration.setPlotOptions(plotOptions);
    plotOptions.setMarker(new Marker(false));
    plotOptions.setPointInterval(ONE_HOUR);
    plotOptions.setPointStart(toDate("2009,09,06"));
    DataSeries ds = new DataSeries();
    ds.setName("Hestavollane");
    ds.setData(4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 7.4, 6.9, 7.1, 7.9, 7.9, 7.5, 6.7, 7.7, 7.7, 7.4, 7.0, 7.1, 5.8, 5.9, 7.4, 8.2, 8.5, 9.4, 8.1, 10.9, 10.4, 10.9, 12.4, 12.1, 9.5, 7.5, 7.1, 7.5, 8.1, 6.8, 3.4, 2.1, 1.9, 2.8, 2.9, 1.3, 4.4, 4.2, 3.0, 3.0);
    DataSeriesItem item = new DataSeriesItem();
    item.setY(4.51);
    item.setDataLabels(getDataLabels());
    ds.add(item);
    configuration.addSeries(ds);
    ds = new DataSeries();
    ds.setName("Voll");
    ds.setData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0, 0.0, 0.4, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6, 1.2, 1.7, 0.7, 2.9, 4.1, 2.6, 3.7, 3.9, 1.7, 2.3, 3.0, 3.3, 4.8, 5.0, 4.8, 5.0, 3.2, 2.0, 0.9, 0.4, 0.3, 0.5, 0.4);
    item = new DataSeriesItem();
    item.setY(0.27);
    item.setDataLabels(getDataLabels());
    ds.add(item);
    configuration.addSeries(ds);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 28 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.

the class ChartPluginExamples method createHeatMap.

public static Chart createHeatMap() {
    final Chart chart = new Chart(CustomChartTypes.MAP);
    chart.setWidth("800px");
    chart.setHeight("500px");
    final Configuration configuration = chart.getConfiguration();
    ChartModel model = new ChartModel();
    configuration.setChart(model);
    model.setType(CustomChartTypes.MAP);
    model.setBorderWidth(1);
    model.setZoomType(ZoomType.XY);
    model.setInverted(false);
    configuration.getTitle().setText("Vaadin Charts Test for complex highcharts plugin");
    XAxis xAxis = configuration.getxAxis();
    xAxis.setEndOnTick(false);
    xAxis.setGridLineWidth(0);
    xAxis.getLabels().setEnabled(false);
    xAxis.setLineWidth(0);
    xAxis.setMinPadding(0);
    xAxis.setMaxPadding(0);
    xAxis.setStartOnTick(false);
    xAxis.setTickWidth(0);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setEndOnTick(false);
    yAxis.setGridLineWidth(0);
    yAxis.getLabels().setEnabled(false);
    yAxis.setLineWidth(0);
    yAxis.setMinPadding(0);
    yAxis.setMaxPadding(0);
    yAxis.setStartOnTick(false);
    yAxis.setTickWidth(0);
    yAxis.setTitle("");
    yAxis.setReversed(true);
    Legend legend = configuration.getLegend();
    legend.setHorizontalAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.BOTTOM);
    legend.setFloating(true);
    legend.setLayout(LayoutDirection.VERTICAL);
    configuration.setExporting(false);
    MapSeries series = new MapSeries();
    series.addValueRange(new ValueRange(null, 3, new SolidColor(19, 64, 117, 0.05)));
    series.addValueRange(new ValueRange(3, 10, new SolidColor(19, 64, 117, 0.2)));
    series.addValueRange(new ValueRange(10, 30, new SolidColor(19, 64, 117, 0.4)));
    series.addValueRange(new ValueRange(30, 100, new SolidColor(19, 64, 117, 0.5)));
    series.addValueRange(new ValueRange(100, 300, new SolidColor(19, 64, 117, 0.6)));
    series.addValueRange(new ValueRange(300, 1000, new SolidColor(19, 64, 117, 0.8)));
    series.addValueRange(new ValueRange(1000, null, new SolidColor(19, 64, 117, 1)));
    Random random = new Random();
    for (String c : Locale.getISOCountries()) {
        DataSeriesItem p = new DataSeriesItem(c.toLowerCase(), random.nextInt(1200));
        series.add(p);
    }
    configuration.addSeries(series);
    chart.drawChart(configuration);
    return chart;
}
Also used : ValueRange(com.vaadin.demo.chartplugin.model.ValueRange) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Random(java.util.Random) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ChartModel(com.vaadin.addon.charts.model.ChartModel) MapSeries(com.vaadin.demo.chartplugin.model.MapSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 29 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.

the class ChartExportDemo method createChartConf.

private static Configuration createChartConf() {
    Configuration conf = new Configuration();
    conf.getChart().setType(ChartType.PIE);
    conf.setTitle("Browser market shares at a specific website, 2010");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setCursor(Cursor.POINTER);
    Labels dataLabels = new Labels();
    dataLabels.setEnabled(true);
    dataLabels.setColor(new SolidColor(0, 0, 0));
    dataLabels.setConnectorColor(new SolidColor(0, 0, 0));
    dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
    plotOptions.setDataLabels(dataLabels);
    conf.setPlotOptions(plotOptions);
    DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Firefox", 45.0));
    series.add(new DataSeriesItem("IE", 26.8));
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setSliced(true);
    chrome.setSelected(true);
    series.add(chrome);
    series.add(new DataSeriesItem("Safari", 8.5));
    series.add(new DataSeriesItem("Opera", 6.2));
    series.add(new DataSeriesItem("Others", 0.7));
    conf.setSeries(series);
    return conf;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Labels(com.vaadin.addon.charts.model.Labels) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 30 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem in project charts by vaadin.

the class ChartTypes method chartTypesWaterfallDataModel.

public void chartTypesWaterfallDataModel() {
    // Define the colors
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    // The data
    DataSeries series = new DataSeries();
    // The beginning balance
    DataSeriesItem start = new DataSeriesItem("Start", 306503);
    SolidColor balanceColor = SolidColor.KHAKI;
    start.setColor(balanceColor);
    series.add(start);
    // Deltas
    series.add(new DataSeriesItem("Predators", -3330));
    series.add(new DataSeriesItem("Slaughter", -103332));
    series.add(new DataSeriesItem("Reproduction", +104052));
    WaterFallSum end = new WaterFallSum("End");
    end.setColor(balanceColor);
    // Not intermediate (default)
    end.setIntermediate(false);
    series.add(end);
    conf.addSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) WaterFallSum(com.vaadin.addon.charts.model.WaterFallSum) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)88 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 Chart (com.vaadin.addon.charts.Chart)57 Configuration (com.vaadin.addon.charts.model.Configuration)51 YAxis (com.vaadin.addon.charts.model.YAxis)27 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)17 XAxis (com.vaadin.addon.charts.model.XAxis)17 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)12 Random (java.util.Random)12 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)11 Test (org.junit.Test)11 Tooltip (com.vaadin.addon.charts.model.Tooltip)10 Marker (com.vaadin.addon.charts.model.Marker)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8 PlotLine (com.vaadin.addon.charts.model.PlotLine)7 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)7 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)6 ListSeries (com.vaadin.addon.charts.model.ListSeries)6 Style (com.vaadin.addon.charts.model.style.Style)6