use of com.vaadin.addon.charts.model.AxisTitle 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.AxisTitle in project charts by vaadin.
the class TimeSeriesWithTimeline method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
chart.setTimeline(true);
Color[] colors = getThemeColors();
Configuration configuration = chart.getConfiguration();
configuration.getChart().setSpacingRight(20);
configuration.getTitle().setText("USD to EUR exchange rate from 2006 through 2008");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setMinRange(TWO_WEEKS);
configuration.getxAxis().setTitle(new AxisTitle(""));
configuration.getLegend().setEnabled(false);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Exchange rate"));
yAxis.setMin(0.6);
yAxis.setStartOnTick(false);
yAxis.setShowFirstLabel(false);
configuration.getTooltip().setShared(true);
PlotOptionsArea plotOptions = new PlotOptionsArea();
GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
fillColor.addColorStop(0, (SolidColor) colors[0]);
fillColor.addColorStop(1, (SolidColor) colors[8]);
plotOptions.setFillColor(fillColor);
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Marker marker = plotOptions.getMarker();
marker.setEnabled(false);
Hover hoverState = new Hover(true);
hoverState.setRadius(5);
States states = new States();
states.setHover(hoverState);
marker.setStates(states);
Hover hoverStateForArea = new Hover(true);
hoverStateForArea.setLineWidth(1);
States statesForArea = new States();
statesForArea.setHover(hoverStateForArea);
plotOptions.setStates(statesForArea);
plotOptions.setShadow(false);
configuration.setPlotOptions(plotOptions);
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd");
ListSeries ls = new ListSeries();
PlotOptionsArea options = new PlotOptionsArea();
options.setPointInterval(DAY_IN_MILLIS);
ls.setPlotOptions(options);
ls.setName("USD to EUR");
try {
options.setPointStart(df.parse("2006/01/02").getTime());
} catch (ParseException e) {
e.printStackTrace();
}
ls.setData(USD_TO_EUR_EXCHANGE_RATES);
configuration.setSeries(ls);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class WindRose method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.getChart().setInverted(false);
conf.setTitle("Wind rose for South Shore Met Station, Oregon");
conf.setSubTitle("Source: or.water.usgs.gov");
Pane pane = new Pane();
pane.setSize("85%");
conf.addPane(pane);
conf.getLegend().setReversed(false);
conf.getLegend().setAlign(HorizontalAlign.RIGHT);
conf.getLegend().setVerticalAlign(VerticalAlign.TOP);
conf.getLegend().setY(100);
conf.getLegend().setLayout(LayoutDirection.VERTICAL);
XAxis axis = new XAxis();
axis.setCategories("< 0.5 m/s", "0.5-2 m/s", "2-4 m/s", "4-6 m/s", "6-8 m/s", "8-10 m/s", "> 10 m/s");
axis.setTickmarkPlacement(TickmarkPlacement.ON);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
yAxis.setEndOnTick(false);
yAxis.setShowLastLabel(true);
yAxis.setTitle(new AxisTitle("Frequency (%)"));
Labels labels = new Labels();
labels.setFormatter("function() {return this.value + '%';}");
yAxis.setLabels(labels);
conf.addxAxis(axis);
conf.addyAxis(yAxis);
conf.getTooltip().setValueSuffix("%");
PlotOptionsColumn series = new PlotOptionsColumn();
series.setStacking(Stacking.NORMAL);
series.setShadow(false);
series.setGroupPadding(0);
series.setPointPlacement(PointPlacement.ON);
conf.setPlotOptions(series);
ListSeries n = new ListSeries("N", 1.81, 1.78, 0.16, 0.00, 0.00, 0.00, 0.00);
ListSeries nne = new ListSeries("NNE", 0.62, 1.09, 0.00, 0.00, 0.00, 0.00, 0.00);
ListSeries ne = new ListSeries("NE", 0.82, 0.82, 0.07, 0.00, 0.00, 0.00, 0.00);
ListSeries ene = new ListSeries("ENE", 0.59, 1.22, 0.07, 0.00, 0.00, 0.00, 0.00);
ListSeries e = new ListSeries("E", 0.62, 2.20, 0.49, 0.00, 0.00, 0.00, 0.00);
ListSeries ese = new ListSeries("ESE", 1.22, 2.01, 1.55, 0.30, 0.13, 0.00, 0.00);
ListSeries se = new ListSeries("SE", 1.61, 3.06, 2.37, 2.14, 1.74, 0.39, 0.13);
ListSeries sse = new ListSeries("SSE", 2.04, 3.42, 1.97, 0.86, 0.53, 0.49, 0.00);
ListSeries s = new ListSeries("S", 2.66, 4.74, 0.43, 0.00, 0.00, 0.00, 0.00);
ListSeries ssw = new ListSeries("SSW", 2.96, 4.14, 0.26, 0.00, 0.00, 0.00, 0.00);
ListSeries sw = new ListSeries("SW", 2.53, 4.01, 1.22, 0.49, 0.13, 0.00, 0.00);
ListSeries wsw = new ListSeries("WSW", 1.97, 2.66, 1.97, 0.79, 0.30, 0.00, 0.00);
ListSeries w = new ListSeries("W", 1.64, 1.71, 0.92, 1.45, 0.26, 0.10, 0.00);
ListSeries wnw = new ListSeries("WNW", 1.32, 2.40, 0.99, 1.61, 0.33, 0.00, 0.00);
ListSeries nw = new ListSeries("NW", 1.58, 4.28, 1.28, 0.76, 0.66, 0.69, 0.03);
ListSeries nnw = new ListSeries("NNW", 1.51, 5.00, 1.32, 0.13, 0.23, 0.13, 0.07);
conf.setSeries(n, nne, ne, ene, e, ese, se, sse, s, ssw, sw, wsw, w, wnw, nw, nnw);
// transpose data "matrix"
conf.reverseListSeries();
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class CustomClock method getChart.
@Override
protected Chart getChart() {
final Chart chart = new Chart();
chart.setWidth("500px");
chart.setHeight("200px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.GAUGE);
configuration.getChart().setPlotBackgroundColor(null);
configuration.getChart().setPlotBackgroundImage(null);
configuration.getChart().setPlotBorderWidth(0);
configuration.getChart().setPlotShadow(false);
configuration.setTitle("The Vaadin Charts customised clock");
configuration.getCredits().setEnabled(false);
GradientColor gradient1 = GradientColor.createRadial(0.5, -0.4, 1.9);
gradient1.addColorStop(0.5, new SolidColor(255, 255, 255, 0.2));
gradient1.addColorStop(0.5, new SolidColor(200, 200, 200, 0.2));
Background[] background = new Background[2];
background[0] = new Background();
background[1] = new Background();
background[1].setBackgroundColor(gradient1);
background[1].setBorderWidth(1);
background[1].setOuterRadius("107%");
configuration.getPane().setBackground(background);
YAxis yAxis = configuration.getyAxis();
yAxis.getLabels().setDistance(-20);
yAxis.setMin(0);
yAxis.setMax(12);
yAxis.setLineWidth(0);
yAxis.setShowFirstLabel(false);
yAxis.setMinorTickInterval("auto");
yAxis.setMinorTickWidth(1);
yAxis.setMinorTickLength(5);
yAxis.setMinorTickPosition(TickPosition.INSIDE);
yAxis.setMinorGridLineWidth(0);
yAxis.setMinorTickColor(new SolidColor("#666"));
yAxis.setTickInterval(1);
yAxis.setTickWidth(2);
yAxis.setTickPosition(TickPosition.INSIDE);
yAxis.setTickLength(10);
yAxis.setTickColor(new SolidColor("#666"));
yAxis.setTitle(new AxisTitle("Powered by<br/>Vaadin Charts 2"));
yAxis.getTitle().setStyle(new Style());
yAxis.getTitle().getStyle().setColor(new SolidColor("#BBB"));
yAxis.getTitle().getStyle().setFontWeight(FontWeight.BOLD);
yAxis.getTitle().getStyle().setFontSize("8px");
yAxis.getTitle().getStyle().setLineHeight("10px");
yAxis.getTitle().setY(10);
final DataSeries series = new DataSeries();
final DataSeriesItem second = new DataSeriesItem();
second.setId("second");
second.setY(30);
second.setDial(new Dial());
second.getDial().setRadius("100%");
second.getDial().setBaseWidth(1);
second.getDial().setRearLength("20%");
second.getDial().setBackgroundColor(SolidColor.AQUA);
second.getDial().setBorderColor(SolidColor.RED);
second.getDial().setBorderWidth(10);
second.getDial().setTopWidth(8);
series.add(second);
PlotOptionsGauge plotOptionsGauge = new PlotOptionsGauge();
plotOptionsGauge.setDataLabels(new DataLabels(false));
configuration.setPlotOptions(plotOptionsGauge);
configuration.setSeries(series);
final Calendar cal = Calendar.getInstance();
runWhileAttached(chart, new Runnable() {
@Override
public void run() {
cal.setTimeInMillis(System.currentTimeMillis());
double secs = cal.get(Calendar.SECOND);
// disable animation when the second dial reaches 0
boolean animation = secs == 0 ? false : true;
configuration.getChart().setAnimation(animation);
second.setY(secs * (12.0 / 60.0));
series.update(second);
}
}, 1000, 15000);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.AxisTitle in project charts by vaadin.
the class ErrorBarExample method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
Color[] colors = getThemeColors();
// Enable xy zooming, test also with touch devices
conf.getChart().setZoomType(ZoomType.XY);
conf.setTitle("Temperature vs Rainfall");
conf.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis primaryAxis = conf.getyAxis();
AxisTitle title = new AxisTitle("Temperature");
Style style = new Style();
style.setColor(colors[0]);
title.setStyle(style);
primaryAxis.setTitle(title);
Labels labels = new Labels();
labels.setFormatter("this.value + '°C'");
primaryAxis.setLabels(labels);
YAxis secondaryAxis = new YAxis();
conf.addyAxis(secondaryAxis);
title = new AxisTitle("Rainfall");
secondaryAxis.setTitle(title);
style = new Style();
style.setColor(colors[1]);
title.setStyle(style);
labels = new Labels();
labels.setFormatter("this.value + ' mm'");
labels.setStyle(style);
secondaryAxis.setLabels(labels);
secondaryAxis.setOpposite(true);
conf.getTooltip().setShared(true);
DataSeries rainfall = new DataSeries("Rainfall");
PlotOptionsColumn column = new PlotOptionsColumn();
column.setColor(colors[1]);
SeriesTooltip tooltip = new SeriesTooltip();
tooltip.setPointFormat("<span style='font-weight: bold; color: {series.color}'>{series.name}</span>: <b>{point.y:.1f} mm</b> ");
column.setTooltip(tooltip);
rainfall.setPlotOptions(column);
conf.addSeries(rainfall);
rainfall.setyAxis(secondaryAxis);
DataSeries rainfallError = new DataSeries("Rainfall");
conf.addSeries(rainfallError);
rainfallError.setyAxis(secondaryAxis);
PlotOptionsErrorbar rainErrorOptions = new PlotOptionsErrorbar();
tooltip = new SeriesTooltip();
tooltip.setPointFormat("(error range: {point.low}-{point.high} mm)<br/>");
rainErrorOptions.setTooltip(tooltip);
rainfallError.setPlotOptions(rainErrorOptions);
DataSeries temperature = new DataSeries("Temperature");
conf.addSeries(temperature);
PlotOptionsSpline tempOptions = new PlotOptionsSpline();
tempOptions.setColor(colors[0]);
tooltip = new SeriesTooltip();
tooltip.setPointFormat("<span style='font-weight: bold; color: {series.color}'>{series.name}</span>: <b>{point.y:.1f}°C");
tempOptions.setTooltip(tooltip);
temperature.setPlotOptions(tempOptions);
DataSeries temperatureErrors = new DataSeries("Temperature error");
conf.addSeries(temperatureErrors);
PlotOptionsErrorbar tempErrorOptions = new PlotOptionsErrorbar();
SolidColor green = new SolidColor("green");
tempErrorOptions.setStemColor(green);
tempErrorOptions.setWhiskerColor(green);
tooltip = new SeriesTooltip();
tooltip.setPointFormat("(error range: {point.low}-{point.high}°C)<br/>");
tempErrorOptions.setTooltip(tooltip);
temperatureErrors.setPlotOptions(tempErrorOptions);
// Populate series
for (Data d : DATA) {
DataSeriesItem item = new DataSeriesItem();
item.setY(d.rainfall);
rainfall.add(item);
item = new DataSeriesItem();
item.setLow(d.rainfallErrorLow);
item.setHigh(d.rainfallErrorHigh);
rainfallError.add(item);
item = new DataSeriesItem();
item.setY(d.temperature);
temperature.add(item);
item = new DataSeriesItem();
item.setLow(d.temperatureErrorLow);
item.setHigh(d.temperatureErrorHigh);
temperatureErrors.add(item);
}
return chart;
}
Aggregations