Search in sources :

Example 6 with PlotOptionsLine

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

the class Spiderweb method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.LINE);
    Configuration conf = chart.getConfiguration();
    conf.getChart().setPolar(true);
    conf.setTitle("Budget vs spending");
    conf.getTitle().setX(-80);
    Pane pane = new Pane();
    pane.setSize(80, Unit.PERCENTAGE);
    conf.addPane(pane);
    XAxis axis = new XAxis();
    axis.setCategories("Sales", "Marketing", "Development", "Customer Support", "Information Technology", "Administration");
    axis.setTickmarkPlacement(TickmarkPlacement.ON);
    axis.setLineWidth(0);
    YAxis yaxs = new YAxis();
    yaxs.setGridLineInterpolation("polygon");
    yaxs.setMin(0);
    yaxs.setLineWidth(0);
    conf.addxAxis(axis);
    conf.addyAxis(yaxs);
    conf.getTooltip().setShared(true);
    conf.getTooltip().setValuePrefix("$");
    conf.getLegend().setAlign(HorizontalAlign.RIGHT);
    conf.getLegend().setVerticalAlign(VerticalAlign.TOP);
    conf.getLegend().setY(100);
    conf.getLegend().setLayout(LayoutDirection.VERTICAL);
    ListSeries line1 = new ListSeries(43000, 19000, 60000, 35000, 17000, 10000);
    ListSeries line2 = new ListSeries(50000, 39000, 42000, 31000, 26000, 14000);
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setPointPlacement(PointPlacement.ON);
    line1.setPlotOptions(plotOptions);
    line1.setName("Allocated Budget");
    plotOptions = new PlotOptionsLine();
    plotOptions.setPointPlacement(PointPlacement.ON);
    line2.setPlotOptions(plotOptions);
    line2.setName("Actual Spending");
    conf.setSeries(line1, line2);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Pane(com.vaadin.addon.charts.model.Pane) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 7 with PlotOptionsLine

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

the class CustomThemeUI method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    ChartOptions.get().setTheme(new CustomTheme());
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries();
    ls.setName("Tokyo");
    ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) CustomTheme(com.vaadin.addon.charts.examples.themes.CustomTheme) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 8 with PlotOptionsLine

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

the class LargeDataSet method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.getConfiguration().setTitle("Large data set");
    // Force zoom and enable scrollbar
    chart.getConfiguration().getxAxis().setMin(5000);
    chart.getConfiguration().getScrollbar().setEnabled(true);
    DataSeries series = new DataSeries();
    Number[] data = TimeSeriesZoomable.USD_TO_EUR_EXCHANGE_RATES;
    Random r = new Random(0);
    int x = 0;
    for (int j = 0; j < ROUNDS; j++) {
        for (Number number : data) {
            DataSeriesItem item;
            if (xyPairs()) {
                x += r.nextInt(4);
                item = new DataSeriesItem(x, number);
            } else {
                // interval data (x == index of data point), performs better
                // and consumes less memory/bandwidth
                item = new DataSeriesItem();
                item.setY(number);
            }
            /*
                 * Note, with large datasets, avoid settings like
                 * item.setColor(myColorX), or item.setName(myName) for data
                 * items. Without them the framework is able to optimize the
                 * rendering and can survive from rather large datasets.
                 * 
                 * Also note, that if data set is very large, the library might
                 * ignore it if there are custom settings for data items. This
                 * threshold is called turboThreshHold in plot options. See
                 * example below.
                 */
            // item.setName("x " + x);
            series.add(item);
        }
    }
    /*
         * If you play with this example your might try uncomment next line to
         * keep the amount of transfered data sane. You might also try to
         * increase the ROUNDS to increase the input data. By default commented
         * out to stress client side performance
         */
    // reduce(series, 1000);
    /*
         * If data can contain high/low peaks, one can use more sophisticated
         * algorithms
         */
    // ramerDouglasPeuckerReduce(series, 300);
    chart.getConfiguration().setSeries(series);
    PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
    // Showing points with thousands of data items looks odd (on top of each
    // other), also renders faster without markers
    plotOptionsLine.setMarker(new Marker(false));
    // To render shadow, library must create additional element, without it
    // performance will be better
    plotOptionsLine.setShadow(false);
    plotOptionsLine.setAnimation(false);
    /*
         * If developers need to use large data sets and point specific
         * settings, they can override the default turbo threshold. Here we set
         * it to 200000 (default 1000). Turbo threshold is configuration that
         * works as a "sanity threshold" so that old browsers wont drop to their
         * knees under load. Without this Vaadin Charts might not render chart
         * if data items have e.g. name set.
         */
    plotOptionsLine.setTurboThreshold(200000);
    chart.getConfiguration().setPlotOptions(plotOptionsLine);
    return chart;
}
Also used : Random(java.util.Random) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 9 with PlotOptionsLine

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

the class LineWithDashSelector method getChart.

@Override
protected Component getChart() {
    chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    plotOptions.setDashStyle(DashStyle.DOT);
    configuration.setPlotOptions(plotOptions);
    Legend legend = configuration.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-10d);
    legend.setY(100d);
    legend.setBorderWidth(0);
    ListSeries ls = new ListSeries();
    ls.setName("Tokyo");
    ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("New York");
    ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("Berlin");
    ls.setData(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 10 with PlotOptionsLine

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

the class BasicLineWithDataLabels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    plotOptions.setEnableMouseTracking(false);
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries();
    ls.setName("Tokyo");
    ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    configuration.addSeries(ls);
    chart.drawChart(configuration);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)33 Configuration (com.vaadin.addon.charts.model.Configuration)25 Chart (com.vaadin.addon.charts.Chart)21 ListSeries (com.vaadin.addon.charts.model.ListSeries)19 YAxis (com.vaadin.addon.charts.model.YAxis)13 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)10 DataLabels (com.vaadin.addon.charts.model.DataLabels)9 Test (org.junit.Test)9 DataSeries (com.vaadin.addon.charts.model.DataSeries)7 Legend (com.vaadin.addon.charts.model.Legend)6 Marker (com.vaadin.addon.charts.model.Marker)5 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)4 XAxis (com.vaadin.addon.charts.model.XAxis)4 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)3 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)3 Elements (org.jsoup.select.Elements)3 Hover (com.vaadin.addon.charts.model.Hover)2 Labels (com.vaadin.addon.charts.model.Labels)2 Pane (com.vaadin.addon.charts.model.Pane)2 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)2