use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class BasicLineWithCustomCrosshairs method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setId("chart");
Configuration config = chart.getConfiguration();
config.setTitle("Customized crosshairs");
Crosshair xCrossHair = new Crosshair();
xCrossHair.setColor(SolidColor.BLACK);
xCrossHair.setDashStyle(DashStyle.SOLID);
xCrossHair.setWidth(10);
xCrossHair.setZIndex(0);
config.getxAxis().setCrosshair(xCrossHair);
Crosshair yCrossHair = new Crosshair();
yCrossHair.setColor(new SolidColor("#880000"));
yCrossHair.setDashStyle(DashStyle.DOT);
yCrossHair.setWidth(5);
yCrossHair.setZIndex(1);
config.getyAxis().setCrosshair(yCrossHair);
ListSeries ls = new ListSeries();
ls.setName("Data");
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);
config.setSeries(ls);
chart.drawChart(config);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class BasicLineWithRedGridLines method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.LINE);
configuration.getChart().setMarginRight(130);
configuration.getChart().setMarginBottom(25);
configuration.getTitle().setText("Monthly Average Temperature");
configuration.getSubTitle().setText("Source: WorldClimate.com");
configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
YAxis yAxis = configuration.getyAxis();
yAxis.setMin(-5d);
yAxis.setTitle(new AxisTitle("Temperature (°C)"));
yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
yAxis.setGridLineColor(new SolidColor("red"));
yAxis.setGridLineDashStyle(DashStyle.DASHDOT);
yAxis.setGridLineWidth(3);
XAxis xAxis = configuration.getxAxis();
xAxis.setGridLineColor(new SolidColor(0, 255, 0, 0.5));
xAxis.setGridLineWidth(4);
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setDataLabels(new DataLabels(true));
configuration.setPlotOptions(plotOptions);
ListSeries ls = new ListSeries();
ls.setName("Tokyo");
ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
configuration.addSeries(ls);
ls = new ListSeries();
ls.setName("New York");
ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
configuration.addSeries(ls);
ls = new ListSeries();
ls.setName("Berlin");
ls.setData(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0);
configuration.addSeries(ls);
ls = new ListSeries();
ls.setName("London");
ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class Clock 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 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();
Labels labels = new Labels();
labels.setDistance(-20);
yAxis.setLabels(labels);
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"));
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 hour = new DataSeriesItem();
final DataSeriesItem minute = new DataSeriesItem();
final DataSeriesItem second = new DataSeriesItem();
hour.setId("hour");
hour.setY(10);
hour.setDial(new Dial());
hour.getDial().setRadius("60%");
hour.getDial().setBaseWidth(4);
hour.getDial().setRearLength("0%");
hour.getDial().setBaseLength("95%");
minute.setId("minute");
minute.setY(10);
minute.setDial(new Dial());
minute.getDial().setBaseLength("95%");
minute.getDial().setRearLength("0%");
second.setId("second");
second.setY(30);
second.setDial(new Dial());
second.getDial().setRadius("100%");
second.getDial().setBaseWidth(1);
second.getDial().setRearLength("20%");
series.add(hour);
series.add(minute);
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 hours = cal.get(Calendar.HOUR);
double mins = cal.get(Calendar.MINUTE);
double secs = cal.get(Calendar.SECOND);
// disable animation when the second dial reaches 0
boolean animation = secs == 0 ? false : true;
configuration.getChart().setAnimation(animation);
hour.setY(hours + (mins / 60.0));
minute.setY(mins * (12.0 / 60.0) + secs * (12.0 / 3600.0));
second.setY(secs * (12.0 / 60.0));
series.update(hour);
series.update(minute);
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 ColumnRangeResourceUsage method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMNRANGE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Resource usage");
conf.getChart().setInverted(true);
XAxis xAxis = new XAxis();
xAxis.setCategories("Printer", "Coffee mahine");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle("Time");
yAxis.setType(AxisType.DATETIME);
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name +': '+ Highcharts.dateFormat('%H:%M', this.point.low) + ' - ' + Highcharts.dateFormat('%H:%M', this.point.high)");
conf.setTooltip(tooltip);
PlotOptionsColumnrange columnRange = new PlotOptionsColumnrange();
columnRange.setGrouping(false);
DataLabelsRange dataLabels = new DataLabelsRange(true);
dataLabels.setFormatter("this.y == this.point.low ? '' : this.series.name");
dataLabels.setInside(true);
dataLabels.setColor(new SolidColor("white"));
columnRange.setDataLabels(dataLabels);
conf.setPlotOptions(columnRange);
Calendar instance = Calendar.getInstance();
instance.set(Calendar.MILLISECOND, 0);
instance.set(2013, 6, 7, 12, 00, 00);
DataSeries a = new DataSeries();
a.setName("Team Alpha");
PlotOptionsColumnrange o = new PlotOptionsColumnrange();
o.setColor(new SolidColor(255, 60, 125, 0.8));
a.setPlotOptions(o);
DataSeries b = new DataSeries();
o = new PlotOptionsColumnrange();
o.setColor(new SolidColor(60, 125, 255, 0.8));
b.setPlotOptions(o);
b.setName("Team Beta");
DataSeriesItem item;
item = new DataSeriesItem();
item.setName("Printer");
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 3);
item.setHigh(instance.getTimeInMillis());
a.add(item);
item = new DataSeriesItem();
item.setName("Printer");
instance.roll(Calendar.HOUR_OF_DAY, 1);
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 1);
item.setHigh(instance.getTimeInMillis());
b.add(item);
instance.set(2013, 6, 7, 12, 00, 00);
item = new DataSeriesItem();
item.setName("Coffee mahine");
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 2);
item.setHigh(instance.getTimeInMillis());
b.add(item);
item = new DataSeriesItem();
item.setName("Coffee mahine");
instance.roll(Calendar.HOUR_OF_DAY, -1);
item.setLow(instance.getTimeInMillis());
instance.roll(Calendar.HOUR_OF_DAY, 4);
item.setHigh(instance.getTimeInMillis());
a.add(item);
conf.setSeries(a, b);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class TreeMapPointClick method createSeries.
private TreeSeries createSeries() {
TreeSeries series = new TreeSeries();
TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
apples.setColor(new SolidColor("#EC2500"));
TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
bananas.setColor(new SolidColor("#ECE100"));
TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
oranges.setColor(new SolidColor("#EC9800"));
TreeSeriesItem anneA = new TreeSeriesItem("Anne", apples, 5);
TreeSeriesItem rickA = new TreeSeriesItem("Rick", apples, 3);
TreeSeriesItem peterA = new TreeSeriesItem("Peter", apples, 4);
TreeSeriesItem anneB = new TreeSeriesItem("Anne", bananas, 4);
TreeSeriesItem rickB = new TreeSeriesItem("Rick", bananas, 10);
TreeSeriesItem peterB = new TreeSeriesItem("Peter", bananas, 1);
TreeSeriesItem anneO = new TreeSeriesItem("Anne", oranges, 1);
TreeSeriesItem rickO = new TreeSeriesItem("Rick", oranges, 3);
TreeSeriesItem peterO = new TreeSeriesItem("Peter", oranges, 3);
TreeSeriesItem susanne = new TreeSeriesItem("Susanne", 2);
susanne.setParent("Kiwi");
susanne.setColor(new SolidColor("#9EDE00"));
series.addAll(apples, bananas, oranges, anneA, rickA, peterA, anneB, rickB, peterB, anneO, rickO, peterO, susanne);
return series;
}
Aggregations