use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class TimeDataWithIrregularIntervalsAndLocalizedTexts method getChart.
@Override
protected Component getChart() {
// localizations
final Lang fi = new Lang();
fi.setDecimalPoint(",");
fi.setShortMonths(new String[] { "Tammi", "Helmi", "Maalis", "Huhti", "Touko", "Kesä", "Heinä", "Elo", "Syys", "Loka", "Marras", "Joulu" });
fi.setMonths(new String[] { "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" });
fi.setWeekdays(new String[] { "Ma", "Ti", "Ke", "To", "Pe", "La", "Su" });
final Lang en = new Lang();
en.setDecimalPoint(".");
en.setShortMonths(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
en.setMonths(new String[] { "January", "February", "March", "April", "May", "June", "Jule", "August", "September", "October", "November", "December" });
en.setWeekdays(new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" });
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Lumen syvyys Vikjafjellet-tunturilla, Norja");
configuration.getSubTitle().setText("Lokalisointiesimerkki");
configuration.getTooltip().setFormatter("");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setDateTimeLabelFormats(new DateTimeLabelFormats());
configuration.getxAxis().getDateTimeLabelFormats().setMonth("%B");
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Lumen syvyys (m)"));
yAxis.setMin(0);
DataSeries ls = new DataSeries();
PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
plotOptionsSpline.setDataLabels(new DataLabels(true));
plotOptionsSpline.setEnableMouseTracking(false);
plotOptionsSpline.getDataLabels().setFormatter("return Highcharts.dateFormat('%a %d %B',this.x);");
ls.setPlotOptions(plotOptionsSpline);
ls.setName("Talvi 2009-2010");
Object[][] data3 = getData3();
for (int i = 0; i < data3.length; i++) {
Object[] ds = data3[i];
DataSeriesItem item = new DataSeriesItem((Date) ds[0], (Double) ds[1]);
ls.add(item);
}
configuration.addSeries(ls);
chart.drawChart(configuration);
final Button enButton = new Button("English");
enButton.setId("en-button");
enButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ChartOptions.get().setLang(en);
}
});
final Button fiButton = new Button("Finnish");
fiButton.setId("fi-button");
fiButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ChartOptions.get().setLang(fi);
}
});
HorizontalLayout horizontalLayout = new HorizontalLayout(enButton, fiButton);
horizontalLayout.setSpacing(false);
VerticalLayout verticalLayout = new VerticalLayout(horizontalLayout, chart);
verticalLayout.setSpacing(false);
verticalLayout.setMargin(false);
return verticalLayout;
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class TimeSeriesIntervalUnit method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setSpacingRight(20);
configuration.getTitle().setText("Point interval test");
configuration.getxAxis().setType(AxisType.DATETIME);
final PlotOptionsSeries plotOptions = new PlotOptionsSeries();
try {
DateFormat df = new SimpleDateFormat("yyyyMMdd");
plotOptions.setPointStart(df.parse("20150101"));
} catch (ParseException e) {
e.printStackTrace();
}
plotOptions.setPointInterval(1);
plotOptions.setPointIntervalUnit(IntervalUnit.MONTH);
configuration.setPlotOptions(plotOptions);
ListSeries ls = new ListSeries();
ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
configuration.setSeries(ls);
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(false);
layout.setMargin(false);
layout.addComponent(chart);
layout.addComponent(new Button("one day interval", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
plotOptions.setPointInterval(24 * 3600 * 1000);
plotOptions.setPointIntervalUnit(null);
chart.drawChart();
}
}));
return layout;
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class TimeSeriesZoomable method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Color[] colors = getThemeColors();
Configuration configuration = chart.getConfiguration();
configuration.getChart().setZoomType(ZoomType.X);
configuration.getChart().setSpacingRight(20);
configuration.getTitle().setText("USD to EUR exchange rate from 2006 through 2008");
String title = Page.getCurrent().getWebBrowser().isTouchDevice() ? "Drag your finger over the plot to zoom in" : "Click and drag in the plot area to zoom in";
configuration.getSubTitle().setText(title);
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 = new Marker();
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.setMarker(marker);
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.Configuration in project charts by vaadin.
the class AreaSplineSite method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.AREASPLINE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Monthly supply and demand");
conf.setSubTitle("Last six months");
Legend legend = conf.getLegend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.LEFT);
legend.setFloating(true);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(150);
legend.setY(100);
Tooltip tooltip = conf.getTooltip();
tooltip.setValueSuffix("t");
tooltip.setShared(true);
XAxis xAxis = conf.getxAxis();
xAxis.setCategories("January", "February", "March", "April", "May", "June");
YAxis yAxis = conf.getyAxis();
yAxis.setTitle("Metric tons");
conf.addSeries(new ListSeries("Supply", 35, 28, 45, 60, 80, 74));
conf.addSeries(new ListSeries("Demand", 29, 11, 50, 63, 65, 61));
return chart;
}
use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.
the class LibraryData method getChart.
@Override
protected Component getChart() {
chart = new Chart(ChartType.BAR);
chart.setSizeFull();
Configuration config = chart.getConfiguration();
boolean inverted = config.getChart().getInverted();
config.getChart().setInverted(!inverted);
config.getLegend().setEnabled(false);
YAxis axis = new YAxis();
axis.setTitle("Pages");
config.addyAxis(axis);
series = new DataSeries();
config.setSeries(series);
updateChart();
return chart;
}
Aggregations