Chart.js: 改变工具提示的宽度

Chart.js: Change width of tooltip

我想在 Chart.js 中更改 toopltip 的宽度。 原因是如果工具提示太宽,它们会隐藏在 iFrame 下。

我试图移动它们,但我只找到了选项 position: 'nearest'。 但这并不能解决问题。

是否没有将工具提示的宽度设置为 200px(带换行符)的选项?

我只找到了边框宽度或字体大小(应该更大)的选项。

您也可以尝试位置:'average' 或按照指定定义您自己的位置@

https://www.chartjs.org/docs/latest/configuration/tooltip.html#position-modes

即在示例中有一个自定义定位器的示例,它声明 "New modes can be defined by adding functions to the Chart.Tooltip.positioners map"

如果以上不适合,那么您必须按照指定编写自己的外部 html 工具提示 @ https://www.chartjs.org/docs/latest/configuration/tooltip.html#external-custom-tooltips