Search in sources :

Example 1 with Legend

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

the class SVGGeneratorTest method createConf.

private Configuration createConf() {
    Configuration conf = new Configuration();
    conf.setTitle("Historic World Population by Region");
    conf.setSubTitle("Source: Wikipedia.org");
    XAxis x = new XAxis();
    x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
    x.setTitle(new AxisTitle((String) null));
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    AxisTitle title = new AxisTitle("Population (millions)");
    title.setAlign(VerticalAlign.HIGH);
    y.setTitle(title);
    conf.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    // tooltip.setFormatter("this.series.name +': '+ this.y +' millions'");
    conf.setTooltip(tooltip);
    PlotOptionsBar plot = new PlotOptionsBar();
    plot.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(plot);
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-100);
    legend.setY(100);
    legend.setFloating(true);
    legend.setBorderWidth(1);
    legend.setBackgroundColor(new SolidColor("#FFFFFF"));
    legend.setShadow(true);
    conf.setLegend(legend);
    conf.disableCredits();
    List<Series> series = new ArrayList<Series>();
    series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
    series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
    series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
    conf.setSeries(series);
    return conf;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) ArrayList(java.util.ArrayList) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) PlotOptionsBar(com.vaadin.addon.charts.model.PlotOptionsBar) XAxis(com.vaadin.addon.charts.model.XAxis) Series(com.vaadin.addon.charts.model.Series) ListSeries(com.vaadin.addon.charts.model.ListSeries) TreeSeries(com.vaadin.addon.charts.model.TreeSeries) DataSeries(com.vaadin.addon.charts.model.DataSeries) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 2 with Legend

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

the class PieWithLegendNavigator method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    Legend legend = conf.getLegend();
    legend.setLayout(VERTICAL);
    legend.setAlign(RIGHT);
    legend.setVerticalAlign(TOP);
    LegendNavigation nav = legend.getNavigation();
    nav.setActiveColor(GREEN);
    nav.setArrowSize(24);
    conf.setTitle("Lot of slices to force navigation in legend");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.getDataLabels().setEnabled(false);
    plotOptions.setShowInLegend(true);
    conf.setPlotOptions(plotOptions);
    DataSeries series = new DataSeries();
    for (int i = 0; i < 50; i++) {
        series.add(new DataSeriesItem("Item " + i, 1));
    }
    conf.addSeries(series);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) LegendNavigation(com.vaadin.addon.charts.model.LegendNavigation) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 3 with Legend

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

the class PointClickCoordinatesBarChart method createChart.

@Override
protected Chart createChart() {
    Chart chart = super.createChart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Historic World Population by Region");
    conf.setSubTitle("Source: Wikipedia.org");
    Legend legend = new Legend();
    legend.setLabelFormatter("function() { return this.name + ' (click to hide)'; }");
    conf.setLegend(legend);
    return chart;
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Chart(com.vaadin.addon.charts.Chart)

Example 4 with Legend

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

the class ChartDesignWriterTest method writeConfiguration_enumValueDefinedInConfiguration_theValueIsAddedAsAttribute.

@Test
public void writeConfiguration_enumValueDefinedInConfiguration_theValueIsAddedAsAttribute() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    configuration.setLegend(legend);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<legend layout=\"vertical\"></legend>", parent.child(0).toString());
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Example 5 with Legend

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

the class ChartDesignWriterTest method writeConfiguration_numberValueDefinedInConfiguration_theValueIsAddedAsAttribute.

@Test
public void writeConfiguration_numberValueDefinedInConfiguration_theValueIsAddedAsAttribute() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    Legend legend = new Legend();
    legend.setY(100);
    configuration.setLegend(legend);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<legend y=\"100\"></legend>", parent.child(0).toString());
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Aggregations

Legend (com.vaadin.addon.charts.model.Legend)35 Configuration (com.vaadin.addon.charts.model.Configuration)30 Chart (com.vaadin.addon.charts.Chart)29 YAxis (com.vaadin.addon.charts.model.YAxis)24 XAxis (com.vaadin.addon.charts.model.XAxis)20 ListSeries (com.vaadin.addon.charts.model.ListSeries)19 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)17 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)15 Tooltip (com.vaadin.addon.charts.model.Tooltip)14 DataSeries (com.vaadin.addon.charts.model.DataSeries)10 DataLabels (com.vaadin.addon.charts.model.DataLabels)9 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)8 Style (com.vaadin.addon.charts.model.style.Style)7 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)6 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)5 Series (com.vaadin.addon.charts.model.Series)5 Title (com.vaadin.addon.charts.model.Title)5 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)4 ArrayList (java.util.ArrayList)4 Labels (com.vaadin.addon.charts.model.Labels)3