Search in sources :

Example 11 with PlotOptionsArea

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

the class ContainerWithLotsOfData method createChart.

public static Chart createChart(Series container) {
    final Chart chart = new Chart();
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.AREA);
    configuration.getTitle().setText("Data from Vaadin Container");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Exchange rate"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(container);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 12 with PlotOptionsArea

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

the class ChartWithExternalDataProviderWithChangingData method createChart.

public static Chart createChart(Series ds) {
    final Chart chart = new Chart(ChartType.AREA);
    final Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Data from Vaadin DataProvider");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Data values"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(ds);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 13 with PlotOptionsArea

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

the class DataProviderWithLotsOfData method createChart.

public static Chart createChart(Series ds) {
    final Chart chart = new Chart(ChartType.AREA);
    final Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Data from Vaadin DataProvider");
    configuration.getLegend().setEnabled(false);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Exchange rate"));
    yAxis.setMin(0.6);
    yAxis.setStartOnTick(false);
    yAxis.setShowFirstLabel(false);
    configuration.getTooltip().setShared(true);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
    fillColor.addColorStop(0, new SolidColor("#4572A7"));
    fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
    plotOptions.setFillColor(fillColor);
    plotOptions.setLineWidth(1);
    plotOptions.setShadow(false);
    Marker marker = plotOptions.getMarker();
    marker.setEnabled(false);
    Hover hoverState = new Hover(true);
    hoverState.setRadius(5);
    hoverState.setLineWidth(1);
    marker.getStates().setHover(hoverState);
    plotOptions.getStates().setHover(new Hover(true));
    plotOptions.setShadow(false);
    configuration.setPlotOptions(plotOptions);
    configuration.setSeries(ds);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Hover(com.vaadin.addon.charts.model.Hover) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Marker(com.vaadin.addon.charts.model.Marker) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 14 with PlotOptionsArea

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

the class ColoredContainerSeries method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREA);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Colored ContainerDataSeries"));
    conf.addxAxis(new XAxis());
    YAxis yAxis = new YAxis();
    yAxis.setTitle("Numbers");
    conf.addyAxis(yAxis);
    Collection<Test> col = new ArrayList<>();
    col.add(new Test(10, "TEN"));
    col.add(new Test(11, "ELEVEN"));
    col.add(new Test(12, "TWELVE"));
    DataProvider<Test, ?> ds = new ListDataProvider<>(col);
    DataProviderSeries<Test> chartDS = new DataProviderSeries<>(ds);
    chartDS.setName("Test Series");
    chartDS.setY(Test::getNumber);
    chartDS.setPointName(Test::getName);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    plotOptions.setFillColor(SolidColor.CORNFLOWERBLUE);
    plotOptions.setColor(SolidColor.GOLDENROD);
    chartDS.setPlotOptions(plotOptions);
    // conf.setPlotOptions(plotOptions);
    conf.setSeries(chartDS);
    chart.drawChart(conf);
    return chart;
}
Also used : ListDataProvider(com.vaadin.data.provider.ListDataProvider) DataProviderSeries(com.vaadin.addon.charts.model.DataProviderSeries) Configuration(com.vaadin.addon.charts.model.Configuration) ArrayList(java.util.ArrayList) Title(com.vaadin.addon.charts.model.Title) XAxis(com.vaadin.addon.charts.model.XAxis) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 15 with PlotOptionsArea

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

the class ContainerWithLotsOfData method createContainer.

@SuppressWarnings("unchecked")
private ContainerDataSeries createContainer() {
    IndexedContainer vaadinContainer = new IndexedContainer();
    ContainerDataSeries container = new ContainerDataSeries(vaadinContainer);
    vaadinContainer.addContainerProperty("y", Number.class, null);
    for (int i = 0; i < getContainerData().length; i++) {
        Item item = vaadinContainer.addItem(i);
        item.getItemProperty("y").setValue(getContainerData()[i]);
    }
    container.setName("USD to EUR");
    container.setPlotOptions(new PlotOptionsArea());
    container.setYPropertyId("y");
    return container;
}
Also used : Item(com.vaadin.v7.data.Item) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) ContainerDataSeries(com.vaadin.v7.addon.charts.model.ContainerDataSeries)

Aggregations

PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)18 Configuration (com.vaadin.addon.charts.model.Configuration)16 Chart (com.vaadin.addon.charts.Chart)15 YAxis (com.vaadin.addon.charts.model.YAxis)13 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)11 ListSeries (com.vaadin.addon.charts.model.ListSeries)11 Marker (com.vaadin.addon.charts.model.Marker)9 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)9 XAxis (com.vaadin.addon.charts.model.XAxis)8 Hover (com.vaadin.addon.charts.model.Hover)7 Title (com.vaadin.addon.charts.model.Title)7 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)7 States (com.vaadin.addon.charts.model.States)5 Labels (com.vaadin.addon.charts.model.Labels)4 Subtitle (com.vaadin.addon.charts.model.Subtitle)4 Tooltip (com.vaadin.addon.charts.model.Tooltip)4 Legend (com.vaadin.addon.charts.model.Legend)3 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 PlotBand (com.vaadin.addon.charts.model.PlotBand)2