Search in sources :

Example 31 with DataLabels

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;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) DataLabels(com.vaadin.addon.charts.model.DataLabels) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Color(com.vaadin.addon.charts.model.style.Color) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries)

Example 32 with DataLabels

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());
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 33 with DataLabels

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);
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) HeatSeries(com.vaadin.addon.charts.model.HeatSeries) PlotOptionsHeatmap(com.vaadin.addon.charts.model.PlotOptionsHeatmap) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 34 with DataLabels

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");
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) DataLabels(com.vaadin.addon.charts.model.DataLabels) PlotOptionsTreemap(com.vaadin.addon.charts.model.PlotOptionsTreemap) DashStyle(com.vaadin.addon.charts.model.DashStyle) Style(com.vaadin.addon.charts.model.style.Style) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Level(com.vaadin.addon.charts.model.Level) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem) Chart(com.vaadin.addon.charts.Chart)

Example 35 with DataLabels

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;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) DataLabels(com.vaadin.addon.charts.model.DataLabels) Labels(com.vaadin.addon.charts.model.Labels) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

DataLabels (com.vaadin.addon.charts.model.DataLabels)53 Chart (com.vaadin.addon.charts.Chart)46 Configuration (com.vaadin.addon.charts.model.Configuration)43 YAxis (com.vaadin.addon.charts.model.YAxis)31 DataSeries (com.vaadin.addon.charts.model.DataSeries)24 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)20 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)19 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)18 ListSeries (com.vaadin.addon.charts.model.ListSeries)17 XAxis (com.vaadin.addon.charts.model.XAxis)17 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)13 Tooltip (com.vaadin.addon.charts.model.Tooltip)13 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)12 Style (com.vaadin.addon.charts.model.style.Style)11 Legend (com.vaadin.addon.charts.model.Legend)9 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)9 Labels (com.vaadin.addon.charts.model.Labels)6 Series (com.vaadin.addon.charts.model.Series)6 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)6 DrilldownCallback (com.vaadin.addon.charts.DrilldownCallback)4