chart js annotation label text is cutting of

j2cgzkjk  于 12个月前  发布在  Chart.js
关注(0)|答案(1)|浏览(161)

我使用react-chart js在我的图我画一个多垂直线使用annotation这是我的示例代码我曾用来画线

const testValue = ['0.019', '0.033', '0.305', '0.428', '0.582', '0.826'];
    const splitArrayPopup = map(testValue, el => ({
      type: 'line',
      mode: 'vertical',
      scaleID: 'x-axis-0',
      value: parseFloat(el),
      borderColor: '#e0e2e2',
      borderWidth: 1,
      borderDash: [3, 3],
      label: {
        content: parseFloat(el),
        position: 'bottom',
        enabled: true,
        backgroundColor: 'transparent',
        fontColor: '#e0e2e2',
        fontStyle: 'normal',
        yPadding: 0,
        yAdjust: -10,
      },
    }));

我需要在图表的底部显示我的标签文本,我的意思是在图表之外,现在我要进入图表。

nwsw7zdq

nwsw7zdq1#

超晚,但你可以禁用裁剪图表边界,允许你的标签被视为画布的图表的定义视图之外:

plugins: {
  annotation: {
    clip: false,
   }
  annotations: annotations
}

注意:如果div没有足够的空间,标签仍然会被切断。在这种情况下,您需要增加包含图表的div的空间。

相关问题