4

如何使用 ng2-chart 设置工具提示始终可见?在 char.js 是选项 showTooltips: true,但我找不到 ng2-chart 解决方案。

4

1 回答 1

0

您可以将选项对象传递给canvas指令。

在您的 html 中:

<div style="display: block;">
    <canvas baseChart width="2" height="1"
            [datasets]="chartData"
            [labels]="chartLabels"
            [options]="chartOptions"
            [colors]="chartColors"
            [legend]=true
            chartType=line></canvas>
</div>

在您的打字稿中,创建chartOptions

private chartOptions = { responsive: true, tooltips: { mode: 'index', intersect: false } };

设置intersect: false选项以使工具提示始终显示在悬停时,就像您想要的那样。

更多关于 ChartJS 工具提示

于 2017-05-31T14:49:10.917 回答