Chartjs Tooltip Line Breaks

后端 未结 5 592
盖世英雄少女心
盖世英雄少女心 2020-12-09 15:02

Is it possible to get line breaks in chartjs tooltips?

tooltipTemplate: \"<%if (label){%><%=label%>: <%}%><%= value %>\"
5条回答
  •  攒了一身酷
    2020-12-09 15:35

    You can use tooltips footer callback,it will also not render coloured square for each list.

    tooltips: {
      callbacks: {
        label: function(tooltipItem, data) {
          let label = data.datasets[tooltipItem.datasetIndex].label;
          let value = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
          return label + ': ' + value;
        },
        footer: function(tooltipItems, data) {
          return ['new line', 'another line'];
        }
      }
    }

提交回复
热议问题