android折线图点击事件,Echarts 折线统计图 在线上增添点击事件

本文围绕Echarts折线统计图展开,介绍了其基本配置代码,包括路径配置、图表初始化、选项设置等。重点阐述了为Echarts折线图添加点击事件的解决思路,给出了具体代码示例,代码涉及路径配置、图表选项设置及点击事件监听等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当前位置:我的异常网» JavaScript » Echarts 折线统计图 在线上增添点击事件

Echarts 折线统计图 在线上增添点击事件

www.myexceptions.net  网友分享于:2014-11-13  浏览:0次

Echarts 折线统计图 在线上添加点击事件

132715123.jpg

js

// JavaScript Document

// 路径配置

require.config({

paths:{

'echarts' : 'build/echarts',

'echarts/chart/bar' : 'build/echarts'

}

});

// 作为入口

require(

[

'echarts',

'echarts/chart/line'

],

function(ec) {

// 基于准备好的dom,初始化echarts图表

var myChart = ec.init(document.getElementById('main'));

option = {

tooltip : {

trigger: 'axis'

},

legend: {

data:['论坛','新闻','博客','全部']

},

toolbox: {

show : true,

feature : {

mark : {show: true},

dataView : {show: true, readOnly: false},

magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},

restore : {show: true},

saveAsImage : {show: true}

}

},

calculable : true,

xAxis : [

{

type : 'category',

boundaryGap : false,

data : ['周一','周二','周三','周四','周五','周六','周日']

}

],

yAxis : [

{

type : 'value',

splitArea : {show : true}

}

],

series : [

{

name:'论坛',

type:'line',

stack: '总量',

data:[120, 132, 101, 134, 90, 230, 210]

},

{

name:'新闻',

type:'line',

stack: '总量',

data:[220, 182, 191, 234, 290, 330, 310]

},

{

name:'博客',

type:'line',

stack: '总量',

data:[150, 232, 201, 154, 190, 330, 410]

},

{

name:'全部',

type:'line',

stack: '总量',

data:[320, 332, 301, 334, 390, 330, 320]

}

]

};

// 为echarts对象加载数据

myChart.setOption(option);

}

);

最近刚刚学使用Echarts 作图 现在想对折线图中线 添加onclick事件 请问该怎天添加

------解决思路----------------------

var xList=eval(["2010.9.11","2012.11.14","2013.3.25","2013.4.14","2013.5.2","2013.6.26","2013.7.8","2013.8.27","2013.11.9","2013.12.20"]);

var yList=eval(["36","84","232","22.5","-239","365","-239","-50","81","373"]);

// 路径配置

require.config({

paths:{

'echarts' : 'js/echarts',

'echarts/chart/bar' : 'js/echarts'

}

});

option_line = {

title : {

text: '',

subtext: ''

},

tooltip : {

trigger: 'axis'

},

legend: {

data:['synthesize'],

},

toolbox: {

show : true,

feature : {

mark : {show: true},

dataZoom : {show: true},

dataView : {show: true},

magicType : {show: true, type: ['line', 'bar']},

restore : {show: true},

saveAsImage : {show: true}

}

},

calculable : false,

xAxis : [

{

type : 'category',

boundaryGap : false,

data : xList

}

],

yAxis : [

{

type : 'value',

axisLabel : {

formatter: '{value} '

},

splitArea : {show : true}

}

],

dataZoom : {

show : true,

realtime : true,

//x: 0,

y: 460,

//width: 400,

height: 20,

//backgroundColor: 'rgba(221,160,221,0.5)',

//dataBackgroundColor: 'rgba(138,43,226,0.5)',

//fillerColor: 'rgba(38,143,26,0.6)',

//handleColor: 'rgba(128,43,16,0.8)',

//xAxisIndex:[],

//yAxisIndex:[],

start : 0,

end : 100

},

series : [

{

name:'synthesize',

type:'line',

itemStyle: {

normal: {

lineStyle: {

color:'',

shadowColor : 'rgba(0,0,0,0.3)',

shadowBlur: 5,

shadowOffsetX: 3,

shadowOffsetY: 3

}

}

},

data:yList

}

]

};//end option

require(

[

'echarts',

'echarts/chart/line',

'echarts/chart/bar'

],

function (ec) {

myChart_line_main = ec.init(document.getElementById('main'));

myChart_line_main.setOption(option_line);

var ecConfig = require('echarts/config');//alert(ecConfig);

var zrEvent = require('zrender/tool/event');

myChart_line_main.on(ecConfig.EVENT.CLICK,function (param){

var temp="";

for(var i in param){

temp += i+":"+eval("param."+i)+"\n";

}alert(temp);

});

}

);

这段代码在X.html中其他用到的js文件都存到 js/   文件夹下   js文件夹与X.html在同一目录下。zrender.js   echarts.js  ....

文章评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值