Chartjs-tsgauge icon indicating copy to clipboard operation
Chartjs-tsgauge copied to clipboard

add function formatDataValue in options

Open jhonnattan123 opened this issue 4 years ago • 1 comments

with this atributte u can modify the text display in the center of gauge. like this example:

var ctx = document.getElementById("chartjs-gauge").getContext("2d");
            new Chart(ctx, {
                type: "tsgauge",
                data: {
                    datasets: [{
                        backgroundColor: ["#0fdc63", "#fd9704", "#ff7143"],
                        borderWidth: 0,
                        gaugeData: {
                            value: 32,
                            valueColor: "#ff7143"
                        },
                        gaugeLimits: [0, 50, 100, 150]
                    }]
                },
                options: {
                        events: [],
                        showMarkers: true,
                        markerFormatFn :  n => n + 'm³/s',
                        formatDataValue :  n => n + 'm³/s',
                }
            });

before the center text is 32. after the center text is 32m³/s

only add formatDataValue attribute (is a function) in options.

jhonnattan123 avatar Apr 01 '20 18:04 jhonnattan123

@kluverua @lukas-mertens

jhonnattan123 avatar Oct 19 '21 13:10 jhonnattan123