echarts tooltip超出显示区域 如何让其一直处在显示区域内

echarts yekong 867℃

设置前

echarts tooltip超出显示区域设置前

设置后

echarts tooltip超出显示区域设置后

ECharts 的 tooltip 组件有一个属性 confine,默认值为 false。当其设置为 true 时,tooltip 会被限制在图表的内容区域(由 grid.left/right/top/bottompolar.radius,等参数定义)内。

你可以在 tooltip 中添加 confine: true,如下所示:

var option = {
    tooltip: {
      trigger: 'item',
      confine: true
    },
    // ... 其他配置项
};

这样 tooltip 就不会超出图表的内容区域。如果 tooltip 的内容过长,ECharts 会自动提供滚动条。

喜欢 (0)