Echarts柱状图点击事件的实现方法


点击事件绑定

click事件

onChartClick=(param,echarts)=>{

    console.log(param)

}

render(){

    let onEvents={

        'click': this.onChartClick

    }

    return(

            <ReactEcharts

                option={this.getOption()} 

                notMerge={true}

                lazyUpdate={true}

                onEvents={onEvents}

                style={{width: '100%',height:'100%'}}

            />
    )

}

 

legend标签点击事件

onChartLegendselectchanged=(param,echarts)=>{

    console.log(param)

}

render(){

    let onEvents={

        'legendselectchanged': this.onChartLegendselectchanged

    }

    return(

            <ReactEcharts

                option={this.getOption()} 

                notMerge={true}

                lazyUpdate={true}

                onEvents={onEvents}

                style={{width: '100%',height:'100%'}}

            />

    )

}

 

一、安装

npm install --save echarts-for-react
//如果需要使用echarts的一些特殊方法需要安装
npm install --save echarts

二、使用

import ReactEcharts from 'echarts-for-react';
import echarts from 'echarts';

<ReactEcharts option={this.getOption()} notMerge={true} lazyUpdate={true} onEvents={onEvents} style={{width: '100%',height:'100%'}} />


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM