use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class CustomClock method getChart.
@Override
protected Chart getChart() {
final Chart chart = new Chart();
chart.setWidth("500px");
chart.setHeight("200px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.GAUGE);
configuration.getChart().setPlotBackgroundColor(null);
configuration.getChart().setPlotBackgroundImage(null);
configuration.getChart().setPlotBorderWidth(0);
configuration.getChart().setPlotShadow(false);
configuration.setTitle("The Vaadin Charts customised clock");
configuration.getCredits().setEnabled(false);
GradientColor gradient1 = GradientColor.createRadial(0.5, -0.4, 1.9);
gradient1.addColorStop(0.5, new SolidColor(255, 255, 255, 0.2));
gradient1.addColorStop(0.5, new SolidColor(200, 200, 200, 0.2));
Background[] background = new Background[2];
background[0] = new Background();
background[1] = new Background();
background[1].setBackgroundColor(gradient1);
background[1].setBorderWidth(1);
background[1].setOuterRadius("107%");
configuration.getPane().setBackground(background);
YAxis yAxis = configuration.getyAxis();
yAxis.getLabels().setDistance(-20);
yAxis.setMin(0);
yAxis.setMax(12);
yAxis.setLineWidth(0);
yAxis.setShowFirstLabel(false);
yAxis.setMinorTickInterval("auto");
yAxis.setMinorTickWidth(1);
yAxis.setMinorTickLength(5);
yAxis.setMinorTickPosition(TickPosition.INSIDE);
yAxis.setMinorGridLineWidth(0);
yAxis.setMinorTickColor(new SolidColor("#666"));
yAxis.setTickInterval(1);
yAxis.setTickWidth(2);
yAxis.setTickPosition(TickPosition.INSIDE);
yAxis.setTickLength(10);
yAxis.setTickColor(new SolidColor("#666"));
yAxis.setTitle(new AxisTitle("Powered by<br/>Vaadin Charts 2"));
yAxis.getTitle().setStyle(new Style());
yAxis.getTitle().getStyle().setColor(new SolidColor("#BBB"));
yAxis.getTitle().getStyle().setFontWeight(FontWeight.BOLD);
yAxis.getTitle().getStyle().setFontSize("8px");
yAxis.getTitle().getStyle().setLineHeight("10px");
yAxis.getTitle().setY(10);
final DataSeries series = new DataSeries();
final DataSeriesItem second = new DataSeriesItem();
second.setId("second");
second.setY(30);
second.setDial(new Dial());
second.getDial().setRadius("100%");
second.getDial().setBaseWidth(1);
second.getDial().setRearLength("20%");
second.getDial().setBackgroundColor(SolidColor.AQUA);
second.getDial().setBorderColor(SolidColor.RED);
second.getDial().setBorderWidth(10);
second.getDial().setTopWidth(8);
series.add(second);
PlotOptionsGauge plotOptionsGauge = new PlotOptionsGauge();
plotOptionsGauge.setDataLabels(new DataLabels(false));
configuration.setPlotOptions(plotOptionsGauge);
configuration.setSeries(series);
final Calendar cal = Calendar.getInstance();
runWhileAttached(chart, new Runnable() {
@Override
public void run() {
cal.setTimeInMillis(System.currentTimeMillis());
double secs = cal.get(Calendar.SECOND);
// disable animation when the second dial reaches 0
boolean animation = secs == 0 ? false : true;
configuration.getChart().setAnimation(animation);
second.setY(secs * (12.0 / 60.0));
series.update(second);
}
}, 1000, 15000);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class ErrorBarExample method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
Color[] colors = getThemeColors();
// Enable xy zooming, test also with touch devices
conf.getChart().setZoomType(ZoomType.XY);
conf.setTitle("Temperature vs Rainfall");
conf.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis primaryAxis = conf.getyAxis();
AxisTitle title = new AxisTitle("Temperature");
Style style = new Style();
style.setColor(colors[0]);
title.setStyle(style);
primaryAxis.setTitle(title);
Labels labels = new Labels();
labels.setFormatter("this.value + '°C'");
primaryAxis.setLabels(labels);
YAxis secondaryAxis = new YAxis();
conf.addyAxis(secondaryAxis);
title = new AxisTitle("Rainfall");
secondaryAxis.setTitle(title);
style = new Style();
style.setColor(colors[1]);
title.setStyle(style);
labels = new Labels();
labels.setFormatter("this.value + ' mm'");
labels.setStyle(style);
secondaryAxis.setLabels(labels);
secondaryAxis.setOpposite(true);
conf.getTooltip().setShared(true);
DataSeries rainfall = new DataSeries("Rainfall");
PlotOptionsColumn column = new PlotOptionsColumn();
column.setColor(colors[1]);
SeriesTooltip tooltip = new SeriesTooltip();
tooltip.setPointFormat("<span style='font-weight: bold; color: {series.color}'>{series.name}</span>: <b>{point.y:.1f} mm</b> ");
column.setTooltip(tooltip);
rainfall.setPlotOptions(column);
conf.addSeries(rainfall);
rainfall.setyAxis(secondaryAxis);
DataSeries rainfallError = new DataSeries("Rainfall");
conf.addSeries(rainfallError);
rainfallError.setyAxis(secondaryAxis);
PlotOptionsErrorbar rainErrorOptions = new PlotOptionsErrorbar();
tooltip = new SeriesTooltip();
tooltip.setPointFormat("(error range: {point.low}-{point.high} mm)<br/>");
rainErrorOptions.setTooltip(tooltip);
rainfallError.setPlotOptions(rainErrorOptions);
DataSeries temperature = new DataSeries("Temperature");
conf.addSeries(temperature);
PlotOptionsSpline tempOptions = new PlotOptionsSpline();
tempOptions.setColor(colors[0]);
tooltip = new SeriesTooltip();
tooltip.setPointFormat("<span style='font-weight: bold; color: {series.color}'>{series.name}</span>: <b>{point.y:.1f}°C");
tempOptions.setTooltip(tooltip);
temperature.setPlotOptions(tempOptions);
DataSeries temperatureErrors = new DataSeries("Temperature error");
conf.addSeries(temperatureErrors);
PlotOptionsErrorbar tempErrorOptions = new PlotOptionsErrorbar();
SolidColor green = new SolidColor("green");
tempErrorOptions.setStemColor(green);
tempErrorOptions.setWhiskerColor(green);
tooltip = new SeriesTooltip();
tooltip.setPointFormat("(error range: {point.low}-{point.high}°C)<br/>");
tempErrorOptions.setTooltip(tooltip);
temperatureErrors.setPlotOptions(tempErrorOptions);
// Populate series
for (Data d : DATA) {
DataSeriesItem item = new DataSeriesItem();
item.setY(d.rainfall);
rainfall.add(item);
item = new DataSeriesItem();
item.setLow(d.rainfallErrorLow);
item.setHigh(d.rainfallErrorHigh);
rainfallError.add(item);
item = new DataSeriesItem();
item.setY(d.temperature);
temperature.add(item);
item = new DataSeriesItem();
item.setLow(d.temperatureErrorLow);
item.setHigh(d.temperatureErrorHigh);
temperatureErrors.add(item);
}
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class AngularGauge method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setWidth("500px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.GAUGE);
configuration.getChart().setPlotBackgroundColor(null);
configuration.getChart().setPlotBackgroundImage(null);
configuration.getChart().setPlotBorderWidth(0);
configuration.getChart().setPlotShadow(false);
configuration.setTitle("Speedometer");
GradientColor gradient1 = GradientColor.createLinear(0, 0, 0, 1);
gradient1.addColorStop(0, new SolidColor("#FFF"));
gradient1.addColorStop(1, new SolidColor("#333"));
GradientColor gradient2 = GradientColor.createLinear(0, 0, 0, 1);
gradient2.addColorStop(0, new SolidColor("#333"));
gradient2.addColorStop(1, new SolidColor("#FFF"));
Background[] background = new Background[3];
background[0] = new Background();
background[0].setBackgroundColor(gradient1);
background[0].setBorderWidth(0);
background[0].setOuterRadius("109%");
background[1] = new Background();
background[1].setBackgroundColor(gradient2);
background[1].setBorderWidth(1);
background[1].setOuterRadius("107%");
background[2] = new Background();
background[2].setBackgroundColor(new SolidColor("#DDD"));
background[2].setBorderWidth(0);
background[2].setInnerRadius("103%");
background[2].setOuterRadius("105%");
configuration.getPane().setStartAngle(-150);
configuration.getPane().setEndAngle(150);
configuration.getPane().setBackground(background);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("km/h"));
yAxis.setMin(0);
yAxis.setMax(200);
yAxis.setMinorTickInterval("auto");
yAxis.setMinorTickWidth(1);
yAxis.setMinorTickLength(10);
yAxis.setMinorTickPosition(TickPosition.INSIDE);
yAxis.setMinorTickColor(new SolidColor("#666"));
yAxis.setGridLineWidth(0);
yAxis.setTickPixelInterval(30);
yAxis.setTickWidth(2);
yAxis.setTickPosition(TickPosition.INSIDE);
yAxis.setTickLength(10);
yAxis.setTickColor(new SolidColor("#666"));
Labels labels = new Labels();
labels.setStep(2);
labels.setRotationPerpendicular();
yAxis.setLabels(labels);
PlotBand[] plotBands = new PlotBand[3];
plotBands[0] = new PlotBand(0, 120, new SolidColor("#55BF3B"));
plotBands[1] = new PlotBand(120, 160, new SolidColor("#DDDF0D"));
plotBands[2] = new PlotBand(160, 200, new SolidColor("#DF5353"));
yAxis.setPlotBands(plotBands);
final ListSeries series = new ListSeries("Speed", 80);
PlotOptionsGauge plotOptions = new PlotOptionsGauge();
plotOptions.setTooltip(new SeriesTooltip());
plotOptions.getTooltip().setValueSuffix(" km/h");
series.setPlotOptions(plotOptions);
configuration.setSeries(series);
runWhileAttached(chart, new Runnable() {
Random r = new Random(0);
@Override
public void run() {
Integer oldValue = series.getData()[0].intValue();
Integer newValue = (int) (oldValue + (r.nextDouble() - 0.5) * 20.0);
series.updatePoint(0, newValue);
}
}, 3000, 12000);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class BoxPlotExample method getPlotBoxOptions.
private PlotOptionsBoxplot getPlotBoxOptions() {
PlotOptionsBoxplot options = new PlotOptionsBoxplot();
if (useCustomStyles.getValue()) {
// optional styling
options.setMedianColor(new SolidColor("cyan"));
options.setMedianWidth(1);
options.setStemColor(new SolidColor("green"));
options.setStemDashStyle(DashStyle.SHORTDOT);
options.setStemWidth(4);
options.setWhiskerColor(new SolidColor("magenta"));
options.setWhiskerLength("70");
options.setWhiskerWidth(5);
}
return options;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class SplineUpdatingEachSecondWithTwoLines method getChart.
@Override
protected Component getChart() {
final Random random = new Random();
final Chart chart = new Chart();
chart.setWidth("500px");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
configuration.getTitle().setText("Live random data");
XAxis xAxis = configuration.getxAxis();
xAxis.setType(AxisType.DATETIME);
xAxis.setTickPixelInterval(150);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Value"));
yAxis.setPlotLines(new PlotLine(0, 1, new SolidColor("#808080")));
configuration.getTooltip().setEnabled(false);
configuration.getLegend().setEnabled(false);
final DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsSpline());
series.setName("Random data");
for (int i = -19; i <= 0; i++) {
series.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
final DataSeries series2 = new DataSeries();
series2.setPlotOptions(new PlotOptionsSpline());
series2.setName("Random data");
for (int i = -19; i <= 0; i++) {
series2.add(new DataSeriesItem(System.currentTimeMillis() + i * 1000, random.nextDouble()));
}
runWhileAttached(chart, new Runnable() {
@Override
public void run() {
long x = System.currentTimeMillis();
series.add(new DataSeriesItem(x, random.nextDouble()), true, true);
series2.add(new DataSeriesItem(x, random.nextDouble()), true, true);
}
}, 1000, 1000);
configuration.setSeries(series, series2);
chart.drawChart(configuration);
return chart;
}
Aggregations