Echarts.js库 - 使用onclick事件为饼图片段引用页面

Iva*_*Nel 5 javascript echarts

我正在使用echarts.js库获取饼图,

我想将pie超链接中的每个切片都设置为另一个页面.

我现在使用静态数据点,以测试它是否可行 - 并将在之后更新为动态数据.

下面是pie1a的一个例子 - 我想要T2,T2,T4和N/A来引用他们自己的页面.T2 =" http://localhost/T2.html ".

// ECHART_PIE1a

  var echartPie1a = echarts.init(document.getElementById('echart_pie1a'), theme);

  echartPie1a.setOption({
     tooltip: {
      trigger: 'item',
      formatter: "{a} <br/>{b} : {c} ({d}%)"

    },




    legend: {
      x: 'right',
      y: 'bottom',
       data: ['T2', 'T3', 'T4', 'N/A']
    },

    calculable: true,
    series: [{
      name: '(TB)',
      type: 'pie',
      radius: '54%',
      center: ['54%', '36%'],
      data: [{

        value: 438,
        name: 'T2'
      }, {
        value: 1109,
        name: 'T3'
      }, {
        value: 42,
        name: 'T4'
      }, {
        value: 389,
        name: 'N/A'

      }]
    }]
  });
Run Code Online (Sandbox Code Playgroud)

Iva*_*Nel 6

echartPie1a.setOption(option);
echartPie1a.on('click', function (params) 
{window.open('' + encodeURIComponent(params.name) + '.html', '_self');
});
Run Code Online (Sandbox Code Playgroud)

似乎已经完成了这个伎俩.