In chart.js, Is it possible to hide x-axis label/text of bar chart if accessing from mobile?

前端 未结 6 1923
日久生厌
日久生厌 2021-01-13 14:06

In chart.js, Is it possible to hide x-axis label/text of bar chart if accessing from mobile ?

\

6条回答
  •  青春惊慌失措
    2021-01-13 14:54

    I got around this by defining labels as a list of empty strings. Example:

    var data = {
        labels: ["", "", "", "", ""],
        datasets: [{
            label: "TEST",
            fillColor: "rgba(220,220,220,0.2)",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(220,220,220,1)",
            data: [10, 20, 15, 8, 22]
        }]
    };
    

    For this you need the label to not be relevant in the tooltip box. I defined mine as follows:

    tooltipTemplate: "Latency: <%=value%>"
    

提交回复
热议问题