use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class PointClickCoordinatesColumnChart method createChart.
@Override
protected Chart createChart() {
Chart chart = super.createChart();
Configuration conf = chart.getConfiguration();
conf.setTitle("Total fruit consumption, grouped by gender");
conf.setSubTitle("Source: WorldClimate.com");
XAxis x = new XAxis();
x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
conf.addyAxis(y);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setBackgroundColor(new SolidColor("#FFFFFF"));
legend.setAlign(HorizontalAlign.LEFT);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(100);
legend.setY(70);
legend.setFloating(true);
legend.setShadow(true);
conf.setLegend(legend);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.x +': '+ this.y +' mm'");
conf.setTooltip(tooltip);
PlotOptionsColumn plot = new PlotOptionsColumn();
plot.setPointPadding(0.2);
plot.setBorderWidth(0);
return chart;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class PointClickCoordinatesScatterChart method createChart.
@Override
protected Chart createChart() {
Chart chart = super.createChart();
Configuration conf = chart.getConfiguration();
XAxis x = conf.getxAxis();
x.setGridLineWidth(1);
x.setExtremes(-3, 3);
if (getCurrentTheme().getxAxis().getGridLineColor() != null) {
x.setGridLineColor(getCurrentTheme().getxAxis().getGridLineColor());
}
YAxis y = conf.getyAxis();
y.setExtremes(-1, 1);
ZAxis z = conf.getzAxis();
z.setMin(-1);
z.setMax(1);
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(10);
options3d.setBeta(30);
options3d.setDepth(80);
options3d.setViewDistance(40);
Frame frame = new Frame();
Bottom bottom = new Bottom();
bottom.setSize(1);
frame.setBottom(bottom);
options3d.setFrame(frame);
conf.getChart().setOptions3d(options3d);
chart.drawChart();
return chart;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class ServerSideEvents method getChart.
@Override
protected Component getChart() {
eventDetails.setId("eventDetails");
lastEvent.setId("lastEvent");
historyLayout.setId("history");
chart = new Chart();
chart.setId("chart");
chart.setWidth("500px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SCATTER);
configuration.getTitle().setText("Test server side events.");
configuration.getSubTitle().setText("When an event occurs, the details are shown below the chart");
configuration.setExporting(true);
configuration.getChart().setAnimation(false);
configuration.getChart().setZoomType(ZoomType.XY);
XAxis xAxis = configuration.getxAxis();
xAxis.setMinPadding(0.2);
xAxis.setMaxPadding(0.2);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Value"));
PlotLine plotline = new PlotLine();
plotline.setValue(0);
plotline.setWidth(1);
plotline.setColor(new SolidColor("#808080"));
yAxis.setPlotLines(new PlotLine[] { plotline });
yAxis.setMinPadding(0.2);
yAxis.setMaxPadding(0.2);
YAxis yAxis1 = new YAxis();
yAxis1.setTitle("Another axis");
yAxis1.setOpposite(true);
configuration.addyAxis(yAxis1);
PlotOptionsSeries opt = new PlotOptionsSeries();
opt.setLineWidth(1);
opt.setShowCheckbox(true);
opt.setAllowPointSelect(true);
configuration.setPlotOptions(opt);
configuration.setTooltip(new Tooltip(false));
final DataSeries series1 = createDataSeries(0);
final DataSeries series2 = createDataSeries(20);
DataSeries series3 = createDataSeries(100);
series3.get(0).setY(105);
series3.get(3).setY(95);
series3.setName("Another axis");
series3.setyAxis(1);
firstDataPoint = series1.get(0);
firstDataPoint.setSelected(true);
configuration.setSeries(series1, series2, series3);
chart.drawChart(configuration);
final Layout toggles = createControls();
Layout eventListeners = addEventListeners();
chart.setSeriesVisibilityTogglingDisabled(false);
visibilityToggling.setValue(false);
lastEvent.setCaption("Last event");
eventDetails.setCaption("Details");
historyLayout.setCaption("History");
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.addComponent(toggles);
HorizontalLayout chartAndListeners = new HorizontalLayout(chart, eventListeners);
chartAndListeners.setSizeUndefined();
chartAndListeners.setSpacing(true);
layout.addComponent(chartAndListeners);
layout.addComponent(lastEvent);
layout.addComponent(eventDetails);
layout.addComponent(historyLayout);
return layout;
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class LibraryData method updateChart.
private void updateChart() {
if (series != null) {
ArrayList<DataSeriesItem> list = new ArrayList<DataSeriesItem>();
ArrayList<String> categories = new ArrayList<String>();
for (Helmet.Record r : result.records) {
int numPages = r.getNumPages();
if (numPages != -1) {
String name = String.format("%s, written by %s %s", r.title, r.author, r.description.isEmpty() ? "" : "<br/>" + r.description);
list.add(new DataSeriesItem(name, numPages));
categories.add(r.title.length() > 25 ? r.title.substring(0, 25) + "..." : r.title);
}
}
series.setData(list);
XAxis getyAxes = chart.getConfiguration().getxAxis();
getyAxes.setCategories(categories.toArray(new String[categories.size()]));
chart.drawChart(chart.getConfiguration());
}
}
use of com.vaadin.addon.charts.model.XAxis in project charts by vaadin.
the class BasicLineGettingMousePointerPosition method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setId("chart");
Color[] colors = getThemeColors();
Configuration conf = chart.getConfiguration();
conf.getChart().setZoomType(ZoomType.XY);
conf.setTitle("Average Monthly Temperature and Rainfall in Tokyo");
conf.setSubTitle("Source: WorldClimate.com");
XAxis x = new XAxis();
x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
conf.addxAxis(x);
YAxis primary = new YAxis();
primary.setTitle("Temperature");
Style style = new Style();
style.setColor(colors[0]);
primary.getTitle().setStyle(style);
conf.addyAxis(primary);
YAxis snd = new YAxis();
snd.setTitle("Rainfall");
snd.setOpposite(true);
style = new Style();
style.setColor(colors[1]);
snd.getTitle().setStyle(style);
conf.addyAxis(snd);
Tooltip tooltip = new Tooltip(false);
conf.setTooltip(tooltip);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.LEFT);
legend.setX(120);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setY(100);
legend.setFloating(true);
legend.setBackgroundColor(new SolidColor("#FFFFFF"));
conf.setLegend(legend);
DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsColumn());
series.setName("Rainfall");
series.setData(49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
series.setyAxis(1);
conf.addSeries(series);
series = new DataSeries();
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
series.setPlotOptions(plotOptions);
series.setName("Temperature");
series.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
conf.addSeries(series);
chart.addPointClickListener(new PointClickListener() {
@Override
public void onClick(PointClickEvent event) {
Window win = new Window("PointClickEvent window");
win.setContent(new Label("Browser client area coordinates: point X:" + event.getAbsoluteX() + " Y:" + event.getAbsoluteY()));
win.setPositionX(event.getAbsoluteX());
win.setPositionY(event.getAbsoluteY());
getUI().addWindow(win);
}
});
chart.addChartClickListener(new ChartClickListener() {
@Override
public void onClick(ChartClickEvent event) {
Window win = new Window("Chart Click Event Window");
win.setContent(new Label("Browser client area coordinates: point X:" + event.getAbsoluteX() + " Y:" + event.getAbsoluteY()));
win.setPositionX(event.getAbsoluteX());
win.setPositionY(event.getAbsoluteY());
getUI().addWindow(win);
}
});
return chart;
}
Aggregations