use of com.vaadin.flow.component.charts.model.Tooltip in project flow-components by vaadin.
the class ScatterAndPolygon method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.SCATTER);
Configuration conf = chart.getConfiguration();
chart.setId("chart");
conf.getChart().setZoomType(Dimension.XY);
conf.disableCredits();
conf.setTitle("Height vs Weight");
conf.setSubTitle("Polygon series in Vaadin Charts.");
Tooltip tooltip = conf.getTooltip();
tooltip.setHeaderFormat("<b>{series.name}</b><br>");
tooltip.setPointFormat("{point.x} cm, {point.y} kg");
XAxis xAxis = conf.getxAxis();
xAxis.setStartOnTick(true);
xAxis.setEndOnTick(true);
xAxis.setShowLastLabel(true);
xAxis.setTitle("Height (cm)");
YAxis yAxis = conf.getyAxis();
yAxis.setTitle("Weight (kg)");
PlotOptionsScatter plotOptionsScatter = new PlotOptionsScatter();
DataSeries scatter = new DataSeries();
scatter.setPlotOptions(plotOptionsScatter);
scatter.setName("Observations");
fillScatter(scatter);
DataSeries polygon = new DataSeries();
PlotOptionsPolygon plotOptionsPolygon = new PlotOptionsPolygon();
plotOptionsPolygon.setEnableMouseTracking(false);
polygon.setPlotOptions(plotOptionsPolygon);
polygon.setName("Target");
polygon.add(new DataSeriesItem(153, 42));
polygon.add(new DataSeriesItem(149, 46));
polygon.add(new DataSeriesItem(149, 55));
polygon.add(new DataSeriesItem(152, 60));
polygon.add(new DataSeriesItem(159, 70));
polygon.add(new DataSeriesItem(170, 77));
polygon.add(new DataSeriesItem(180, 70));
polygon.add(new DataSeriesItem(180, 60));
polygon.add(new DataSeriesItem(173, 52));
polygon.add(new DataSeriesItem(166, 45));
conf.addSeries(polygon);
conf.addSeries(scatter);
add(chart);
}
use of com.vaadin.flow.component.charts.model.Tooltip 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.Tooltip 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.Tooltip 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.Tooltip 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