在Echarts 柱形圖的單擊事件中寫入自定義的參數


  邏輯:(點擊柱形圖的某個實例(注意:三個柱子表示的是一個實例))

  

  參考鏈接:http://echarts.baidu.com/doc/example/event.html

  

  {
                    name: 'cunchu',
                    type: 'bar',
                    data: [],
                    rawdate: []  //添加了rawdate參數(自定義的)
                },
 function eConsole(param) {
            var cloudid;
            var mes = '' + param.type + '';
            if (typeof param.seriesIndex != 'undefined') {
                mes += '  seriesIndex : ' + param.seriesIndex;
                mes += '  dataIndex : ' + param.dataIndex;
                //alert(option.series[param.dataIndex].rawdate);
                cloudid = option.series[param.seriesIndex].rawdate[param.dataIndex];
                Tiaozhuan(cloudid);
            }
            if (param.type == 'hover') {
                document.getElementById('hover-console').innerHTML = 'Event Console : ' + mes;
            } else {
                document.getElementById('console').innerHTML = mes;
            }
            console.log(param);
        }

   將你的自定義的參數,弄成數組,傳值給rawdate,然后,可以通過option ,在根據下標,就可以獲取自定義的參數:

  option.series[param.seriesIndex].rawdate[param.dataIndex]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM