如何禁用图表交互

98 阅读1分钟

问题标题

如何禁用图表交互

问题描述

请问使用图表的时候怎么关闭图表的交互事件呢,只希望图表作为图片一样使用?

解决方案

VChart 中可以支持直接传入disableTriggerEvent: true关闭交互

代码示例

const spec = {
  type: 'bar',
  data: [
    {
      id: 'barData',
      values: [
        { month: 'Monday', sales: 22 },
        { month: 'Tuesday', sales: 13 },
        { month: 'Wednesday', sales: 25 },
        { month: 'Thursday', sales: 29 },
        { month: 'Friday', sales: 38 }
      ]
    }
  ],
  xField: 'month',
  yField: 'sales'
};

const vchart = new VChart(spec, { dom: CONTAINER_ID, disableTriggerEvent: true });
vchart.renderSync();

// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

结果展示

Demo: codesandbox.io/p/sandbox/v…

相关文档

Demo:codesandbox.io/p/sandbox/v…

教程:

Github:github.com/VisActor/VC…