use of com.vaadin.flow.component.charts.model.YAxis in project flow-components by vaadin.
the class Polar method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.getChart().setPolar(true);
conf.setTitle("Polar Chart");
Pane pane = new Pane(0, 360);
conf.addPane(pane);
XAxis xAxis = new XAxis();
xAxis.setTickInterval(45);
xAxis.setMin(0);
xAxis.setMax(360);
Labels labels = new Labels();
labels.setFormatter("function() {return this.value + '°';}");
xAxis.setLabels(labels);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
conf.addxAxis(xAxis);
conf.addyAxis(yAxis);
PlotOptionsSeries series = new PlotOptionsSeries();
PlotOptionsColumn column = new PlotOptionsColumn();
series.setPointStart(0);
series.setPointInterval(45);
column.setPointPadding(0);
column.setGroupPadding(0);
conf.setPlotOptions(series, column);
ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
col.setPlotOptions(new PlotOptionsColumn());
col.setName(ChartType.COLUMN.toString());
line.setPlotOptions(new PlotOptionsLine());
line.setName(ChartType.LINE.toString());
area.setPlotOptions(new PlotOptionsArea());
area.setName(ChartType.AREA.toString());
conf.setSeries(col, line, area);
add(chart);
}
use of com.vaadin.flow.component.charts.model.YAxis 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.YAxis in project flow-components by vaadin.
the class Spiderweb method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration configuration = chart.getConfiguration();
configuration.getChart().setPolar(true);
configuration.setTitle("Budget vs spending");
XAxis xAxis = configuration.getxAxis();
xAxis.setCategories("Sales", "Marketing", "Development", "Customer Support", "Information Technology", "Administration");
xAxis.setTickmarkPlacement(TickmarkPlacement.ON);
YAxis yAxis = configuration.getyAxis();
yAxis.setGridLineInterpolation("polygon");
yAxis.setMin(0);
Tooltip tooltip = configuration.getTooltip();
tooltip.setShared(true);
tooltip.setPointFormat("<span style=\"color:{series.color}\">{series.name}: <b>${point.y:,.0f}</b><br/>");
Legend legend = configuration.getLegend();
legend.setAlign(HorizontalAlign.RIGHT);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setLayout(LayoutDirection.VERTICAL);
legend.setY(70);
ListSeries allocatedBudget = new ListSeries("Allocated Budget", 43000, 19000, 60000, 35000, 17000, 10000);
configuration.addSeries(allocatedBudget);
ListSeries actualSpending = new ListSeries("Actual Spending", 50000, 39000, 42000, 31000, 26000, 14000);
configuration.addSeries(actualSpending);
add(chart);
}
use of com.vaadin.flow.component.charts.model.YAxis in project flow-components by vaadin.
the class DynamicChangingChart method getPolarConfiguration.
public Configuration getPolarConfiguration() {
Configuration configuration = new Configuration();
configuration.getChart().setPolar(true);
configuration.setTitle("Polar Chart");
Pane pane = new Pane(0, 360);
configuration.addPane(pane);
XAxis xAxis = new XAxis();
xAxis.setTickInterval(45);
xAxis.setMin(0);
xAxis.setMax(360);
Labels labels = new Labels();
labels.setFormatter("function() {return this.value + '°';}");
xAxis.setLabels(labels);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
configuration.addxAxis(xAxis);
configuration.addyAxis(yAxis);
PlotOptionsSeries series = new PlotOptionsSeries();
PlotOptionsColumn column = new PlotOptionsColumn();
series.setPointStart(0);
series.setPointInterval(45);
column.setPointPadding(0);
column.setGroupPadding(0);
configuration.setPlotOptions(series, column);
ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
col.setPlotOptions(new PlotOptionsColumn());
col.setName(ChartType.COLUMN.toString());
line.setPlotOptions(new PlotOptionsLine());
line.setName(ChartType.LINE.toString());
area.setPlotOptions(new PlotOptionsArea());
area.setName(ChartType.AREA.toString());
configuration.setSeries(col, line, area);
return configuration;
}
use of com.vaadin.flow.component.charts.model.YAxis in project flow-components by vaadin.
the class ErrorBar method initDemo.
@Override
public void initDemo() {
Chart chart = new Chart();
Configuration configuration = chart.getConfiguration();
configuration.setTitle("Monthly Rainfall");
XAxis x = new XAxis();
x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
configuration.addxAxis(x);
YAxis y = new YAxis();
Labels yLabels = new Labels();
yLabels.setFormat("{value} mm");
y.setLabels(yLabels);
y.setTitle("Rainfall");
configuration.addyAxis(y);
Tooltip tooltip = new Tooltip();
tooltip.setShared(true);
configuration.setTooltip(tooltip);
Series rainfall = new ListSeries("Rainfall", 49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
PlotOptionsColumn rainfallOptions = new PlotOptionsColumn();
SeriesTooltip rainfallTooltip = new SeriesTooltip();
rainfallTooltip.setPointFormat("<span style=\"font-weight: bold; color: {series.color}\">" + "{series.name}</span>: <b>{point.y:.1f} mm</b> ");
rainfallOptions.setTooltip(rainfallTooltip);
rainfall.setPlotOptions(rainfallOptions);
configuration.addSeries(rainfall);
Series error = new RangeSeries("Rainfall error", new Number[] { 48, 51 }, new Number[] { 68, 73 }, new Number[] { 92, 110 }, new Number[] { 128, 136 }, new Number[] { 140, 150 }, new Number[] { 171, 179 }, new Number[] { 135, 143 }, new Number[] { 142, 149 }, new Number[] { 204, 220 }, new Number[] { 189, 199 }, new Number[] { 95, 110 }, new Number[] { 52, 56 });
PlotOptionsErrorbar errorOptions = new PlotOptionsErrorbar();
SeriesTooltip errorTooltip = new SeriesTooltip();
errorTooltip.setPointFormat("(error range: {point.low}-{point.high} mm)<br/>");
errorOptions.setTooltip(errorTooltip);
error.setPlotOptions(errorOptions);
configuration.addSeries(error);
add(chart);
}
Aggregations