use of com.vaadin.addon.charts.model.DataLabelsRange 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.DataLabelsRange in project charts by vaadin.
the class ContainerSeriesWithHighAndLow 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);
IndexedContainer vaadinContainer = new IndexedContainer();
vaadinContainer.addContainerProperty("min", Number.class, null);
vaadinContainer.addContainerProperty("max", Number.class, null);
for (Number[] minMaxPair : getRawData()) {
Item item = vaadinContainer.getItem(vaadinContainer.addItem());
item.getItemProperty("min").setValue(minMaxPair[0]);
item.getItemProperty("max").setValue(minMaxPair[1]);
}
ContainerDataSeries data = new ContainerDataSeries(vaadinContainer);
data.setLowPropertyId("min");
data.setHighPropertyId("max");
data.setName("Temperatures");
conf.setSeries(data);
return chart;
}
use of com.vaadin.addon.charts.model.DataLabelsRange in project charts by vaadin.
the class DataProviderSeriesWithHighAndLow 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);
conf.setSeries(createChartDS());
return chart;
}
use of com.vaadin.addon.charts.model.DataLabelsRange in project charts by vaadin.
the class ColumnRangeResourceUsage method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMNRANGE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Resource usage");
conf.getChart().setInverted(true);
XAxis xAxis = new XAxis();
xAxis.setCategories("Printer", "Coffee mahine");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle("Time");
yAxis.setType(AxisType.DATETIME);
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name +': '+ Highcharts.dateFormat('%H:%M', this.point.low) + ' - ' + Highcharts.dateFormat('%H:%M', this.point.high)");
conf.setTooltip(tooltip);
PlotOptionsColumnrange columnRange = new PlotOptionsColumnrange();
columnRange.setGrouping(false);
DataLabelsRange dataLabels = new DataLabelsRange(true);
dataLabels.setFormatter("this.y == this.point.low ? '' : this.series.name");
dataLabels.setInside(true);
dataLabels.setColor(new SolidColor("white"));
columnRange.setDataLabels(dataLabels);
conf.setPlotOptions(columnRange);
Calendar instance = Calendar.getInstance();
instance.set(Calendar.MILLISECOND, 0);
instance.set(2013, 6, 7, 12, 00, 00);
DataSeries a = new DataSeries();
a.setName("Team Alpha");
PlotOptionsColumnrange o = new PlotOptionsColumnrange();
o.setColor(new SolidColor(255, 60, 125, 0.8));
a.setPlotOptions(o);
DataSeries b = new DataSeries();
o = new PlotOptionsColumnrange();
o.setColor(new SolidColor(60, 125, 255, 0.8));
b.setPlotOptions(o);
b.setName("Team Beta");
DataSeriesItem item;
item = new DataSeriesItem();
item.setName("Printer");
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 3);
item.setHigh(instance.getTimeInMillis());
a.add(item);
item = new DataSeriesItem();
item.setName("Printer");
instance.roll(Calendar.HOUR_OF_DAY, 1);
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 1);
item.setHigh(instance.getTimeInMillis());
b.add(item);
instance.set(2013, 6, 7, 12, 00, 00);
item = new DataSeriesItem();
item.setName("Coffee mahine");
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 2);
item.setHigh(instance.getTimeInMillis());
b.add(item);
item = new DataSeriesItem();
item.setName("Coffee mahine");
instance.roll(Calendar.HOUR_OF_DAY, -1);
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 4);
item.setHigh(instance.getTimeInMillis());
a.add(item);
conf.setSeries(a, b);
return chart;
}
Aggregations