use ChartJS components in vaadin flow?

I’m working on a Vaadin 10 Demo and would like now to display some (chartJS) charts in a view:
(Alternatively JFreeChart)
How does it work? the doc I found tell it is supported in Vaadin8+ ?


@Route(value = "test", layout = MainLayout.class)
public class ChartJSDemo extends VerticalLayout { 

    public ChartJSDemo() {
        InitChart();
    }

    void InitChart() {
        
        PieChartConfig config = new PieChartConfig();
        
        config.data().labels("Red", "Green", "Yellow").addDataset(new PieDataset().label("Dataset 1")).and();

//some init stuff

        ChartJs chart = new ChartJs(config);
        chart.setJsLoggingEnabled(true);
    
        add(chart); add chart to view ???

    }
}

Thanks for a hint / code snippet

Hi,

thanks for this very usefull API. I just tested it with Vaadin 12 and it is working great.
Finally I can rewrite my php chart program in Java with Vaadin.

Chris