Search in sources :

Example 31 with DataSeriesItem

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

the class ChartTypes method chartTypesScatterMarkerPropertiesSnippet1.

public void chartTypesScatterMarkerPropertiesSnippet1() {
    double x = 1.0;
    double y = 1.2;
    double z = 1.45;
    DataSeries series = new DataSeries();
    DataSeriesItem point = new DataSeriesItem(x, y);
    Marker marker = new Marker();
    // Set line width and color
    // Normally zero width
    marker.setLineWidth(1);
    marker.setLineColor(SolidColor.BLACK);
    // Set RGB fill color
    int level = (int) Math.round((1 - z) * 127);
    marker.setFillColor(new SolidColor(255 - level, 0, level));
    point.setMarker(marker);
    marker.setRadius((z + 1) * 5);
    series.add(point);
}
Also used : SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 32 with DataSeriesItem

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

the class ChartData method asynchronousDrilldown.

public void asynchronousDrilldown(Chart chart) {
    DataSeries series = new DataSeries();
    DataSeriesItem mainItem = new DataSeriesItem("MSIE", 55.11);
    series.addItemWithDrilldown(mainItem);
    chart.setDrilldownCallback(new DrilldownCallback() {

        @Override
        public Series handleDrilldown(DrilldownEvent event) {
            DataSeries drillDownSeries = new DataSeries("MSIE versions");
            drillDownSeries.add(new DataSeriesItem("MSIE 6.0", 10.85));
            drillDownSeries.add(new DataSeriesItem("MSIE 7.0", 7.35));
            drillDownSeries.add(new DataSeriesItem("MSIE 8.0", 33.06));
            drillDownSeries.add(new DataSeriesItem("MSIE 9.0", 2.81));
            return drillDownSeries;
        }
    });
}
Also used : DataProviderSeries(com.vaadin.addon.charts.model.DataProviderSeries) Series(com.vaadin.addon.charts.model.Series) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) ListSeries(com.vaadin.addon.charts.model.ListSeries) DataSeries(com.vaadin.addon.charts.model.DataSeries) DrilldownCallback(com.vaadin.addon.charts.DrilldownCallback) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) DrilldownEvent(com.vaadin.addon.charts.DrilldownEvent)

Example 33 with DataSeriesItem

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

the class DataSeriesItemJSONSerializationTest method toJSON_xAndyAreSet_ItemSerializedWithXYAndNull.

@Test
public void toJSON_xAndyAreSet_ItemSerializedWithXYAndNull() {
    DataSeriesItem item = new DataSeriesItem();
    item.setX(2);
    item.setY(3);
    DataSeries series = new DataSeries();
    series.add(item);
    String expected = "{\"data\":[[2,3]]}";
    assertEquals(expected, toJSON(series));
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Test(org.junit.Test)

Example 34 with DataSeriesItem

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

the class DataSeriesItemJSONSerializationTest method toJSON_xIsSet_ItemSerializedWithXAndNulls.

@Test
public void toJSON_xIsSet_ItemSerializedWithXAndNulls() {
    DataSeriesItem item = new DataSeriesItem();
    item.setX(2);
    DataSeries series = new DataSeries();
    series.add(item);
    String expected = "{\"data\":[[2,null,null]]}";
    assertEquals(expected, toJSON(series));
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Test(org.junit.Test)

Example 35 with DataSeriesItem

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

the class DataSeriesItemJSONSerializationTest method toJSON_yIsSet_ItemSerializedWithY.

@Test
public void toJSON_yIsSet_ItemSerializedWithY() {
    DataSeriesItem item = new DataSeriesItem();
    item.setY(2);
    DataSeries series = new DataSeries();
    series.add(item);
    String expected = "{\"data\":[2]}";
    assertEquals(expected, toJSON(series));
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Test(org.junit.Test)

Aggregations

DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)88 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 Chart (com.vaadin.addon.charts.Chart)57 Configuration (com.vaadin.addon.charts.model.Configuration)51 YAxis (com.vaadin.addon.charts.model.YAxis)27 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)17 XAxis (com.vaadin.addon.charts.model.XAxis)17 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)12 Random (java.util.Random)12 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)11 Test (org.junit.Test)11 Tooltip (com.vaadin.addon.charts.model.Tooltip)10 Marker (com.vaadin.addon.charts.model.Marker)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8 PlotLine (com.vaadin.addon.charts.model.PlotLine)7 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)7 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)6 ListSeries (com.vaadin.addon.charts.model.ListSeries)6 Style (com.vaadin.addon.charts.model.style.Style)6