use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicUse method basicUseMixed.
public void basicUseMixed() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
// A data series as column graph
DataSeries series1 = new DataSeries();
PlotOptionsColumn options1 = new PlotOptionsColumn();
options1.setColor(SolidColor.BLUE);
series1.setPlotOptions(options1);
series1.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
conf.addSeries(series1);
// A data series as line graph
ListSeries series2 = new ListSeries("Diameter");
PlotOptionsLine options2 = new PlotOptionsLine();
options2.setColor(SolidColor.RED);
series2.setPlotOptions(options2);
series2.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
conf.addSeries(series2);
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class Events method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
final Configuration configuration = chart.getConfiguration();
configuration.setTitle("Click to add point");
configuration.getChart().setType(ChartType.SPLINE);
final ListSeries series = new ListSeries(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(series);
chart.drawChart(configuration);
chart.addChartClickListener(new ChartClickListener() {
@Override
public void onClick(ChartClickEvent event) {
double getyAxisValue = event.getyAxisValue();
series.addData(getyAxisValue);
}
});
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class MasterDetailChart method getChart.
@Override
protected Component getChart() {
VerticalLayout lo = new VerticalLayout();
lo.setSpacing(false);
lo.setMargin(false);
lo.setWidth("100%");
lo.setHeight("600px");
final Chart masterChart = getMasterChart();
final Chart detailChart = getDetailChart();
masterChart.addChartSelectionListener(new ChartSelectionListener() {
@Override
public void onSelection(ChartSelectionEvent event) {
long start = event.getSelectionStart().longValue();
long end = event.getSelectionEnd().longValue();
// set plot band to highlight the selection on the master chart
PlotBand plotBand1 = new PlotBand();
PlotBand plotBand2 = new PlotBand();
plotBand1.setColor(new SolidColor(0, 0, 0, 0.2));
plotBand2.setColor(new SolidColor(0, 0, 0, 0.2));
plotBand1.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
plotBand1.setTo(start);
plotBand2.setFrom(end);
plotBand2.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
masterChart.getConfiguration().getxAxis().setPlotBands(plotBand1, plotBand2);
masterChart.drawChart();
List<Number> list = MasterDetailChart.this.getPartialList(start, end);
Configuration configuration = detailChart.getConfiguration();
configuration.getChart().setAnimation(false);
ListSeries detailData = (ListSeries) configuration.getSeries().get(0);
PlotOptionsLine plotOptionsLine = (PlotOptionsLine) detailData.getPlotOptions();
plotOptionsLine.setPointStart(start);
detailData.setData(list);
detailChart.drawChart(configuration);
}
});
lo.addComponent(detailChart);
lo.addComponent(masterChart);
return lo;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class MasterDetailChart method getDetailChart.
private Chart getDetailChart() {
Chart detailChart = new Chart();
detailChart.setHeight("100%");
detailChart.setWidth("100%");
Configuration configuration = detailChart.getConfiguration();
configuration.getCredits().setEnabled(false);
configuration.setTitle("Historical USD to EUR Exchange Rate");
configuration.setSubTitle("Select an area by dragging across the lower chart");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getyAxis().setTitle(new AxisTitle((String) null));
configuration.getyAxis().setMinRange(0.1);
configuration.getTooltip().setFormatter("function() {var point = this.points[0];return '<b>'+ point.series.name +'</b><br/>'+Highcharts.dateFormat('%A %B %e %Y', this.x) + ':<br/>'+'1 USD = '+ Highcharts.numberFormat(point.y, 2) +' EUR';}");
configuration.getTooltip().setShared(true);
PlotOptionsLine series = new PlotOptionsLine();
series.setPointInterval(DAY_IN_MILLIS);
configuration.setPlotOptions(series);
States states = new States();
Hover hover = new Hover();
hover.setRadius(3);
states.setHover(hover);
Marker marker = series.getMarker();
marker.setEnabled(false);
marker.setStates(states);
marker.setRadius(2);
series.setAnimation(false);
ListSeries seriesList = new ListSeries();
PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
plotOptionsLine.setPointInterval(DAY_IN_MILLIS);
plotOptionsLine.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
seriesList.setPlotOptions(plotOptionsLine);
seriesList.setName("USD to EUR");
seriesList.setData(FULL_DEMO_DATA_SET);
configuration.getLegend().setEnabled(false);
configuration.setExporting(false);
configuration.addSeries(seriesList);
detailChart.drawChart(configuration);
return detailChart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class MasterDetailChart method getMasterChart.
private Chart getMasterChart() {
Chart masterChart = new Chart(ChartType.AREA);
masterChart.setHeight("80px");
masterChart.setWidth("100%");
masterChart.setId("master-chart");
Configuration configuration = masterChart.getConfiguration();
configuration.getChart().setZoomType(ZoomType.X);
configuration.getChart().setReflow(false);
configuration.getChart().setBorderWidth(0);
configuration.getChart().setBackgroundColor(null);
configuration.getChart().setMarginLeft(50);
configuration.getChart().setMarginRight(20);
configuration.getTitle().setText("");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setShowLastLabel(true);
configuration.getxAxis().setMinRange(14 * DAY_IN_MILLIS);
configuration.getxAxis().setTitle(new AxisTitle(""));
PlotBand mask = new PlotBand();
mask.setColor(new SolidColor(0, 0, 0, 0.2));
mask.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
mask.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
configuration.getxAxis().setPlotBands(mask);
YAxis yAxis = configuration.getyAxis();
yAxis.setGridLineWidth(0);
yAxis.setLabels(new Labels(false));
yAxis.setTitle(new AxisTitle(""));
yAxis.setMin(0.6);
yAxis.setShowFirstLabel(false);
configuration.getTooltip().setEnabled(false);
configuration.getLegend().setEnabled(false);
configuration.getCredits().setEnabled(false);
PlotOptionsArea plotOptions = new PlotOptionsArea();
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Hover hover = new Hover();
hover.setLineWidth(1);
States states = new States();
states.setHover(hover);
plotOptions.setStates(states);
plotOptions.setEnableMouseTracking(false);
plotOptions.setAnimation(false);
configuration.setPlotOptions(plotOptions);
ListSeries ls = new ListSeries();
PlotOptionsArea masterPlotOptions = new PlotOptionsArea();
GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
fillColor.addColorStop(0, new SolidColor(69, 114, 167, 1));
fillColor.addColorStop(1, new SolidColor(69, 114, 167, 0.5));
masterPlotOptions.setFillColor(fillColor);
masterPlotOptions.setPointInterval(24 * 3600 * 1000);
masterPlotOptions.setMarker(new Marker(false));
masterPlotOptions.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
ls.setPlotOptions(masterPlotOptions);
ls.setName("USD to EUR");
ls.setData(FULL_DEMO_DATA_SET);
configuration.addSeries(ls);
masterChart.drawChart(configuration);
return masterChart;
}
Aggregations