Search in sources :

Example 26 with ListSeries

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

the class BasicUse method basicUseMixed.

public void basicUseMixed() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    // A data series as column graph
    DataSeries series1 = new DataSeries();
    PlotOptionsColumn options1 = new PlotOptionsColumn();
    options1.setColor(SolidColor.BLUE);
    series1.setPlotOptions(options1);
    series1.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
    conf.addSeries(series1);
    // A data series as line graph
    ListSeries series2 = new ListSeries("Diameter");
    PlotOptionsLine options2 = new PlotOptionsLine();
    options2.setColor(SolidColor.RED);
    series2.setPlotOptions(options2);
    series2.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
    conf.addSeries(series2);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart)

Example 27 with ListSeries

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

the class Events method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    final Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Click to add point");
    configuration.getChart().setType(ChartType.SPLINE);
    final ListSeries series = new ListSeries(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    configuration.setSeries(series);
    chart.drawChart(configuration);
    chart.addChartClickListener(new ChartClickListener() {

        @Override
        public void onClick(ChartClickEvent event) {
            double getyAxisValue = event.getyAxisValue();
            series.addData(getyAxisValue);
        }
    });
    return chart;
}
Also used : ChartClickListener(com.vaadin.addon.charts.ChartClickListener) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Chart(com.vaadin.addon.charts.Chart) ChartClickEvent(com.vaadin.addon.charts.ChartClickEvent)

Example 28 with ListSeries

use of com.vaadin.addon.charts.model.ListSeries 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 29 with ListSeries

use of com.vaadin.addon.charts.model.ListSeries 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 30 with ListSeries

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

the class MasterDetailChart method getMasterChart.

private Chart getMasterChart() {
    Chart masterChart = new Chart(ChartType.AREA);
    masterChart.setHeight("80px");
    masterChart.setWidth("100%");
    masterChart.setId("master-chart");
    Configuration configuration = masterChart.getConfiguration();
    configuration.getChart().setZoomType(ZoomType.X);
    configuration.getChart().setReflow(false);
    configuration.getChart().setBorderWidth(0);
    configuration.getChart().setBackgroundColor(null);
    configuration.getChart().setMarginLeft(50);
    configuration.getChart().setMarginRight(20);
    configuration.getTitle().setText("");
    configuration.getxAxis().setType(AxisType.DATETIME);
    configuration.getxAxis().setShowLastLabel(true);
    configuration.getxAxis().setMinRange(14 * DAY_IN_MILLIS);
    configuration.getxAxis().setTitle(new AxisTitle(""));
    PlotBand mask = new PlotBand();
    mask.setColor(new SolidColor(0, 0, 0, 0.2));
    mask.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    mask.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
    configuration.getxAxis().setPlotBands(mask);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setGridLineWidth(0);
    yAxis.setLabels(new Labels(false));
    yAxis.setTitle(new AxisTitle(""));
    yAxis.setMin(0.6);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setEnabled(false);
    configuration.getLegend().setEnabled(false);
    configuration.getCredits().setEnabled(false);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Hover hover = new Hover();
    hover.setLineWidth(1);
    States states = new States();
    states.setHover(hover);
    plotOptions.setStates(states);
    plotOptions.setEnableMouseTracking(false);
    plotOptions.setAnimation(false);
    configuration.setPlotOptions(plotOptions);
    ListSeries ls = new ListSeries();
    PlotOptionsArea masterPlotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor(69, 114, 167, 1));
    fillColor.addColorStop(1, new SolidColor(69, 114, 167, 0.5));
    masterPlotOptions.setFillColor(fillColor);
    masterPlotOptions.setPointInterval(24 * 3600 * 1000);
    masterPlotOptions.setMarker(new Marker(false));
    masterPlotOptions.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
    ls.setPlotOptions(masterPlotOptions);
    ls.setName("USD to EUR");
    ls.setData(FULL_DEMO_DATA_SET);
    configuration.addSeries(ls);
    masterChart.drawChart(configuration);
    return masterChart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Labels(com.vaadin.addon.charts.model.Labels) Marker(com.vaadin.addon.charts.model.Marker) States(com.vaadin.addon.charts.model.States) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) ListSeries(com.vaadin.addon.charts.model.ListSeries) Hover(com.vaadin.addon.charts.model.Hover) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

ListSeries (com.vaadin.addon.charts.model.ListSeries)88 Chart (com.vaadin.addon.charts.Chart)76 Configuration (com.vaadin.addon.charts.model.Configuration)70 YAxis (com.vaadin.addon.charts.model.YAxis)46 XAxis (com.vaadin.addon.charts.model.XAxis)35 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)31 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)25 Tooltip (com.vaadin.addon.charts.model.Tooltip)24 Legend (com.vaadin.addon.charts.model.Legend)18 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)18 DataLabels (com.vaadin.addon.charts.model.DataLabels)17 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)16 Title (com.vaadin.addon.charts.model.Title)15 Labels (com.vaadin.addon.charts.model.Labels)11 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)11 Marker (com.vaadin.addon.charts.model.Marker)10 VerticalLayout (com.vaadin.ui.VerticalLayout)9 Hover (com.vaadin.addon.charts.model.Hover)8 States (com.vaadin.addon.charts.model.States)8 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)8