Display totals for Label (or simply display a string) inside a chart in Chart.js

0πŸ‘

βœ…

I managed to solve it. It’s possible to do that with an external plugin called
chartjs annotation

annotation: {

    // Should be one of: afterDraw, afterDatasetsDraw, beforeDatasetsDraw
    drawTime: 'afterDatasetsDraw', // (default)


    annotations: [

                {

        type: 'line',
        mode: 'vertical',
        scaleID: 'x-axis-0',
        value: 'January',
        borderColor: 'transparent',
        borderWidth: 0,

                    label: {
                        backgroundColor: 'rgba(0,0,0,0.8)',
                        fontSize: 10,
                        fontStyle: "bold",
                        fontColor: "#fff",
                        xPadding: 6,
                        yPadding: 6,
                        cornerRadius: 6,
                        position: "center",
                        xAdjust: 0,
                        yAdjust: -80,
                        enabled: true,
                        content: "Totals etc"
                    }

                }


            ]
        }

Leave a comment