use of com.vaadin.addon.charts.model.style.Style in project charts by vaadin.
the class RangeSelectorCustomDateParser method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
chart.setTimeline(true);
Configuration configuration = chart.getConfiguration();
YAxis yAxis = new YAxis();
PlotLine plotLine = new PlotLine();
plotLine.setValue(2);
plotLine.setWidth(2);
plotLine.setColor(SolidColor.SILVER);
yAxis.setPlotLines(plotLine);
configuration.addyAxis(yAxis);
DataSeries aaplSeries = new DataSeries();
for (StockPrices.PriceData data : StockPrices.fetchAaplPriceWithTime()) {
DataSeriesItem item = new DataSeriesItem();
item.setX(data.getDate());
item.setY(data.getPrice());
aaplSeries.add(item);
}
configuration.setSeries(aaplSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(4);
ButtonTheme theme = new ButtonTheme();
Style style = new Style();
style.setColor(new SolidColor("#0766d8"));
style.setFontWeight(FontWeight.BOLD);
theme.setStyle(style);
rangeSelector.setButtonTheme(theme);
Style inputStyle = new Style();
inputStyle.setColor(new SolidColor("#0766d8"));
inputStyle.setFontWeight(FontWeight.BOLD);
rangeSelector.setInputStyle(inputStyle);
rangeSelector.setInputDateFormat("%H:%M:%S.%L");
rangeSelector.setInputEditDateFormat("%H:%M:%S.%L");
// All the data is for 2009 Jan 28, so we don't bother to parse date only parse time
rangeSelector.setInputDateParser("function(value) {" + "value = value.split(/[:\\.]/);\n" + "return Date.UTC(\n" + " 2009,\n" + " 0,\n" + " 28,\n" + " parseInt(value[0], 10),\n" + " parseInt(value[1], 10),\n" + " parseInt(value[2], 10),\n" + " parseInt(value[3], 10)" + ");}");
configuration.setRangeSelector(rangeSelector);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.Style in project charts by vaadin.
the class TreemapWithLevels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.TREEMAP);
PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.STRIPES);
plotOptions.setAlternateStartingDirection(true);
Level level1 = new Level();
level1.setLevel(1);
level1.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SLICEANDDICE);
DataLabels dataLabels = new DataLabels();
dataLabels.setEnabled(true);
dataLabels.setAlign(HorizontalAlign.LEFT);
dataLabels.setVerticalAlign(VerticalAlign.TOP);
Style style = new Style();
style.setFontSize("15px");
style.setFontWeight(FontWeight.BOLD);
dataLabels.setStyle(style);
level1.setDataLabels(dataLabels);
plotOptions.setLevels(level1);
TreeSeries series = createSeries();
series.setPlotOptions(plotOptions);
chart.getConfiguration().addSeries(series);
chart.getConfiguration().setTitle("Fruit consumption");
return chart;
}
use of com.vaadin.addon.charts.model.style.Style in project charts by vaadin.
the class ValoDarkTheme method setDataLabelsDefaults.
protected void setDataLabelsDefaults(AbstractDataLabels labels) {
labels.setColor(TEXT_COLOR);
labels.setStyle(new Style());
labels.getStyle().setFontFamily(DEFAULT_FONT_FAMILIES);
labels.getStyle().setFontSize("12px");
}
use of com.vaadin.addon.charts.model.style.Style in project charts by vaadin.
the class ValoLightTheme method setDataLabelsDefaults.
protected void setDataLabelsDefaults(AbstractDataLabels labels) {
labels.setColor(TEXT_COLOR);
labels.setStyle(new Style());
labels.getStyle().setFontFamily(DEFAULT_FONT_FAMILIES);
labels.getStyle().setFontSize("12px");
}
use of com.vaadin.addon.charts.model.style.Style in project charts by vaadin.
the class SplineWithPlotBands method getChart.
@SuppressWarnings("deprecation")
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.SPLINE);
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)"));
yAxis.setMin(0);
yAxis.setMinorGridLineWidth(0);
yAxis.setGridLineWidth(0);
// disable alternate grid color from Vaadin theme, disturbs
// demonstrating plotbands
yAxis.setAlternateGridColor(TRANSPARENT);
Style style = new Style();
style.setColor(LIGHT_GRAY);
final PlotBand lightAir = new PlotBand();
lightAir.setFrom(0.3);
lightAir.setTo(1.5);
lightAir.setColor(LIGHT_BLUE);
lightAir.setLabel(new Label("Light air"));
lightAir.getLabel().setStyle(style);
final PlotBand lightBreeze = new PlotBand();
lightBreeze.setFrom(1.5);
lightBreeze.setTo(3.3);
lightBreeze.setColor(TRANSPARENT);
lightBreeze.setLabel(new Label("Light breeze"));
lightBreeze.getLabel().setStyle(style);
final PlotBand gentleBreeze = new PlotBand();
gentleBreeze.setFrom(3.3);
gentleBreeze.setTo(5.5);
gentleBreeze.setColor(LIGHT_BLUE);
gentleBreeze.setLabel(new Label("Gentle breeze"));
gentleBreeze.getLabel().setStyle(style);
final PlotBand moderateBreeze = new PlotBand();
moderateBreeze.setFrom(5.5);
moderateBreeze.setTo(8);
moderateBreeze.setColor(TRANSPARENT);
moderateBreeze.setLabel(new Label("Moderate breeze"));
moderateBreeze.getLabel().setStyle(style);
final PlotBand freshBreeze = new PlotBand();
freshBreeze.setFrom(8);
freshBreeze.setTo(11);
freshBreeze.setColor(LIGHT_BLUE);
freshBreeze.setLabel(new Label("Fresh breeze"));
freshBreeze.getLabel().setStyle(style);
final PlotBand strongBreeze = new PlotBand();
strongBreeze.setFrom(11);
strongBreeze.setTo(14);
strongBreeze.setColor(TRANSPARENT);
strongBreeze.setLabel(new Label("Strong breeze"));
strongBreeze.getLabel().setStyle(style);
final PlotBand highWind = new PlotBand();
highWind.setFrom(14);
highWind.setTo(15);
highWind.setColor(LIGHT_BLUE);
highWind.setLabel(new Label("High wind"));
highWind.getLabel().setStyle(style);
yAxis.setPlotBands(lightAir, lightBreeze, gentleBreeze, moderateBreeze, freshBreeze, strongBreeze, highWind);
configuration.getTooltip().setFormatter("Highcharts.dateFormat('%e. %b %Y, %H:00', this.x) +': '+ this.y +' m/s'");
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
configuration.setPlotOptions(plotOptions);
plotOptions.setMarker(new Marker(false));
plotOptions.getMarker().setLineWidth(4);
plotOptions.getMarker().setSymbol(MarkerSymbolEnum.CIRCLE);
States states = new States();
Hover hover = new Hover(true);
hover.setRadius(5);
hover.setLineWidth(1);
states.setHover(hover);
plotOptions.getMarker().setStates(states);
plotOptions.setPointInterval(ONE_HOUR);
LocalDate date = LocalDate.of(2009, 9, 6);
plotOptions.setPointStart(date.atStartOfDay().toInstant(ZoneOffset.UTC));
ListSeries ls = new ListSeries();
ls.setName("Hestavollane");
ls.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);
configuration.addSeries(ls);
ls = new ListSeries();
ls.setName("Voll");
ls.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);
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
Aggregations