使用echarts图强调点击

时间:2018-08-20 16:07:51

标签: javascript html echarts

我有一个使用echarts制作的图形图表。当我将鼠标悬停在边缘时,它将显示在强调选项上设置的某些行为。单击边缘之一时,有什么办法可以使这种行为发生?

强调代码:

emphasis: {
            lineStyle: {
              width: 5,
              color: "#555555"
            }
          }

1 个答案:

答案 0 :(得分:0)

myChart.on('click', (params) => {
  if (params.dataType === 'edge') { 
    /* you can check params to look for what you want to pick */
    myChart.dispatchAction({
        /* HighLight type */
        type: 'focusNodeAdjacency',
        /* OffLight type if you need */
        // type: 'unfocusNodeAdjacency',
        /* Positioning the series with seriesId/seriesIndex/seriesName */
        seriesIndex: 0,
        /* Positioning the node with dataIndex */
        dataIndex: params.dataIndex
    });
  }
})