use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class DeclarativeTreemapWithLevels 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;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class MasterDetailChart method getChart.
@Override
protected Component getChart() {
VerticalLayout lo = new VerticalLayout();
lo.setSpacing(false);
lo.setMargin(false);
lo.setWidth("100%");
lo.setHeight("600px");
final Chart masterChart = getMasterChart();
final Chart detailChart = getDetailChart();
masterChart.addChartSelectionListener(new ChartSelectionListener() {
@Override
public void onSelection(ChartSelectionEvent event) {
long start = event.getSelectionStart().longValue();
long end = event.getSelectionEnd().longValue();
// set plot band to highlight the selection on the master chart
PlotBand plotBand1 = new PlotBand();
PlotBand plotBand2 = new PlotBand();
plotBand1.setColor(new SolidColor(0, 0, 0, 0.2));
plotBand2.setColor(new SolidColor(0, 0, 0, 0.2));
plotBand1.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
plotBand1.setTo(start);
plotBand2.setFrom(end);
plotBand2.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
masterChart.getConfiguration().getxAxis().setPlotBands(plotBand1, plotBand2);
masterChart.drawChart();
List<Number> list = MasterDetailChart.this.getPartialList(start, end);
Configuration configuration = detailChart.getConfiguration();
configuration.getChart().setAnimation(false);
ListSeries detailData = (ListSeries) configuration.getSeries().get(0);
PlotOptionsLine plotOptionsLine = (PlotOptionsLine) detailData.getPlotOptions();
plotOptionsLine.setPointStart(start);
detailData.setData(list);
detailChart.drawChart(configuration);
}
});
lo.addComponent(detailChart);
lo.addComponent(masterChart);
return lo;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class MasterDetailChart method getMasterChart.
private Chart getMasterChart() {
Chart masterChart = new Chart(ChartType.AREA);
masterChart.setHeight("80px");
masterChart.setWidth("100%");
masterChart.setId("master-chart");
Configuration configuration = masterChart.getConfiguration();
configuration.getChart().setZoomType(ZoomType.X);
configuration.getChart().setReflow(false);
configuration.getChart().setBorderWidth(0);
configuration.getChart().setBackgroundColor(null);
configuration.getChart().setMarginLeft(50);
configuration.getChart().setMarginRight(20);
configuration.getTitle().setText("");
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.getxAxis().setShowLastLabel(true);
configuration.getxAxis().setMinRange(14 * DAY_IN_MILLIS);
configuration.getxAxis().setTitle(new AxisTitle(""));
PlotBand mask = new PlotBand();
mask.setColor(new SolidColor(0, 0, 0, 0.2));
mask.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
mask.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
configuration.getxAxis().setPlotBands(mask);
YAxis yAxis = configuration.getyAxis();
yAxis.setGridLineWidth(0);
yAxis.setLabels(new Labels(false));
yAxis.setTitle(new AxisTitle(""));
yAxis.setMin(0.6);
yAxis.setShowFirstLabel(false);
configuration.getTooltip().setEnabled(false);
configuration.getLegend().setEnabled(false);
configuration.getCredits().setEnabled(false);
PlotOptionsArea plotOptions = new PlotOptionsArea();
plotOptions.setLineWidth(1);
plotOptions.setShadow(false);
Hover hover = new Hover();
hover.setLineWidth(1);
States states = new States();
states.setHover(hover);
plotOptions.setStates(states);
plotOptions.setEnableMouseTracking(false);
plotOptions.setAnimation(false);
configuration.setPlotOptions(plotOptions);
ListSeries ls = new ListSeries();
PlotOptionsArea masterPlotOptions = new PlotOptionsArea();
GradientColor fillColor = GradientColor.createLinear(0, 0, 0, 1);
fillColor.addColorStop(0, new SolidColor(69, 114, 167, 1));
fillColor.addColorStop(1, new SolidColor(69, 114, 167, 0.5));
masterPlotOptions.setFillColor(fillColor);
masterPlotOptions.setPointInterval(24 * 3600 * 1000);
masterPlotOptions.setMarker(new Marker(false));
masterPlotOptions.setPointStart(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
ls.setPlotOptions(masterPlotOptions);
ls.setName("USD to EUR");
ls.setData(FULL_DEMO_DATA_SET);
configuration.addSeries(ls);
masterChart.drawChart(configuration);
return masterChart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class ModifyOnePoint method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("300px");
chart.setWidth("100%");
final Configuration configuration = chart.getConfiguration();
configuration.setTitle("One point is different");
configuration.getTooltip().setEnabled(false);
configuration.getChart().setType(ChartType.SPLINE);
series = new DataSeries();
series.add(createBasicPoint(1, 4));
series.add(new DataSeriesItem(3, 4));
dataSeriesItem = new DataSeriesItem(4, 4);
Marker marker = new Marker(true);
marker.setRadius(10);
marker.setFillColor(new SolidColor("red"));
dataSeriesItem.setMarker(marker);
dataSeriesItem.setName("Special point");
series.add(dataSeriesItem);
series.add(new DataSeriesItem(8, 3));
configuration.setSeries(series);
chart.drawChart(configuration);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class ModifyOnePoint method setup.
@Override
protected void setup() {
super.setup();
FormLayout formLayout = new FormLayout();
formLayout.setCaption("Special point settings, only updated point state is sent to client.");
formLayout.setMargin(true);
final Slider sliderX = new Slider();
sliderX.setMin(3);
sliderX.setMax(8);
sliderX.setResolution(1);
sliderX.setValue(4d);
sliderX.setCaption("X");
sliderX.addValueChangeListener(event -> {
dataSeriesItem.setX(sliderX.getValue());
series.update(dataSeriesItem);
});
sliderX.setWidth("200px");
formLayout.addComponent(sliderX);
final Slider sliderY = new Slider();
sliderY.setMin(0);
sliderY.setMax(10);
sliderY.setResolution(1);
sliderY.setValue(4d);
sliderY.setCaption("Y");
sliderY.addValueChangeListener(event -> {
dataSeriesItem.setY(sliderY.getValue());
updateItemInChart();
});
sliderY.setWidth("200px");
formLayout.addComponent(sliderY);
final ColorPicker colorPicker = new ColorPicker();
colorPicker.setValue(new com.vaadin.shared.ui.colorpicker.Color(255, 0, 0));
colorPicker.setCaption("Marker color");
colorPicker.addValueChangeListener(event -> {
dataSeriesItem.getMarker().setFillColor(new SolidColor(event.getValue().getCSS()));
updateItemInChart();
});
formLayout.addComponent(colorPicker);
Button c = new Button("Pseudorandom", new Button.ClickListener() {
Random r = new Random(0);
@Override
public void buttonClick(ClickEvent event) {
sliderX.setValue(r.nextDouble() * 5 + 3);
sliderY.setValue(r.nextDouble() * 10);
colorPicker.setValue(new com.vaadin.shared.ui.colorpicker.Color(r.nextInt(255), r.nextInt(255), r.nextInt(255)));
}
});
c.setId("random");
formLayout.addComponent(c);
addComponentAsFirst(formLayout);
}
Aggregations