use of com.vaadin.flow.component.charts.model.style.SolidColor in project flow-components by vaadin.
the class ServerSideEvents method initDemo.
@Override
public void initDemo() {
historyLayout = new OrderedList();
historyLayout.setId("history");
chart = new Chart();
chart.setId("chart");
final Configuration configuration = chart.getConfiguration();
configuration.getChart().setWidth(500);
configuration.getChart().setType(ChartType.SCATTER);
configuration.getTitle().setText("Test server side events.");
configuration.getSubTitle().setText("When an event occurs, the details are shown below the chart");
configuration.setExporting(true);
configuration.getChart().setAnimation(false);
configuration.getChart().setZoomType(Dimension.XY);
configuration.getAccessibility().setEnabled(false);
XAxis xAxis = configuration.getxAxis();
xAxis.setMinPadding(0.2);
xAxis.setMaxPadding(0.2);
YAxis yAxis = configuration.getyAxis();
yAxis.setTitle(new AxisTitle("Value"));
PlotLine plotline = new PlotLine();
plotline.setValue(0);
plotline.setWidth(1);
plotline.setColor(new SolidColor("#808080"));
yAxis.setPlotLines(plotline);
yAxis.setMinPadding(0.2);
yAxis.setMaxPadding(0.2);
YAxis yAxis1 = new YAxis();
yAxis1.setTitle("Another axis");
yAxis1.setOpposite(true);
configuration.addyAxis(yAxis1);
PlotOptionsSeries opt = new PlotOptionsSeries();
opt.setShowCheckbox(true);
opt.setAllowPointSelect(true);
configuration.setPlotOptions(opt);
configuration.setTooltip(new Tooltip(false));
final DataSeries series1 = createDataSeries(0);
final DataSeries series2 = createDataSeries(20);
DataSeries series3 = createDataSeries(100);
series3.get(0).setY(105);
series3.get(3).setY(95);
series3.setName("Another axis");
series3.setyAxis(1);
DataSeriesItem firstDataPoint = series1.get(0);
firstDataPoint.setSelected(true);
configuration.setSeries(series1, series2, series3);
chart.addChartClickListener(this::logEvent);
chart.addPointClickListener(this::logEvent);
chart.addCheckBoxClickListener(this::logEvent);
chart.addSeriesLegendItemClickListener(this::logEvent);
chart.addSeriesHideListener(this::logEvent);
chart.addSeriesShowListener(this::logEvent);
chart.addPointSelectListener(this::logEvent);
chart.addPointUnselectListener(this::logEvent);
chart.addYAxesExtremesSetListener(this::logEvent);
chart.drawChart();
chart.setVisibilityTogglingDisabled(false);
VerticalLayout layout = new VerticalLayout();
layout.setId("master");
layout.add(createControls());
layout.add(new H2("Event History"), historyLayout);
add(chart, layout);
}
use of com.vaadin.flow.component.charts.model.style.SolidColor in project flow-components by vaadin.
the class Bullet method createBulletChart.
/**
* Create a bullet chart with shared configuration
*
* @param plotBandY1
* "from" value for the first plotband
* @param plotBandY2
* "to" value for the first plotband and "from" value for the
* second plotband
* @param plotBandY3
* "to" value for the second plotband and "from" value for the
* third plotband
* @param plotBandY4
* "to" value for the third plotband
* @param y
* Y value for the series item
* @param target
* Target value for the series item
* @param category
* Title to be used in the category
* @return Chart with shared configuration
*/
private Chart createBulletChart(Number plotBandY1, Number plotBandY2, Number plotBandY3, Number plotBandY4, Number y, Number target, String category) {
Chart chart = new Chart(ChartType.BULLET);
chart.setHeight("85px");
Configuration conf = chart.getConfiguration();
conf.getChart().setInverted(true);
conf.getChart().setMarginLeft(135);
conf.getLegend().setEnabled(false);
YAxis yAxis = conf.getyAxis();
yAxis.setGridLineWidth(0);
yAxis.setTitle("");
yAxis.addPlotBand(new PlotBand(plotBandY1, plotBandY2, new SolidColor("#666666")));
yAxis.addPlotBand(new PlotBand(plotBandY2, plotBandY3, new SolidColor("#999999")));
yAxis.addPlotBand(new PlotBand(plotBandY3, plotBandY4, new SolidColor("#bbbbbb")));
conf.getxAxis().addCategory(category);
conf.getTooltip().setPointFormat("<b>{point.y}</b> (with target at {point.target})");
PlotOptionsBullet options = new PlotOptionsBullet();
options.setPointPadding(0.25);
options.setBorderWidth(0);
options.setColor(SolidColor.BLACK);
options.getTargetOptions().setWidth("200%");
conf.setExporting(false);
DataSeries series = new DataSeries();
series.add(new DataSeriesItemBullet(y, target));
series.setPlotOptions(options);
conf.addSeries(series);
return chart;
}
use of com.vaadin.flow.component.charts.model.style.SolidColor in project flow-components by vaadin.
the class ColorThreshold method initDemo.
@Override
public void initDemo() {
super.initDemo();
PlotOptionsArearange plotOptions = new PlotOptionsArearange();
// Make "value" below -5 displayed with another color. Default threshold
// value is 0
plotOptions.setThreshold(-5);
plotOptions.setNegativeColor(new SolidColor("#434348"));
chart.getConfiguration().setPlotOptions(plotOptions);
}
use of com.vaadin.flow.component.charts.model.style.SolidColor in project flow-components by vaadin.
the class HeatMap method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration config = chart.getConfiguration();
config.getChart().setType(ChartType.HEATMAP);
config.getChart().setMarginTop(40);
config.getChart().setMarginBottom(40);
config.getTitle().setText("Sales per employee per weekday");
config.getxAxis().setCategories("Marta", "Mysia", "Misiek", "Maniek", "Miki", "Guillermo", "Jonatan", "Zdzisław", "Antoni", "Zygmunt");
config.getyAxis().setCategories("Monday", "Tuesday", "Wednesday", "Thursday", "Friday");
config.getColorAxis().setMin(0);
config.getColorAxis().setMinColor(SolidColor.WHITE);
SolidColor lightBlue = new SolidColor(22, 118, 243);
config.getColorAxis().setMaxColor(lightBlue);
config.getLegend().setLayout(LayoutDirection.VERTICAL);
config.getLegend().setAlign(HorizontalAlign.RIGHT);
config.getLegend().setMargin(0);
config.getLegend().setVerticalAlign(VerticalAlign.TOP);
config.getLegend().setY(25);
config.getLegend().setSymbolHeight(320);
HeatSeries rs = new HeatSeries("Sales per employee", getRawData());
PlotOptionsHeatmap plotOptionsHeatmap = new PlotOptionsHeatmap();
plotOptionsHeatmap.setDataLabels(new DataLabels());
plotOptionsHeatmap.getDataLabels().setEnabled(true);
SeriesTooltip tooltip = new SeriesTooltip();
tooltip.setHeaderFormat("{series.name}<br/>");
tooltip.setPointFormat("Amount: <b>{point.value}</b> ");
plotOptionsHeatmap.setTooltip(tooltip);
config.setPlotOptions(plotOptionsHeatmap);
config.setSeries(rs);
add(chart);
}
use of com.vaadin.flow.component.charts.model.style.SolidColor in project flow-components by vaadin.
the class Organization method createSeries.
private NodeSeries createSeries() {
NodeSeries series = new NodeSeries();
series.setName("Acme");
Node acme = new Node("Acme");
Node headOffice = new Node("Head Office");
Node labs = new Node("Labs");
Node coyoteBuilding = new Node("Coyote Building");
Node roadRunnerBuilding = new Node("Road Runner Building");
Node sales = new Node("Sales");
Node marketing = new Node("Marketing");
Node accounting = new Node("Accounting");
Node administration = new Node("Administration");
Node mdsOffice = new Node("MD's Office");
Node josephMiler = new Node("Joseph Miler");
josephMiler.setTitle("Head of Sales");
josephMiler.setLayout(NodeLayout.HANGING);
Node erikPerez = new Node("Erik Perez");
erikPerez.setTitle("Head of Marketing");
erikPerez.setLayout(NodeLayout.HANGING);
Node emilyFox = new Node("Emily Fox");
emilyFox.setTitle("Head of Accounting");
Node ewanHerbert = new Node("Ewan Herbert");
ewanHerbert.setTitle("Head of Admin");
ewanHerbert.setLayout(NodeLayout.HANGING);
Node kateKirby = new Node("Kate Kirby");
Node vaughnWhiting = new Node("Vaughn Whiting");
Node lisaWarner = new Node("Lisa Warner");
Node mollyDodd = new Node("Molly Dodd");
Node natashaKelly = new Node("Natasha Kelly");
Node managingDirector = new Node("Sally Brown", "Sally Brown", "Managing Director");
managingDirector.setColor(new SolidColor("#E4B651"));
series.add(acme, headOffice);
series.add(acme, labs);
series.add(headOffice, coyoteBuilding);
series.add(headOffice, roadRunnerBuilding);
series.add(coyoteBuilding, sales);
series.add(coyoteBuilding, marketing);
series.add(coyoteBuilding, accounting);
series.add(roadRunnerBuilding, administration);
series.add(roadRunnerBuilding, mdsOffice);
series.add(sales, josephMiler);
series.add(marketing, erikPerez);
series.add(accounting, emilyFox);
series.add(administration, ewanHerbert);
series.add(josephMiler, kateKirby);
series.add(josephMiler, vaughnWhiting);
series.add(erikPerez, lisaWarner);
series.add(ewanHerbert, mollyDodd);
series.add(ewanHerbert, natashaKelly);
series.add(mdsOffice, managingDirector);
PlotOptionsOrganization plotOptions = createPlotOptions();
series.setPlotOptions(plotOptions);
return series;
}
Aggregations