Search in sources :

Example 1 with PlotOptionsHeatmap

use of com.vaadin.flow.component.charts.model.PlotOptionsHeatmap 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);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) HeatSeries(com.vaadin.flow.component.charts.model.HeatSeries) PlotOptionsHeatmap(com.vaadin.flow.component.charts.model.PlotOptionsHeatmap) SolidColor(com.vaadin.flow.component.charts.model.style.SolidColor) Chart(com.vaadin.flow.component.charts.Chart) SeriesTooltip(com.vaadin.flow.component.charts.model.SeriesTooltip)

Aggregations

Chart (com.vaadin.flow.component.charts.Chart)1 Configuration (com.vaadin.flow.component.charts.model.Configuration)1 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)1 HeatSeries (com.vaadin.flow.component.charts.model.HeatSeries)1 PlotOptionsHeatmap (com.vaadin.flow.component.charts.model.PlotOptionsHeatmap)1 SeriesTooltip (com.vaadin.flow.component.charts.model.SeriesTooltip)1 SolidColor (com.vaadin.flow.component.charts.model.style.SolidColor)1