echarts2添加点击事件+条形图单条背景
来源:互联网 发布:淘宝助理发布宝贝教程 编辑:程序博客网 时间:2024/05/29 16:57
<div id="abcd" style="width:1300px;height:360px; "></div>
首先引进echarts模块化文件
然后require进模块
require.config({
paths: {
echarts: 'js/echarts/'
}
});
require(
[
'echarts',
'echarts/chart/gauge', // 按需加载所需图表,如需动态类型切换功能,别忘了同时加载相应图表
'echarts/chart/line',
'echarts/chart/bar',
'echarts/chart/pie',
],
function (ec) {
//获取ID
var myChartHideBar6= ec.init(document.getElementById('abcd'));
hideBarOption6 = {
tooltip: {
show: false,
},
toolbox: {
show: false,
},
calculable: false,
grid: {
y: 30,
x: 100,
x2: 400,
borderWidth: 0,
},
xAxis: [
{
type: 'value',
axisLabel: {
show: false,
interval: 'auto', // {number}
textStyle: {
color: '#fff',
fontFamily: 'sans-serif',
fontSize: 15,
}
},
axisLine: { // 轴线
show: false,
},
splitLine: {//中间分隔线
show: false,
},
}
],
yAxis: [
{
type: 'category',
axisLabel: {
show: true,
interval: 'auto', // {number}
textStyle: {
color: '#fff',
fontFamily: 'sans-serif',
fontSize: 15,
}
},
axisLine: { // 轴线
show: false,
},
splitLine: {//中间分隔线
show: false,
},
data: [8,7,6,5,4,3,2,1]
},
//辅助x轴 条形图背景关键1
{
type: 'category',
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
},
splitArea: {
show: false
},
splitLine: {
show: false
},
data: [8,7,6,5,4,3,2,1]
}
],
series: [
{
name: '',
type: 'bar',
barGap: 10,
barWidth: 20,
itemStyle: {
normal: {
color: '#0e7ea5',
label: {
show: false,
position: 'insideRight',
formatter: '{c} 个'
}
}
},
data: ["42", "33", "88", "58", "42", "33", "15", "33", ]
},
{
name: '',
type: 'bar',
barWidth: 20,
yAxisIndex: 1, 条形图背景关键2
itemStyle: {
normal:
{
color: 'rgba(120,203,253,0.2)',
label: {
show: true,
position: 'right',
formatter: function (params) {
for (var i = 0, l = hideBarOption6.yAxis[0].data.length; i < l; i++) {
if (hideBarOption6.yAxis[0].data[i] == params.name) {
return hideBarOption6.series[0].data[i] ;
}
}
},
textStyle: {
color: '#d5d5d5'
}
}
},
emphasis: {
color: 'rgba(120,203,253,0.1)',
},
},
data: [100, 100, 100, 100, 100, 100, 100, 100, 100]
},
]
};
var ecConfig = require('echarts/config');
function eConsole(param) {
console.log(param.dataIndex);//打印当前点击的index值
}
myChartHideBar6.on(ecConfig.EVENT.CLICK, eConsole);
myChartHideBar6.setOption(hideBarOption6);
此图是条形图背景效果图
}
)
- echarts2添加点击事件+条形图单条背景
- iOS给背景添加点击事件
- 给lineLayout添加点击事件,点击后改变背景
- 自定义TextView设置边框与背景颜色添加点击事件,点击更改随机数与背景
- ImageButton点击背景切换事件
- UIView 添加点击事件
- xcode添加点击事件
- Flash添加点击事件
- UILabel添加点击事件
- UIimageView添加点击事件
- echarts添加点击事件
- UILabel添加点击事件
- UIImageView添加点击事件
- 添加按钮点击事件
- UIView添加点击事件
- ECharts 添加点击事件
- RecyclerView添加点击事件
- RecyclerView添加点击事件
- ZCMU-1679-查找2(二分上界)
- javascript中的this使用总结
- Retrofit简介
- [JAVASCRIPT] Permutation 递归算法以及结果筛选
- Java Random
- echarts2添加点击事件+条形图单条背景
- sqrt(a) 返回值为0的问题
- 前台提示框是否删除
- 二叉树序列化
- 【面经】2016年【阿里实习内推电面】
- user XXX is currently used by process
- Android开发相关软件
- 小白从linux到放弃第一篇
- C++11之模板别名&函数模板的默认模板参数