如何在刀尖去除彩色标签?

问题描述 投票:0回答:1

我试图删除从图表工具提示的颜色标签平方米。我怎样才能让这段代码中发生的与机智的所有其他代码?

<html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title> Title
</title>
<script 
 src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js">
    </script>
  </head>

<body onLoad="ready()">
<canvas id="myChart" width="600" height="200">
                                        </canvas>
<script>
    var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
                type: 'line',
                data: {
                    datasets: [{
                                data: [], //start empty backgroundColor: '#e8ebf8', borderColor: '#615BD4', borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { display: false, beginAtZero: true } }], xAxes: [{ ticks: { stepSize: 2, maxTicksLimit: 90 } }] }, legend: { display: false }, tooltips: { intersect: false, showTooltips: true, tooltipEvents: ["mousemove", "touchstart", "touchmove"], tooltipFillColor: "rgba(0,0,0,0.8)" } } }); window.onmessage = function(event) { myChart.data.datasets[0].data = event.data.data; myChart.data.labels = event.data.labels; myChart.update(); }; function handleClick(e) { var activeBars = myChart.getElementAtEvent(e); var value = myChart.config.data.datasets[activeBars[0]._datasetIndex].data[activeBars[0]._index]; var label = activeBars[0]._model.label; window.parent.postMessage({ "type": "click", // "label":label, "value": value }, "*"); } function ready() { window.parent.postMessage({ "type": "ready" }, "*"); }
</script>

</body>

</html>
html chart.js
1个回答
0
投票

使用回调功能删除标签:

  options: {
    legend: {
        display: false
    },
    tooltips: {
        callbacks: {
        label: function(tooltipItem) {
        console.log(tooltipItem)
            return tooltipItem.yLabel;
        }
      }
    }
  }
© www.soinside.com 2019 - 2024. All rights reserved.