Search in sources :

Example 86 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class BasicUse method basicUseDataSnippet1.

public void basicUseDataSnippet1() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    ListSeries series = new ListSeries("Diameter");
    series.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
    conf.addSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Chart(com.vaadin.addon.charts.Chart)

Example 87 with Chart

use of com.vaadin.addon.charts.Chart 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 88 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class ChartComponentMapper method tagToComponent.

@Override
public Component tagToComponent(String tagName, Design.ComponentFactory componentFactory, DesignContext context) {
    boolean isChartTag = Pattern.matches("^vaadin-.*-chart$", tagName);
    if (isChartTag) {
        String[] split = tagName.split("-");
        if (split.length != 3) {
            throw new DesignException("Unknown tag: " + tagName);
        }
        String typeName = split[1];
        ChartType chartType = resolveChartTypeFor(typeName);
        if (chartType == null) {
            throw new DesignException("Unknown tag: " + tagName);
        }
        return new Chart(chartType);
    }
    return super.tagToComponent(tagName, componentFactory, context);
}
Also used : DesignException(com.vaadin.ui.declarative.DesignException) ChartType(com.vaadin.addon.charts.model.ChartType) Chart(com.vaadin.addon.charts.Chart)

Example 89 with Chart

use of com.vaadin.addon.charts.Chart 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 90 with Chart

use of com.vaadin.addon.charts.Chart 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

Chart (com.vaadin.addon.charts.Chart)243 Configuration (com.vaadin.addon.charts.model.Configuration)196 YAxis (com.vaadin.addon.charts.model.YAxis)105 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 ListSeries (com.vaadin.addon.charts.model.ListSeries)76 XAxis (com.vaadin.addon.charts.model.XAxis)71 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)57 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)55 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)50 DataLabels (com.vaadin.addon.charts.model.DataLabels)45 Tooltip (com.vaadin.addon.charts.model.Tooltip)44 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)34 Legend (com.vaadin.addon.charts.model.Legend)29 Marker (com.vaadin.addon.charts.model.Marker)23 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)21 Style (com.vaadin.addon.charts.model.style.Style)20 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)19 Labels (com.vaadin.addon.charts.model.Labels)18 VerticalLayout (com.vaadin.ui.VerticalLayout)18 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)16