Search in sources :

Example 41 with DataSeries

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

the class DataSeriesItemJSONSerializationTest method toJSON_PlotOptionsSeriesIsSet_SeriesSerializedWithoutType.

@Test
public void toJSON_PlotOptionsSeriesIsSet_SeriesSerializedWithoutType() {
    DataSeries series = new DataSeries();
    series.setPlotOptions(new PlotOptionsSeries());
    String expected = "{\"data\":[]}";
    assertEquals(expected, toJSON(series));
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries) Test(org.junit.Test)

Example 42 with DataSeries

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

the class BasicUse method basicUse3dDistanceSnippet2.

public void basicUse3dDistanceSnippet2() {
    double x = 3.2;
    double z = 3.3;
    double y = 2.3;
    Options3d options3d = new Options3d();
    DataSeriesItem3d item = new DataSeriesItem3d(x, y, z * options3d.getDepth().doubleValue());
    double distance = 43.2;
    // Grayness
    int gr = (int) (distance * 75);
    Marker marker = new Marker(true);
    marker.setRadius(1 + 10 / distance);
    marker.setFillColor(new SolidColor(gr, gr, gr));
    item.setMarker(marker);
    DataSeries series = new DataSeries();
    series.add(item);
}
Also used : DataSeriesItem3d(com.vaadin.addon.charts.model.DataSeriesItem3d) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) Options3d(com.vaadin.addon.charts.model.Options3d)

Example 43 with DataSeries

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

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

the class ModifyOnePoint method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart();
    chart.setHeight("300px");
    chart.setWidth("100%");
    final Configuration configuration = chart.getConfiguration();
    configuration.setTitle("One point is different");
    configuration.getTooltip().setEnabled(false);
    configuration.getChart().setType(ChartType.SPLINE);
    series = new DataSeries();
    series.add(createBasicPoint(1, 4));
    series.add(new DataSeriesItem(3, 4));
    dataSeriesItem = new DataSeriesItem(4, 4);
    Marker marker = new Marker(true);
    marker.setRadius(10);
    marker.setFillColor(new SolidColor("red"));
    dataSeriesItem.setMarker(marker);
    dataSeriesItem.setName("Special point");
    series.add(dataSeriesItem);
    series.add(new DataSeriesItem(8, 3));
    configuration.setSeries(series);
    chart.drawChart(configuration);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 45 with DataSeries

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

the class ColumnWithMultiLevelDrilldown method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    final Configuration conf = chart.getConfiguration();
    conf.setTitle("Global happiness index");
    conf.setSubTitle("Source: www.happyplanetindex.org");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total percent market share");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    DataSeries regionsSeries = new DataSeries();
    regionsSeries.setName("Regions");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    regionsSeries.setPlotOptions(plotOptionsColumn);
    DataSeriesItem regionItem = new DataSeriesItem("Latin America and Carribean", 60);
    DataSeries countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Latin America and Carribean Countries");
    DataSeriesItem countryItem = new DataSeriesItem("Costa Rica", 64);
    DataSeries detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Costa Rica");
    String[] categories = new String[] { "Life Expectancy", "Well-being (0-10)", "Footprint (gha/capita)" };
    Number[] ys = new Number[] { 79.3, 7.3, 2.5 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Colombia", 59.8);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Colombia");
    ys = new Number[] { 73.7, 6.4, 1.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Belize", 59.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Belize");
    ys = new Number[] { 76.1, 6.5, 2.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("El Salvador", 58.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details El Salvador");
    ys = new Number[] { 72.2, 6.7, 2.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Western Nations", 50);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Western Nations Countries");
    countryItem = new DataSeriesItem("New Zealand", 51.6);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details New Zealand");
    ys = new Number[] { 80.7, 7.2, 4.3 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Norway", 51.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Norway");
    ys = new Number[] { 81.1, 7.6, 4.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Switzerland", 50.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Switzerland");
    ys = new Number[] { 82.3, 7.5, 5.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("United Kingdom", 47.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details United Kingdom");
    ys = new Number[] { 80.2, 7.0, 4.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Western Nations", 50);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Western Nations Countries");
    countryItem = new DataSeriesItem("New Zealand", 51.6);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details New Zealand");
    ys = new Number[] { 80.7, 7.2, 4.3 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Norway", 51.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Norway");
    ys = new Number[] { 81.1, 7.6, 4.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Switzerland", 50.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Switzerland");
    ys = new Number[] { 82.3, 7.5, 5.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("United Kingdom", 47.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details United Kingdom");
    ys = new Number[] { 80.2, 7.0, 4.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Middle East and North Africa", 53);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Middle East and North Africa Countries");
    countryItem = new DataSeriesItem("Israel", 55.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Israel");
    ys = new Number[] { 81.6, 7.4, 4.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Algeria", 52.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Algeria");
    ys = new Number[] { 73.1, 5.2, 1.6 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Jordan", 51.7);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Jordan");
    ys = new Number[] { 73.4, 5.7, 2.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Palestine", 51.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Palestine");
    ys = new Number[] { 72.8, 4.8, 1.4 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Sub-Saharan Africa", 42);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Sub-Saharan Africa Countries");
    countryItem = new DataSeriesItem("Madagascar", 51.6);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Madagascar");
    ys = new Number[] { 66.7, 4.6, 1.2 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Malawi", 42.5);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Malawi");
    ys = new Number[] { 54.2, 5.1, 0.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Ghana", 40.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Ghana");
    ys = new Number[] { 64.2, 4.6, 1.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Ethiopia", 39.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Ethiopia");
    ys = new Number[] { 59.3, 4.4, 1.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("South Asia", 53);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("South Asia Countries");
    countryItem = new DataSeriesItem("Bangladesh", 56.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Bangladesh");
    ys = new Number[] { 68.9, 5.0, 0.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Pakistan", 54.1);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Pakistan");
    ys = new Number[] { 65.4, 5.3, 0.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("India", 50.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details India");
    ys = new Number[] { 65.4, 5.0, 0.9 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Sri Lanka", 51.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Sri Lanka");
    ys = new Number[] { 74.9, 4.2, 1.2 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("East Asia", 55);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("East Asia Countries");
    countryItem = new DataSeriesItem("Vietnam", 60.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Vietnam");
    ys = new Number[] { 75.2, 5.8, 1.4 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Indonesia", 55.5);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Indonesia");
    ys = new Number[] { 69.4, 5.5, 1.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Thailand", 53.5);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Thailand");
    ys = new Number[] { 74.1, 6.2, 2.4 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Philippines", 52.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Philippines");
    ys = new Number[] { 68.7, 4.9, 1.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    conf.addSeries(regionsSeries);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

DataSeries (com.vaadin.addon.charts.model.DataSeries)118 Chart (com.vaadin.addon.charts.Chart)81 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)81 Configuration (com.vaadin.addon.charts.model.Configuration)71 YAxis (com.vaadin.addon.charts.model.YAxis)38 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)26 XAxis (com.vaadin.addon.charts.model.XAxis)25 DataLabels (com.vaadin.addon.charts.model.DataLabels)21 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)17 Tooltip (com.vaadin.addon.charts.model.Tooltip)15 Test (org.junit.Test)15 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)14 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)14 Marker (com.vaadin.addon.charts.model.Marker)13 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)13 Style (com.vaadin.addon.charts.model.style.Style)10 Random (java.util.Random)10 Legend (com.vaadin.addon.charts.model.Legend)9 PlotLine (com.vaadin.addon.charts.model.PlotLine)9 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)8