use of com.vaadin.addon.charts.model.DataLabels in project charts by vaadin.
the class PointClickCoordinatesDonutChart method createInnerSeries.
private Series createInnerSeries() {
DataSeries innerSeries = new DataSeries();
innerSeries.setName("Browsers");
PlotOptionsPie innerPieOptions = new PlotOptionsPie();
innerSeries.setPlotOptions(innerPieOptions);
innerPieOptions.setSize("237px");
innerPieOptions.setDataLabels(new DataLabels());
innerPieOptions.getDataLabels().setFormatter("this.y > 5 ? this.point.name : null");
innerPieOptions.getDataLabels().setColor(new SolidColor(255, 255, 255));
innerPieOptions.getDataLabels().setDistance(-30);
Color[] innerColors = Arrays.copyOf(colors, 5);
innerSeries.setData(new String[] { "MSIE", "Firefox", "Chrome", "Safari", "Opera" }, new Number[] { 55.11, 21.63, 11.94, 7.15, 2.14 }, innerColors);
return innerSeries;
}
use of com.vaadin.addon.charts.model.DataLabels in project charts by vaadin.
the class LabelsJSONSerializationTest method toJSON_allowOverlapIsSet_labelsSerializedWithAllowOverlap.
@Test
public void toJSON_allowOverlapIsSet_labelsSerializedWithAllowOverlap() throws IOException {
DataLabels labels = new DataLabels(true);
labels.setAllowOverlap(true);
ObjectMapper om = ChartSerialization.createObjectMapper();
String json = toJSON(labels);
DataLabels fromJson = om.readValue(json, DataLabels.class);
assertEquals(true, fromJson.getAllowOverlap());
}
use of com.vaadin.addon.charts.model.DataLabels in project charts by vaadin.
the class ChartTypes method chartTypesHeatMap.
public void chartTypesHeatMap() {
Chart chart = new Chart(ChartType.HEATMAP);
chart.setWidth("600px");
chart.setHeight("300px");
Configuration conf = chart.getConfiguration();
conf.setTitle("Heat Data");
// Set colors for the extremes
conf.getColorAxis().setMinColor(SolidColor.AQUA);
conf.getColorAxis().setMaxColor(SolidColor.RED);
// Set up border and data labels
PlotOptionsHeatmap plotOptions = new PlotOptionsHeatmap();
plotOptions.setBorderColor(SolidColor.WHITE);
plotOptions.setBorderWidth(2);
plotOptions.setDataLabels(new DataLabels(true));
conf.setPlotOptions(plotOptions);
// Create some data
HeatSeries series = new HeatSeries();
// Jan High
series.addHeatPoint(0, 0, 10.9);
// Jan Low
series.addHeatPoint(0, 1, -51.5);
// Feb High
series.addHeatPoint(1, 0, 11.8);
// Dec Low
series.addHeatPoint(11, 1, -47.0);
conf.addSeries(series);
// Set the category labels on the X axis
XAxis xaxis = new XAxis();
xaxis.setTitle("Month");
xaxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
conf.addxAxis(xaxis);
// Set the category labels on the Y axis
YAxis yaxis = new YAxis();
yaxis.setTitle("");
yaxis.setCategories("High C", "Low C");
conf.addyAxis(yaxis);
}
use of com.vaadin.addon.charts.model.DataLabels in project charts by vaadin.
the class ChartTypes method chartTypesTreemap.
public void chartTypesTreemap() {
Chart chart = new Chart();
PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.STRIPES);
plotOptions.setAlternateStartingDirection(true);
Level level = new Level();
level.setLevel(1);
level.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SLICEANDDICE);
DataLabels dataLabels = new DataLabels();
dataLabels.setEnabled(true);
dataLabels.setAlign(HorizontalAlign.LEFT);
dataLabels.setVerticalAlign(VerticalAlign.TOP);
Style style = new Style();
style.setFontSize("15px");
style.setFontWeight(FontWeight.BOLD);
dataLabels.setStyle(style);
level.setDataLabels(dataLabels);
plotOptions.setLevels(level);
TreeSeries series = new TreeSeries();
TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
apples.setColor(new SolidColor("#EC2500"));
TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
bananas.setColor(new SolidColor("#ECE100"));
TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
oranges.setColor(new SolidColor("#EC9800"));
TreeSeriesItem anneA = new TreeSeriesItem("Anne", apples, 5);
TreeSeriesItem rickA = new TreeSeriesItem("Rick", apples, 3);
TreeSeriesItem paulA = new TreeSeriesItem("Paul", apples, 4);
TreeSeriesItem anneB = new TreeSeriesItem("Anne", bananas, 4);
TreeSeriesItem rickB = new TreeSeriesItem("Rick", bananas, 10);
TreeSeriesItem paulB = new TreeSeriesItem("Paul", bananas, 1);
TreeSeriesItem anneO = new TreeSeriesItem("Anne", oranges, 1);
TreeSeriesItem rickO = new TreeSeriesItem("Rick", oranges, 3);
TreeSeriesItem paulO = new TreeSeriesItem("Paul", oranges, 3);
TreeSeriesItem susanne = new TreeSeriesItem("Susanne", 2);
susanne.setParent("Kiwi");
susanne.setColor(new SolidColor("#9EDE00"));
series.addAll(apples, bananas, oranges, anneA, rickA, paulA, anneB, rickB, paulB, anneO, rickO, paulO, susanne);
series.setPlotOptions(plotOptions);
chart.getConfiguration().addSeries(series);
chart.getConfiguration().setTitle("Fruit consumption");
}
use of com.vaadin.addon.charts.model.DataLabels in project charts by vaadin.
the class BasicLineWithCallouts method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.LINE);
configuration.getTitle().setText("CALLOUT: Monthly Average Temperature");
configuration.getSubTitle().setText("Source: WorldClimate.com");
configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Temperature (°C)"));
configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
PlotOptionsLine plotOptions = new PlotOptionsLine();
Labels dataLabels = new Labels(false);
plotOptions.setEnableMouseTracking(false);
configuration.setPlotOptions(plotOptions);
DataSeries ds = new DataSeries();
ds.setName("Tokyo");
ds.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
DataLabels callout = new DataLabels(true);
callout.setShape(Shape.CALLOUT);
callout.setBackgroundColor(SolidColor.BLANCHEDALMOND);
callout.setY(-12);
ds.get(5).setDataLabels(callout);
configuration.addSeries(ds);
ds = new DataSeries();
ds.setName("London");
ds.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
ds.get(7).setDataLabels(callout);
configuration.addSeries(ds);
chart.drawChart(configuration);
return chart;
}
Aggregations