Search in sources :

Example 16 with PlotOptionsLine

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

the class Sparkline method configureAsSparkline.

protected void configureAsSparkline() {
    getConfiguration().setTitle("");
    getConfiguration().setLegend(new Legend(false));
    getConfiguration().getChart().setBackgroundColor(new SolidColor(0, 0, 0, 0));
    getConfiguration().getChart().setMargin(0);
    Series series = getConfiguration().getSeries().get(0);
    PlotOptionsLine options = new PlotOptionsLine();
    options.setEnableMouseTracking(false);
    options.setMarker(new Marker(false));
    options.setShowInLegend(false);
    options.setAnimation(false);
    options.setShadow(false);
    series.setPlotOptions(options);
    configureXAxis(getConfiguration().getxAxis());
    configureYAxis(getConfiguration().getyAxis());
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) Series(com.vaadin.addon.charts.model.Series) Legend(com.vaadin.addon.charts.model.Legend) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker)

Example 17 with PlotOptionsLine

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

the class MasterDetailChart method getChart.

@Override
protected Component getChart() {
    VerticalLayout lo = new VerticalLayout();
    lo.setSpacing(false);
    lo.setMargin(false);
    lo.setWidth("100%");
    lo.setHeight("600px");
    final Chart masterChart = getMasterChart();
    final Chart detailChart = getDetailChart();
    masterChart.addChartSelectionListener(new ChartSelectionListener() {

        @Override
        public void onSelection(ChartSelectionEvent event) {
            long start = event.getSelectionStart().longValue();
            long end = event.getSelectionEnd().longValue();
            // set plot band to highlight the selection on the master chart
            PlotBand plotBand1 = new PlotBand();
            PlotBand plotBand2 = new PlotBand();
            plotBand1.setColor(new SolidColor(0, 0, 0, 0.2));
            plotBand2.setColor(new SolidColor(0, 0, 0, 0.2));
            plotBand1.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
            plotBand1.setTo(start);
            plotBand2.setFrom(end);
            plotBand2.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
            masterChart.getConfiguration().getxAxis().setPlotBands(plotBand1, plotBand2);
            masterChart.drawChart();
            List<Number> list = MasterDetailChart.this.getPartialList(start, end);
            Configuration configuration = detailChart.getConfiguration();
            configuration.getChart().setAnimation(false);
            ListSeries detailData = (ListSeries) configuration.getSeries().get(0);
            PlotOptionsLine plotOptionsLine = (PlotOptionsLine) detailData.getPlotOptions();
            plotOptionsLine.setPointStart(start);
            detailData.setData(list);
            detailChart.drawChart(configuration);
        }
    });
    lo.addComponent(detailChart);
    lo.addComponent(masterChart);
    return lo;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) VerticalLayout(com.vaadin.ui.VerticalLayout) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ArrayList(java.util.ArrayList) List(java.util.List) ChartSelectionEvent(com.vaadin.addon.charts.ChartSelectionEvent) ChartSelectionListener(com.vaadin.addon.charts.ChartSelectionListener) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart)

Example 18 with PlotOptionsLine

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

the class MasterDetailChart method getDetailChart.

private Chart getDetailChart() {
    Chart detailChart = new Chart();
    detailChart.setHeight("100%");
    detailChart.setWidth("100%");
    Configuration configuration = detailChart.getConfiguration();
    configuration.getCredits().setEnabled(false);
    configuration.setTitle("Historical USD to EUR Exchange Rate");
    configuration.setSubTitle("Select an area by dragging across the lower chart");
    configuration.getxAxis().setType(AxisType.DATETIME);
    configuration.getyAxis().setTitle(new AxisTitle((String) null));
    configuration.getyAxis().setMinRange(0.1);
    configuration.getTooltip().setFormatter("function() {var point = this.points[0];return '<b>'+ point.series.name +'</b><br/>'+Highcharts.dateFormat('%A %B %e %Y', this.x) + ':<br/>'+'1 USD = '+ Highcharts.numberFormat(point.y, 2) +' EUR';}");
    configuration.getTooltip().setShared(true);
    PlotOptionsLine series = new PlotOptionsLine();
    series.setPointInterval(DAY_IN_MILLIS);
    configuration.setPlotOptions(series);
    States states = new States();
    Hover hover = new Hover();
    hover.setRadius(3);
    states.setHover(hover);
    Marker marker = series.getMarker();
    marker.setEnabled(false);
    marker.setStates(states);
    marker.setRadius(2);
    series.setAnimation(false);
    ListSeries seriesList = new ListSeries();
    PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
    plotOptionsLine.setPointInterval(DAY_IN_MILLIS);
    plotOptionsLine.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    seriesList.setPlotOptions(plotOptionsLine);
    seriesList.setName("USD to EUR");
    seriesList.setData(FULL_DEMO_DATA_SET);
    configuration.getLegend().setEnabled(false);
    configuration.setExporting(false);
    configuration.addSeries(seriesList);
    detailChart.drawChart(configuration);
    return detailChart;
}
Also used : States(com.vaadin.addon.charts.model.States) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) Hover(com.vaadin.addon.charts.model.Hover) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart)

Example 19 with PlotOptionsLine

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

the class ScatterWithRegressionLine method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    Color[] colors = getThemeColors();
    XAxis x = new XAxis();
    x.setMin(-0.5);
    x.setMax(5.5);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    conf.addyAxis(y);
    conf.setTitle("Scatter plot with regression line");
    DataSeries series = new DataSeries();
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setColor(colors[1]);
    series.setPlotOptions(plotOptions);
    series.setName("Regression Line");
    List<DataSeriesItem> list = new ArrayList<DataSeriesItem>();
    list.add(new DataSeriesItem(0, 1.11));
    list.add(new DataSeriesItem(5, 4.51));
    series.setData(list);
    plotOptions.setMarker(new Marker(true));
    plotOptions.setEnableMouseTracking(true);
    Hover hover = new Hover();
    hover.setLineWidth(0);
    States states = new States();
    states.setHover(hover);
    plotOptions.setStates(states);
    conf.addSeries(series);
    ListSeries listSeries = new ListSeries("Observations", 1, 1.5, 2.8, 3.5, 3.9, 4.2);
    PlotOptionsScatter plotOptions2 = new PlotOptionsScatter();
    listSeries.setPlotOptions(plotOptions2);
    Marker marker = new Marker(true);
    marker.setRadius(4);
    plotOptions2.setMarker(marker);
    conf.addSeries(listSeries);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsScatter(com.vaadin.addon.charts.model.PlotOptionsScatter) Color(com.vaadin.addon.charts.model.style.Color) ArrayList(java.util.ArrayList) Marker(com.vaadin.addon.charts.model.Marker) XAxis(com.vaadin.addon.charts.model.XAxis) States(com.vaadin.addon.charts.model.States) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) Hover(com.vaadin.addon.charts.model.Hover) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 20 with PlotOptionsLine

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

the class DynamicExtremes method getChart.

@Override
protected Component getChart() {
    final Chart 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(-10d);
    yAxis.setMax(30d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.HIGH);
    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);
    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);
    final CheckBox extremes = new CheckBox("Switch extremes");
    extremes.addValueChangeListener(e -> {
        if (e.getValue()) {
            chart.getConfiguration().getyAxes().getAxis(0).setExtremes(10, 15);
        } else {
            chart.getConfiguration().getyAxes().getAxis(0).setExtremes(-10, 30);
        }
    });
    VerticalLayout layout = new VerticalLayout(chart, extremes);
    return layout;
}
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) CheckBox(com.vaadin.ui.CheckBox) VerticalLayout(com.vaadin.ui.VerticalLayout) 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