use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class ResizeInsideVaadinComponent method createChart.
private Chart createChart() {
Chart chart = new Chart(ChartType.AREARANGE);
chart.setSizeFull();
Configuration conf = chart.getConfiguration();
conf.setTitle("Temperature variation by day");
XAxis axis = new XAxis();
axis.setType(AxisType.DATETIME);
axis.setCrosshair(new Crosshair());
conf.addxAxis(axis);
conf.addyAxis(new YAxis());
Tooltip tooltip = new Tooltip();
tooltip.setShared(true);
tooltip.setValueSuffix("°C");
conf.setTooltip(tooltip);
RangeSeries data = new RangeSeries("Temperatures", getRawData());
conf.setSeries(data);
return chart;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class Spiderweb method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.LINE);
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.setTitle("Budget vs spending");
conf.getTitle().setX(-80);
Pane pane = new Pane();
pane.setSize(80, Unit.PERCENTAGE);
conf.addPane(pane);
XAxis axis = new XAxis();
axis.setCategories("Sales", "Marketing", "Development", "Customer Support", "Information Technology", "Administration");
axis.setTickmarkPlacement(TickmarkPlacement.ON);
axis.setLineWidth(0);
YAxis yaxs = new YAxis();
yaxs.setGridLineInterpolation("polygon");
yaxs.setMin(0);
yaxs.setLineWidth(0);
conf.addxAxis(axis);
conf.addyAxis(yaxs);
conf.getTooltip().setShared(true);
conf.getTooltip().setValuePrefix("$");
conf.getLegend().setAlign(HorizontalAlign.RIGHT);
conf.getLegend().setVerticalAlign(VerticalAlign.TOP);
conf.getLegend().setY(100);
conf.getLegend().setLayout(LayoutDirection.VERTICAL);
ListSeries line1 = new ListSeries(43000, 19000, 60000, 35000, 17000, 10000);
ListSeries line2 = new ListSeries(50000, 39000, 42000, 31000, 26000, 14000);
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setPointPlacement(PointPlacement.ON);
line1.setPlotOptions(plotOptions);
line1.setName("Allocated Budget");
plotOptions = new PlotOptionsLine();
plotOptions.setPointPlacement(PointPlacement.ON);
line2.setPlotOptions(plotOptions);
line2.setName("Actual Spending");
conf.setSeries(line1, line2);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class ColumnRange method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMNRANGE);
Configuration conf = chart.getConfiguration();
conf.getChart().setInverted(true);
conf.setTitle("Temperature variation by month");
conf.setSubTitle("Observed in Vik i Sogn, Norway, 2009");
XAxis xAxis = new XAxis();
xAxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle("Temperature ( °C )");
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setValueSuffix("°C");
conf.setTooltip(tooltip);
PlotOptionsColumnrange columnRange = new PlotOptionsColumnrange();
columnRange.setDataLabels(new DataLabelsRange(true));
columnRange.getDataLabels().setFormatter("function() {return this.y + '°C';}");
conf.setPlotOptions(columnRange);
conf.getLegend().setEnabled(false);
// RangeSeries has some helper constructors of which example below, but
// here we use the raw DataSeries API
// RangeSeries data = new RangeSeries("Temperatures", getRawData());
DataSeries data = new DataSeries();
data.setName("Temperatures");
for (Number[] minMaxPair : getRawData()) {
DataSeriesItem item = new DataSeriesItem();
item.setLow(minMaxPair[0]);
item.setHigh(minMaxPair[1]);
data.add(item);
}
conf.setSeries(data);
return chart;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class ColumnSite method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle("Earnings");
conf.setSubTitle("2011 - 2014");
XAxis xAxis = conf.getxAxis();
xAxis.setCategories("2011", "2012", "2013", "2014");
YAxis yAxis = conf.getyAxis();
yAxis.setTitle("B€");
Tooltip tooltip = conf.getTooltip();
tooltip.setPointFormat("{series.name}: {point.y} B€");
conf.addSeries(new ListSeries("Revenue", 1.5, 1.8, 1.2, 2.3));
conf.addSeries(new ListSeries("Expenses", 1.2, 1.1, 1.3, 0.9));
conf.addSeries(new ListSeries("Net income", -0.3, 0.7, -0.1, 1.4));
return chart;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class SplineUpdatingEachSecondWithTwoLines method getChart.
@Override
protected Component getChart() {
final Random random = new Random();
final Chart chart = new Chart();
chart.setWidth("500px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Live random data");
XAxis xAxis = configuration.getxAxis();
xAxis.setType(AxisType.DATETIME);
xAxis.setTickPixelInterval(150);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Value"));
yAxis.setPlotLines(new PlotLine(0, 1, new SolidColor("#808080")));
configuration.getTooltip().setEnabled(false);
configuration.getLegend().setEnabled(false);
final DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsSpline());
series.setName("Random data");
for (int i = -19; i <= 0; i++) {
series.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
final DataSeries series2 = new DataSeries();
series2.setPlotOptions(new PlotOptionsSpline());
series2.setName("Random data");
for (int i = -19; i <= 0; i++) {
series2.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
runWhileAttached(chart, new Runnable() {
@Override
public void run() {
long x = System.currentTimeMillis();
series.add(new DataSeriesItem(x, random.nextDouble()), true, true);
series2.add(new DataSeriesItem(x, random.nextDouble()), true, true);
}
}, 1000, 1000);
configuration.setSeries(series, series2);
chart.drawChart(configuration);
return chart;
}
Aggregations