use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class Organization method createPlotOptions.
private PlotOptionsOrganization createPlotOptions() {
PlotOptionsOrganization plotOptions = new PlotOptionsOrganization();
plotOptions.setColorByPoint(false);
plotOptions.setColor(new SolidColor("#007ad0"));
DataLabels dataLabels = new DataLabels();
dataLabels.setColor(SolidColor.BLACK);
plotOptions.setDataLabels(dataLabels);
plotOptions.setBorderColor(SolidColor.WHITE);
Level level0 = new Level();
level0.setLevel(0);
level0.setColor(new SolidColor("#99AED3"));
Level level1 = new Level();
level1.setLevel(1);
level1.setColor(new SolidColor("#CCE6C3"));
Level level2 = new Level();
level2.setLevel(2);
level2.setColor(new SolidColor("#E1F39D"));
Level level3 = new Level();
level3.setLevel(3);
level3.setColor(new SolidColor("#CCE6C3"));
Level level4 = new Level();
level4.setLevel(4);
level4.setColor(new SolidColor("#CABEDC"));
Level level5 = new Level();
level5.setLevel(5);
level5.setColor(new SolidColor("#CABDD4"));
plotOptions.addLevel(level0);
plotOptions.addLevel(level1);
plotOptions.addLevel(level2);
plotOptions.addLevel(level3);
plotOptions.addLevel(level4);
return plotOptions;
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class SolidGauge method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.SOLIDGAUGE);
Configuration configuration = chart.getConfiguration();
Pane pane = configuration.getPane();
pane.setCenter(new String[] { "50%", "50%" });
pane.setStartAngle(-90);
pane.setEndAngle(90);
Background paneBackground = new Background();
paneBackground.setInnerRadius("60%");
paneBackground.setOuterRadius("100%");
paneBackground.setShape(BackgroundShape.ARC);
pane.setBackground(paneBackground);
YAxis yAxis = configuration.getyAxis();
yAxis.setTickAmount(2);
yAxis.setTitle("Speed");
yAxis.setMinorTickInterval("null");
yAxis.getTitle().setY(-50);
yAxis.getLabels().setY(16);
yAxis.setMin(0);
yAxis.setMax(200);
PlotOptionsSolidgauge plotOptionsSolidgauge = new PlotOptionsSolidgauge();
DataLabels dataLabels = plotOptionsSolidgauge.getDataLabels();
dataLabels.setY(5);
dataLabels.setUseHTML(true);
configuration.setPlotOptions(plotOptionsSolidgauge);
DataSeries series = new DataSeries("Speed");
DataSeriesItem item = new DataSeriesItem();
item.setY(80);
// item.setColorIndex(2);
item.setClassName("myClassName");
DataLabels dataLabelsSeries = new DataLabels();
dataLabelsSeries.setFormat("<div style=\"text-align:center\"><span style=\"font-size:25px;" + "color:black' + '\">{y}</span><br/>" + "<span style=\"font-size:12px;color:silver\">km/h</span></div>");
item.setDataLabels(dataLabelsSeries);
series.add(item);
configuration.addSeries(series);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class TimeAxisTimeline method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.TIMELINE);
Configuration conf = chart.getConfiguration();
conf.getxAxis().setVisible(false);
conf.getxAxis().setType(AxisType.DATETIME);
conf.getyAxis().setVisible(false);
conf.setTitle("Timeline of Space Exploration");
conf.setSubTitle("Info source: <a href=\"https://en.wikipedia.org/wiki/Timeline_of_space_exploration\">www.wikipedia.org</a>");
conf.getTooltip().setEnabled(true);
DataSeries series = new DataSeries();
series.add(new DataSeriesItemTimeline(getInstant(1951, 6, 22), "First dogs in space", "First dogs in space", "Dezik and Tsygan were the first dogs to make a sub-orbital flight on 22 July 1951. Both dogs were recovered unharmed after travelling to a maximum altitude of 110 km."));
series.add(new DataSeriesItemTimeline(getInstant(1957, 10, 4), "First artificial satellite", "First artificial satellite", "Sputnik 1 was the first artificial Earth satellite. The Soviet Union launched it into an elliptical low Earth orbit on 4 October 1957, orbiting for three weeks before its batteries died, then silently for two more months before falling back into the atmosphere."));
series.add(new DataSeriesItemTimeline(getInstant(1959, 1, 4), "First artificial satellite to reach the Moon", "First artificial satellite to reach the Moon", "Luna 1 was the first artificial satellite to reach the Moon vicinity and first artificial satellite in heliocentric orbit."));
series.add(new DataSeriesItemTimeline(getInstant(1961, 4, 12), "First human spaceflight", "First human spaceflight", "Yuri Gagarin was a Soviet pilot and cosmonaut. He became the first human to journey into outer space when his Vostok spacecraft completed one orbit of the Earth on 12 April 1961."));
series.add(new DataSeriesItemTimeline(getInstant(1966, 2, 3), "First soft landing on the Moon", "First soft landing on the Moon", "Yuri Gagarin was a Soviet pilot and cosmonaut. He became the first human to journey into outer space when his Vostok spacecraft completed one orbit of the Earth on 12 April 1961."));
series.add(new DataSeriesItemTimeline(getInstant(1969, 7, 20), "First human on the Moon", "First human on the Moon", "Apollo 11 was the spaceflight that landed the first two people on the Moon. Commander Neil Armstrong and lunar module pilot Buzz Aldrin, both American, landed the Apollo Lunar Module Eagle on July 20, 1969, at 20:17 UTC."));
series.add(new DataSeriesItemTimeline(getInstant(1971, 4, 19), "First space station", "First space station", "Salyute 1 was the first space station of any kind, launched into low Earth orbit by the Soviet Union on April 19, 1971. The Salyut program followed this with five more successful launches out of seven more stations."));
series.add(new DataSeriesItemTimeline(getInstant(1971, 12, 2), "First soft Mars landing", "First soft Mars landing", "Mars 3 was an unmanned space probe of the Soviet Mars program which spanned the years between 1960 and 1973. Mars 3 was launched May 28, 1971, nine days after its twin spacecraft Mars 2. The probes were identical robotic spacecraft launched by Proton-K rockets with a Blok D upper stage, each consisting of an orbiter and an attached lander."));
series.add(new DataSeriesItemTimeline(getInstant(1976, 4, 17), "Closest flyby of the Sun", "Closest flyby of the Sun", "Helios-A and Helios-B (also known as Helios 1 and Helios 2) are a pair of probes launched into heliocentric orbit for the purpose of studying solar processes. A joint venture of West Germany's space agency DFVLR (70 percent share) and NASA (30 percent), the probes were launched from Cape Canaveral Air Force Station, Florida."));
series.add(new DataSeriesItemTimeline(getInstant(1978, 12, 4), "First orbital exploration of Venus", "First orbital exploration of Venus", "The Pioneer Venus Orbiter entered orbit around Venus on December 4, 1978, and performed observations to characterize the atmosphere and surface of Venus. It continued to transmit data until October 1992."));
series.add(new DataSeriesItemTimeline(getInstant(1986, 2, 19), "First inhabited space station", "First inhabited space station", "was a space station that operated in low Earth orbit from 1986 to 2001, operated by the Soviet Union and later by Russia. Mir was the first modular space station and was assembled in orbit from 1986 to 1996. It had a greater mass than any previous spacecraft."));
series.add(new DataSeriesItemTimeline(getInstant(1989, 8, 8), "First astrometric satellite", "First astrometric satellite", "Hipparcos was a scientific satellite of the European Space Agency (ESA), launched in 1989 and operated until 1993. It was the first space experiment devoted to precision astrometry, the accurate measurement of the positions of celestial objects on the sky."));
series.add(new DataSeriesItemTimeline(getInstant(1998, 11, 20), "First multinational space station", "First multinational space station", "The International Space Station (ISS) is a space station, or a habitable artificial satellite, in low Earth orbit. Its first component was launched into orbit in 1998, with the first long-term residents arriving in November 2000.[7] It has been inhabited continuously since that date."));
PlotOptionsTimeline options = new PlotOptionsTimeline();
options.getMarker().setSymbol(MarkerSymbolEnum.CIRCLE);
DataLabels labels = options.getDataLabels();
labels.setAllowOverlap(false);
labels.setFormat("<span style=\"color:{point.color}\">● </span><span style=\"font-weight: bold;\" > {point.x:%d %b %Y}</span><br/>{point.label}");
series.setPlotOptions(options);
conf.addSeries(series);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class WaterfallChart method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart(ChartType.WATERFALL);
DataSeries dataSeries = new DataSeries();
dataSeries.add(new DataSeriesItem("Start", 120000));
dataSeries.add(new DataSeriesItem("Product Revenue", 569000));
dataSeries.add(new DataSeriesItem("Service Revenue", 231000));
WaterFallSum positiveBalance = new WaterFallSum("Positive Balance");
positiveBalance.setIntermediate(true);
dataSeries.add(positiveBalance);
dataSeries.add(new DataSeriesItem("Fixed Costs", -342000));
dataSeries.add(new DataSeriesItem("Variable Costs", -233000));
WaterFallSum balance = new WaterFallSum("Balance");
dataSeries.add(balance);
PlotOptionsWaterfall opts = new PlotOptionsWaterfall();
DataLabels dataLabels = new DataLabels(true);
dataLabels.setVerticalAlign(VerticalAlign.TOP);
dataLabels.setY(-30);
dataLabels.setFormatter("function() { return this.y / 1000 + 'k'; }");
opts.setDataLabels(dataLabels);
dataSeries.setPlotOptions(opts);
Configuration configuration = chart.getConfiguration();
configuration.addSeries(dataSeries);
configuration.getxAxis().setType(AxisType.CATEGORY);
add(chart);
}
use of com.vaadin.flow.component.charts.model.DataLabels in project flow-components by vaadin.
the class ColumnWithLazyMultiLevelDrilldown method initDemo.
@Override
public void initDemo() {
log = new Div();
log.setId("log");
Div layout = new Div();
final Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
final Configuration conf = chart.getConfiguration();
conf.setTitle("Global happiness index");
conf.setSubTitle("Source: www.happyplanetindex.org");
conf.getLegend().setEnabled(false);
XAxis x = new XAxis();
x.setType(AxisType.CATEGORY);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setTitle("Total");
conf.addyAxis(y);
PlotOptionsColumn column = new PlotOptionsColumn();
column.setCursor(Cursor.POINTER);
column.setDataLabels(new DataLabels(true));
conf.setPlotOptions(column);
DataSeries series = new DataSeries();
series.setName("Regions");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setColorByPoint(true);
series.setPlotOptions(plotOptionsColumn);
DataSeriesItem item = new DataSeriesItem("Latin America and Caribbean", 60);
item.setId("Latin America and Caribbean");
series.addItemWithDrilldown(item);
item = new DataSeriesItem("Europe", 50);
item.setId("Europe");
series.addItemWithDrilldown(item);
conf.addSeries(series);
drillSeries = new HashMap<String, DataSeries>();
DataSeries drill = new DataSeries("Latin America and Caribbean Countries");
drill.setId("Latin America and Caribbean Countries");
item = new DataSeriesItem("Costa Rica", 64);
item.setId("Costa Rica");
drill.addItemWithDrilldown(item);
item = new DataSeriesItem("Colombia", 59.8);
item.setId("Colombia");
drill.addItemWithDrilldown(item);
item = new DataSeriesItem("Belize", 59.3);
item.setId("Belize");
drill.addItemWithDrilldown(item);
drillSeries.put("Latin America and Caribbean", drill);
drill = new DataSeries("Europe");
drill.setId("European Countries");
item = new DataSeriesItem("Norway", 51.4);
item.setId("Norway");
drill.addItemWithDrilldown(item);
item = new DataSeriesItem("Switzerland", 50.3);
item.setId("Switzerland");
drill.addItemWithDrilldown(item);
item = new DataSeriesItem("Portugal", 38.7);
item.setId("Portugal");
drill.addItemWithDrilldown(item);
drillSeries.put("Europe", drill);
drill = new DataSeries("Details Costa Rica");
drill.setId("Details Costa Rica");
final String[] categories = new String[] { "Life Expectancy", "Well-being (0-10)", "Footprint (gha/capita)" };
Number[] ys = new Number[] { 79.3, 7.3, 2.5 };
drill.setData(categories, ys);
drillSeries.put("Costa Rica", drill);
drill = new DataSeries("Details Colombia");
drill.setId("Details Colombia");
ys = new Number[] { 73.7, 6.4, 1.8 };
drill.setData(categories, ys);
drillSeries.put("Colombia", drill);
drill = new DataSeries("Details Belize");
drill.setId("Details Belize");
ys = new Number[] { 76.1, 6.5, 2.1 };
drill.setData(categories, ys);
drillSeries.put("Belize", drill);
drill = new DataSeries("Details Norway");
drill.setId("Details Norway");
ys = new Number[] { 81.1, 7.6, 4.8 };
drill.setData(categories, ys);
drillSeries.put("Norway", drill);
drill = new DataSeries("Details Switzerland");
drill.setId("Details Switzerland");
ys = new Number[] { 82.3, 7.5, 5.0 };
drill.setData(categories, ys);
drillSeries.put("Switzerland", drill);
drill = new DataSeries("Details Portugal");
drill.setId("Details Portugal");
ys = new Number[] { 79.5, 4.9, 4.1 };
drill.setData(categories, ys);
drillSeries.put("Portugal", drill);
chart.setDrilldownCallback((DrilldownCallback) event -> {
log("DrilldownEvent: " + event.getItem().getId());
return getPointDrilldown(event.getItem());
});
chart.addChartDrillupListener(event -> log("ChartDrillupEvent"));
layout.add(chart, log);
add(layout);
}
Aggregations