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