use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class LargeDataSet method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.getConfiguration().setTitle("Large data set");
// Force zoom and enable scrollbar
chart.getConfiguration().getxAxis().setMin(5000);
chart.getConfiguration().getScrollbar().setEnabled(true);
DataSeries series = new DataSeries();
Number[] data = TimeSeriesZoomable.USD_TO_EUR_EXCHANGE_RATES;
Random r = new Random(0);
int x = 0;
for (int j = 0; j < ROUNDS; j++) {
for (Number number : data) {
DataSeriesItem item;
if (xyPairs()) {
x += r.nextInt(4);
item = new DataSeriesItem(x, number);
} else {
// interval data (x == index of data point), performs better
// and consumes less memory/bandwidth
item = new DataSeriesItem();
item.setY(number);
}
/*
* Note, with large datasets, avoid settings like
* item.setColor(myColorX), or item.setName(myName) for data
* items. Without them the framework is able to optimize the
* rendering and can survive from rather large datasets.
*
* Also note, that if data set is very large, the library might
* ignore it if there are custom settings for data items. This
* threshold is called turboThreshHold in plot options. See
* example below.
*/
// item.setName("x " + x);
series.add(item);
}
}
/*
* If you play with this example your might try uncomment next line to
* keep the amount of transfered data sane. You might also try to
* increase the ROUNDS to increase the input data. By default commented
* out to stress client side performance
*/
// reduce(series, 1000);
/*
* If data can contain high/low peaks, one can use more sophisticated
* algorithms
*/
// ramerDouglasPeuckerReduce(series, 300);
chart.getConfiguration().setSeries(series);
PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
// Showing points with thousands of data items looks odd (on top of each
// other), also renders faster without markers
plotOptionsLine.setMarker(new Marker(false));
// To render shadow, library must create additional element, without it
// performance will be better
plotOptionsLine.setShadow(false);
plotOptionsLine.setAnimation(false);
/*
* If developers need to use large data sets and point specific
* settings, they can override the default turbo threshold. Here we set
* it to 200000 (default 1000). Turbo threshold is configuration that
* works as a "sanity threshold" so that old browsers wont drop to their
* knees under load. Without this Vaadin Charts might not render chart
* if data items have e.g. name set.
*/
plotOptionsLine.setTurboThreshold(200000);
chart.getConfiguration().setPlotOptions(plotOptionsLine);
return chart;
}
use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class SplineWithItemLabels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.SPLINE);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Wind speed during two days");
configuration.getSubTitle().setText("October 6th and 7th 2009 at two locations in Vik i Sogn, Norway");
configuration.getxAxis().setType(AxisType.DATETIME);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Wind speed (m/s)"));
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
configuration.setPlotOptions(plotOptions);
plotOptions.setMarker(new Marker(false));
plotOptions.setPointInterval(ONE_HOUR);
plotOptions.setPointStart(toDate("2009,09,06"));
DataSeries ds = new DataSeries();
ds.setName("Hestavollane");
ds.setData(4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 7.4, 6.9, 7.1, 7.9, 7.9, 7.5, 6.7, 7.7, 7.7, 7.4, 7.0, 7.1, 5.8, 5.9, 7.4, 8.2, 8.5, 9.4, 8.1, 10.9, 10.4, 10.9, 12.4, 12.1, 9.5, 7.5, 7.1, 7.5, 8.1, 6.8, 3.4, 2.1, 1.9, 2.8, 2.9, 1.3, 4.4, 4.2, 3.0, 3.0);
DataSeriesItem item = new DataSeriesItem();
item.setY(4.51);
item.setDataLabels(getDataLabels());
ds.add(item);
configuration.addSeries(ds);
ds = new DataSeries();
ds.setName("Voll");
ds.setData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0, 0.0, 0.4, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6, 1.2, 1.7, 0.7, 2.9, 4.1, 2.6, 3.7, 3.9, 1.7, 2.3, 3.0, 3.3, 4.8, 5.0, 4.8, 5.0, 3.2, 2.0, 0.9, 0.4, 0.3, 0.5, 0.4);
item = new DataSeriesItem();
item.setY(0.27);
item.setDataLabels(getDataLabels());
ds.add(item);
configuration.addSeries(ds);
return chart;
}
use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class ChartTypes method chartTypesScatterMarkerPropertiesSnippet1.
public void chartTypesScatterMarkerPropertiesSnippet1() {
double x = 1.0;
double y = 1.2;
double z = 1.45;
DataSeries series = new DataSeries();
DataSeriesItem point = new DataSeriesItem(x, y);
Marker marker = new Marker();
// Set line width and color
// Normally zero width
marker.setLineWidth(1);
marker.setLineColor(SolidColor.BLACK);
// Set RGB fill color
int level = (int) Math.round((1 - z) * 127);
marker.setFillColor(new SolidColor(255 - level, 0, level));
point.setMarker(marker);
marker.setRadius((z + 1) * 5);
series.add(point);
}
use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class ChartTypes method chartTypesScatterMarkerSymbolsSnippet2.
public void chartTypesScatterMarkerSymbolsSnippet2() {
Marker marker = new Marker();
String url = VaadinServlet.getCurrent().getServletContext().getContextPath() + "/VAADIN/themes/mytheme/img/smiley.png";
marker.setSymbol(new MarkerSymbolUrl(url));
}
use of com.vaadin.addon.charts.model.Marker in project charts by vaadin.
the class BasicUse method basicUse3dDistanceSnippet2.
public void basicUse3dDistanceSnippet2() {
double x = 3.2;
double z = 3.3;
double y = 2.3;
Options3d options3d = new Options3d();
DataSeriesItem3d item = new DataSeriesItem3d(x, y, z * options3d.getDepth().doubleValue());
double distance = 43.2;
// Grayness
int gr = (int) (distance * 75);
Marker marker = new Marker(true);
marker.setRadius(1 + 10 / distance);
marker.setFillColor(new SolidColor(gr, gr, gr));
item.setMarker(marker);
DataSeries series = new DataSeries();
series.add(item);
}
Aggregations