use of com.vaadin.flow.component.charts.model.DataLabels 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.DataLabels in project flow-components by vaadin.
the class BarChart method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration configuration = chart.getConfiguration();
configuration.setTitle("Historic World Population by Region");
configuration.setSubTitle("Source: <a href=\"https://en.wikipedia.org/wiki/World_population\">Wikipedia.org</a>");
chart.getConfiguration().getChart().setType(ChartType.BAR);
configuration.addSeries(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
configuration.addSeries(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
configuration.addSeries(new ListSeries("Year 2000", 814, 841, 3714, 727, 31));
configuration.addSeries(new ListSeries("Year 2016", 1216, 1001, 4436, 738, 40));
XAxis x = new XAxis();
x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
configuration.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
AxisTitle yTitle = new AxisTitle();
yTitle.setText("Population (millions)");
yTitle.setAlign(VerticalAlign.HIGH);
y.setTitle(yTitle);
configuration.addyAxis(y);
Tooltip tooltip = new Tooltip();
tooltip.setValueSuffix(" millions");
configuration.setTooltip(tooltip);
PlotOptionsBar plotOptions = new PlotOptionsBar();
DataLabels dataLabels = new DataLabels();
dataLabels.setEnabled(true);
plotOptions.setDataLabels(dataLabels);
configuration.setPlotOptions(plotOptions);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class ColumnWithLazyMultiLevelDrilldownCallbackTests method initDemo.
@Override
public void initDemo() {
log = new OrderedList();
log.setId("log");
Div layout = new Div();
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
final Configuration conf = chart.getConfiguration();
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setAnimation(false);
conf.getDrilldown().setAnimation(false);
column.setDataLabels(new DataLabels(true));
conf.setPlotOptions(column);
DataSeries series = new DataSeries();
series.setName("Top");
createItems("Item").forEach(series::addItemWithDrilldown);
conf.addSeries(series);
chart.addChartDrillupListener(event -> log("ChartDrillupEvent"));
final NativeButton setNew = new NativeButton("set new callback", e -> chart.setDrilldownCallback(getDrilldownCallback()));
setNew.setId("setNew");
final NativeButton setSame = new NativeButton("set same callback", e -> chart.setDrilldownCallback(chart.getDrilldownCallback()));
setSame.setId("setSame");
final NativeButton setNull = new NativeButton("set null callback", e -> chart.setDrilldownCallback(null));
setNull.setId("setNull");
layout.add(chart, setNew, setSame, setNull, log);
add(layout);
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class ColumnWithNativeLazyDrilldown method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
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);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total percent market share");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
// column.getDataLabels().setFormatter("this.y +'%'");
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");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setColorByPoint(true);
series.setPlotOptions(plotOptionsColumn);
DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
item.setId("MSIE");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Firefox", 21.63);
item.setId("Firefox");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Chrome", 11.94);
item.setId("Chrome");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Safari", 7.15);
item.setId("Safari");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Opera", 2.14);
item.setId("Opera");
series.addItemWithDrilldown(item);
conf.addSeries(series);
drillSeries = new HashMap<String, DataSeries>();
DataSeries drill = new DataSeries("MSIE versions");
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 };
drill.setData(categories, ys);
drillSeries.put("MSIE", drill);
drill = new DataSeries("Firefox versions");
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 };
drill.setData(categories, ys);
drillSeries.put("Firefox", drill);
drill = new DataSeries("Chrome versions");
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 };
drill.setData(categories, ys);
drillSeries.put("Chrome", drill);
drill = new DataSeries("Safari versions");
categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
drill.setData(categories, ys);
drillSeries.put("Safari", drill);
drill = new DataSeries("Opera versions");
categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
ys = new Number[] { 0.12, 0.37, 1.65 };
drill.setData(categories, ys);
drillSeries.put("Opera", drill);
chart.setDrilldownCallback(event -> getPointDrilldown(event.getItem()));
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class ColumnWithNativeLazyDrilldownMultipleSeries method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
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);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total percent market share");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
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);
createSeries(1);
createSeries(2);
drillSeries = new HashMap<>();
addDrillSeries(1);
addDrillSeries(2);
chart.setDrilldownCallback(event -> getPointDrilldown(event.getItem()));
add(chart);
}
Aggregations