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);
}
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);
}
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));
}
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));
}
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);
}
Aggregations