Search in sources :

Example 76 with DataSeriesItem

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

the class ChartTypes method chartTypesScatterMarkersSnippet1.

public void chartTypesScatterMarkersSnippet1() {
    double x = 1.0;
    double y = 1.2;
    DataSeriesItem point = new DataSeriesItem(x, y);
    Marker marker = new Marker();
    // ... Make any settings ...
    point.setMarker(marker);
    DataSeries series = new DataSeries();
    series.add(point);
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 77 with DataSeriesItem

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

the class ChartTypes method chartTypesFunnel.

public void chartTypesFunnel() {
    Chart chart = new Chart(ChartType.FUNNEL);
    chart.setWidth("500px");
    chart.setHeight("350px");
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monster Utilization");
    conf.getLegend().setEnabled(false);
    // Give more room for the labels
    conf.getChart().setSpacingRight(120);
    // Configure the funnel neck shape
    PlotOptionsFunnel options = new PlotOptionsFunnel();
    options.setNeckHeight(20, Sizeable.Unit.PERCENTAGE);
    options.setNeckWidth(20, Sizeable.Unit.PERCENTAGE);
    // Style the data labels
    DataLabelsFunnel dataLabels = new DataLabelsFunnel();
    dataLabels.setFormat("<b>{point.name}</b> ({point.y:,.0f})");
    dataLabels.setSoftConnector(false);
    dataLabels.setColor(SolidColor.BLACK);
    options.setDataLabels(dataLabels);
    conf.setPlotOptions(options);
    // Create the range series
    DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Monsters Met", 340));
    series.add(new DataSeriesItem("Engaged", 235));
    series.add(new DataSeriesItem("Killed", 187));
    series.add(new DataSeriesItem("Tinned", 70));
    series.add(new DataSeriesItem("Eaten", 55));
    conf.addSeries(series);
}
Also used : DataLabelsFunnel(com.vaadin.addon.charts.model.DataLabelsFunnel) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsFunnel(com.vaadin.addon.charts.model.PlotOptionsFunnel) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 78 with DataSeriesItem

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

the class DataSeriesItemJSONSerializationTest method toJSON_xAndLowAndHighAreSet_ItemSerializedWithXAndLowAndHigh.

@Test
public void toJSON_xAndLowAndHighAreSet_ItemSerializedWithXAndLowAndHigh() {
    DataSeriesItem item = new DataSeriesItem();
    item.setX(2);
    item.setLow(3);
    item.setHigh(4);
    DataSeries series = new DataSeries();
    series.add(item);
    String expected = "{\"data\":[[2,3,4]]}";
    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 79 with DataSeriesItem

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

the class DataSeriesItemJSONSerializationTest method toJSON_cursorIsSet_ItemSerializedWithCursor.

@Test
public void toJSON_cursorIsSet_ItemSerializedWithCursor() {
    DataSeriesItem item = new DataSeriesItem();
    item.setCursor("progress");
    DataSeries series = new DataSeries();
    series.add(item);
    String expected = "{\"data\":[{\"cursor\":\"progress\"}]}";
    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 80 with DataSeriesItem

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

the class ChartTypes method chartTypesErrorbarSnippet1.

public void chartTypesErrorbarSnippet1() {
    // Create a chart of some primary type
    Chart chart = new Chart(ChartType.SCATTER);
    chart.setWidth("600px");
    chart.setHeight("400px");
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Average Temperatures in Turku");
    conf.getLegend().setEnabled(false);
    // The primary data series
    ListSeries averages = new ListSeries(-6, -6.5, -4, 3, 9, 14, 17, 16, 11, 6, 2, -2.5);
    // Error bar data series with low and high values
    DataSeries errors = new DataSeries();
    errors.add(new DataSeriesItem(0, -9, -3));
    errors.add(new DataSeriesItem(1, -10, -3));
    errors.add(new DataSeriesItem(2, -8, 1));
    // Configure the stem and whiskers in error bars
    PlotOptionsErrorbar barOptions = new PlotOptionsErrorbar();
    barOptions.setStemColor(SolidColor.GREY);
    barOptions.setStemWidth(2);
    barOptions.setStemDashStyle(DashStyle.DASH);
    barOptions.setWhiskerColor(SolidColor.BROWN);
    // 80% of category width
    barOptions.setWhiskerLength(80, Sizeable.Unit.PERCENTAGE);
    // Pixels
    barOptions.setWhiskerWidth(2);
    errors.setPlotOptions(barOptions);
    // The errors should be drawn lower
    conf.addSeries(errors);
    conf.addSeries(averages);
}
Also used : PlotOptionsErrorbar(com.vaadin.addon.charts.model.PlotOptionsErrorbar) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

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