如何使用 ng2-chart 设置工具提示始终可见?在 char.js 是选项 showTooltips: true,但我找不到 ng2-chart 解决方案。
最佳答案
您可以将选项对象传递到 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>
在您的 typescript 中,创建chartOptions
:
private chartOptions = { responsive: true, tooltips: { mode: 'index', intersect: false } };
设置 intersect: false
选项以使工具提示始终显示在悬停时,如您所愿。
关于tooltip - ng2-chart.js 工具提示始终显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39579067/