use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class ChartWithExternalDataProviderWithChangingData method createChart.
public static Chart createChart(Series ds) {
final Chart chart = new Chart(ChartType.AREA);
final Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Data from Vaadin DataProvider");
configuration.getLegend().setEnabled(false);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Data values"));
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, new SolidColor("#4572A7"));
fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
plotOptions.setFillColor(fillColor);
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Marker marker = plotOptions.getMarker();
marker.setEnabled(false);
Hover hoverState = new Hover(true);
hoverState.setRadius(5);
hoverState.setLineWidth(1);
marker.getStates().setHover(hoverState);
plotOptions.getStates().setHover(new Hover(true));
plotOptions.setShadow(false);
configuration.setPlotOptions(plotOptions);
configuration.setSeries(ds);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class DataProviderWithLotsOfData method createChart.
public static Chart createChart(Series ds) {
final Chart chart = new Chart(ChartType.AREA);
final Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("Data from Vaadin DataProvider");
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, new SolidColor("#4572A7"));
fillColor.addColorStop(1, new SolidColor(2, 0, 0, 0));
plotOptions.setFillColor(fillColor);
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Marker marker = plotOptions.getMarker();
marker.setEnabled(false);
Hover hoverState = new Hover(true);
hoverState.setRadius(5);
hoverState.setLineWidth(1);
marker.getStates().setHover(hoverState);
plotOptions.getStates().setHover(new Hover(true));
plotOptions.setShadow(false);
configuration.setPlotOptions(plotOptions);
configuration.setSeries(ds);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class VUMeter method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setWidth("600px");
chart.setHeight("200px");
GradientColor gradient = GradientColor.createLinear(0, 0, 0, 1);
gradient.addColorStop(0, new SolidColor("#FFF4C6"));
gradient.addColorStop(0.3, new SolidColor("#FFFFFF"));
gradient.addColorStop(1, new SolidColor("#FFF4C6"));
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.GAUGE);
configuration.getChart().setPlotBackgroundColor(gradient);
configuration.getChart().setPlotBackgroundImage(null);
configuration.getChart().setPlotBorderWidth(1);
configuration.setTitle("VU meter");
Pane pane1 = new Pane(-45, 45);
Pane pane2 = new Pane(-45, 45);
pane1.setBackground(new Background[] {});
pane2.setBackground(new Background[] {});
pane1.setCenter("25%", "145%");
pane2.setCenter("75%", "145%");
pane1.setSize("300px");
pane2.setSize("300");
configuration.addPane(pane1);
configuration.addPane(pane2);
PlotBand plotBand1 = new PlotBand(0, 6, new SolidColor("#C02316"));
plotBand1.setInnerRadius("100%");
plotBand1.setOuterRadius("105%");
PlotBand plotBand2 = new PlotBand(0, 6, new SolidColor("#C02316"));
plotBand2.setInnerRadius("100%");
plotBand2.setOuterRadius("105%");
YAxis yAxis = new YAxis();
yAxis.setPane(pane1);
yAxis.setTitle("VU<br/><span style=\"font-size:8px\">Channel A</span>");
yAxis.getTitle().setY(-40);
yAxis.setMin(-20);
yAxis.setMax(6);
yAxis.setTickPosition(TickPosition.OUTSIDE);
yAxis.setMinorTickPosition(TickPosition.OUTSIDE);
Labels labels = new Labels();
labels.setDistance(20);
labels.setRotationPerpendicular();
yAxis.setLabels(labels);
yAxis.setPlotBands(plotBand1);
YAxis yAxis2 = new YAxis();
yAxis2.setPane(pane2);
yAxis2.setTitle("VU<br/><span style=\"font-size:8px\">Channel B</span>");
yAxis2.getTitle().setY(-40);
yAxis2.setMin(-20);
yAxis2.setMax(6);
yAxis2.setTickPosition(TickPosition.OUTSIDE);
yAxis2.setMinorTickPosition(TickPosition.OUTSIDE);
labels = new Labels();
labels.setDistance(20);
labels.setRotationPerpendicular();
yAxis2.setLabels(labels);
yAxis2.setPlotBands(plotBand2);
configuration.addyAxis(yAxis);
configuration.addyAxis(yAxis2);
PlotOptionsGauge gauge = new PlotOptionsGauge();
gauge.setDataLabels(new DataLabels(false));
gauge.setDial(new Dial());
gauge.getDial().setRadius("100%");
configuration.setPlotOptions(gauge);
final ListSeries series1 = new ListSeries(-20);
final ListSeries series2 = new ListSeries(-20);
series1.setyAxis(0);
series2.setyAxis(1);
configuration.setSeries(series1, series2);
runWhileAttached(chart, new Runnable() {
final Random r = new Random(0);
@Override
public void run() {
double left = series1.getData()[0].doubleValue();
double inc = (r.nextDouble() - 0.5) * 3;
double leftVal = left + inc;
double rightVal = leftVal + inc / 3;
if (leftVal < -20 || leftVal > 6) {
leftVal = left - inc;
}
if (rightVal < -20 || rightVal > 6) {
rightVal = leftVal;
}
series1.updatePoint(0, leftVal);
series2.updatePoint(0, rightVal);
}
}, 500, 12000);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class PieWithNativeDrilldown method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.PIE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Browser market share, April, 2011");
conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
conf.getLegend().setEnabled(false);
PlotOptionsPie column = new PlotOptionsPie();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
conf.setPlotOptions(column);
Tooltip tooltip = new Tooltip();
tooltip.setHeaderFormat("<span style=\"font-size:11px\">{series.name}</span><br>");
tooltip.setPointFormat("<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>");
conf.setTooltip(tooltip);
DataSeries series = new DataSeries();
series.setName("Browser brands");
DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
DataSeries drillSeries = new DataSeries("MSIE versions");
drillSeries.setId("MSIE");
String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
drillSeries.setData(categories, ys);
series.addItemWithDrilldown(item, drillSeries);
item = new DataSeriesItem("Firefox", 21.63);
drillSeries = new DataSeries("Firefox versions");
drillSeries.setId("Firefox");
categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
drillSeries.setData(categories, ys);
series.addItemWithDrilldown(item, drillSeries);
item = new DataSeriesItem("Chrome", 11.94);
drillSeries = new DataSeries("Chrome versions");
drillSeries.setId("Chrome");
categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
drillSeries.setData(categories, ys);
series.addItemWithDrilldown(item, drillSeries);
item = new DataSeriesItem("Safari", 7.15);
series.add(item);
item = new DataSeriesItem("Opera", 2.14);
drillSeries = new DataSeries("Opera versions");
drillSeries.setId("Opera");
categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
ys = new Number[] { 0.12, 0.37, 1.65 };
drillSeries.setData(categories, ys);
series.addItemWithDrilldown(item, drillSeries);
conf.addSeries(series);
Drilldown drilldown = conf.getDrilldown();
Style style = new Style();
style.setFontWeight(BOLD);
style.setColor(FIREBRICK);
style.setFontSize("16px");
drilldown.setActiveDataLabelStyle(style);
DrillUpButton button = drilldown.getDrillUpButton();
button.setRelativeTo(SPACINGBOX);
DrillUpButtonTheme theme = new DrillUpButtonTheme();
GradientColor gradient1 = GradientColor.createLinear(0, 0, 0, 1);
gradient1.addColorStop(0, ALICEBLUE);
gradient1.addColorStop(1, ANTIQUEWHITE);
theme.setFill(gradient1);
button.setTheme(theme);
return chart;
}
use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.
the class PieWithCustomBorder method createRadialGradient.
/**
* Creates a radial gradient with the specified start and end colors.
*/
private GradientColor createRadialGradient(SolidColor start, SolidColor end) {
GradientColor color = GradientColor.createRadial(0.5, 0.3, 0.7);
color.addColorStop(0, start);
color.addColorStop(1, end);
return color;
}
Aggregations