Search in sources :

Example 91 with Configuration

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

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

the class Chart method writeDesign.

@Override
public void writeDesign(Element design, DesignContext designContext) {
    super.writeDesign(design, designContext);
    Configuration configuration = getConfiguration();
    if (configuration != null) {
        ChartDesignWriter.writeConfigurationToElement(configuration, design, designContext);
    }
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration)

Example 93 with Configuration

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

the class Chart method readDesign.

@Override
public void readDesign(Element design, DesignContext designContext) {
    super.readDesign(design, designContext);
    Configuration configuration = getConfiguration();
    if (configuration == null) {
        configuration = new Configuration();
    }
    ChartDesignReader.readConfigurationFromElements(design.children(), configuration);
    setConfiguration(configuration);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration)

Example 94 with Configuration

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

use of com.vaadin.addon.charts.model.Configuration 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)

Aggregations

Configuration (com.vaadin.addon.charts.model.Configuration)257 Chart (com.vaadin.addon.charts.Chart)196 YAxis (com.vaadin.addon.charts.model.YAxis)100 DataSeries (com.vaadin.addon.charts.model.DataSeries)72 ListSeries (com.vaadin.addon.charts.model.ListSeries)70 XAxis (com.vaadin.addon.charts.model.XAxis)65 Test (org.junit.Test)58 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)56 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)54 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)51 Tooltip (com.vaadin.addon.charts.model.Tooltip)42 DataLabels (com.vaadin.addon.charts.model.DataLabels)41 Legend (com.vaadin.addon.charts.model.Legend)30 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)30 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)27 Elements (org.jsoup.select.Elements)27 Marker (com.vaadin.addon.charts.model.Marker)22 DesignContext (com.vaadin.ui.declarative.DesignContext)22 Element (org.jsoup.nodes.Element)22 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)20