网格背景实线变为虚线
yAxis: {
splitLine: {
show: true,
lineStyle:{
type:'dashed'
}
}
},
调用showLoading方法
const mycharts = echarts.init(document.getElementById('echart'));
mycharts.showLoading({
text: 'loading',
color: '#c23531',
textColor: '#000',
maskColor: 'rgba(255, 255, 255, 0.2)',
zlevel: 0,
});;
setTimeout(() => {
// setOption前隐藏loading事件
mycharts.hideLoading();
mycharts.setOption(option);
}, 1000);
legend 图例进行操作
legend: {
itemWidth: 10,//宽度
itemHeight: 10,//高度
top: "85%",//位置
left: "center",
textStyle: {//设置字体
color: "#fff",
fontSize: 12
}
},
orinet:布局方式 horizontal(默认的,横向) vertical(竖直显示)
legend: {
data:['同龄普通孩子','已具备技能','已泛化技能','已掌握技能','学习中'],
orient: 'vertical', //垂直显示
y: 'center', //延Y轴居中
x: 'right' //居右显示
},
在Echarts中有两类事件:1.鼠标点击操作2.在使用交互组件后触发的行为事件
鼠标事件包括 'cilck' 单击 'dblclick' 双击 'mousedown' 按下鼠标 'monusemove' 释放鼠标 'mouseover' 鼠标进入一个节点时触发,进入子节点会再次触发 'mouseout' 鼠标离开一个节点时触发 离开父节点也会触发 事件
// 基于准备好的dom,初始化ECharts实例
var myChart = echarts.init(document.getElementById('main'));
// 指定图表的配置项和数据
var option = {
xAxis: {
data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
// 处理点击事件并且跳转到相应的百度搜索页面
myChart.on('click', function (params) {
window.open('https://www.baidu.com/s?wd=' + encodeURIComponent(params.name));
});
每一个鼠标事件都包含一个params参数包括如下
{
// 当前点击的图形元素所属的组件名称,
// 其值如 'series'、'markLine'、'markPoint'、'timeLine' 等。
componentType: string,
// 系列类型。值可能为:'line'、'bar'、'pie' 等。当 componentType 为 'series' 时有意义。
seriesType: string,
// 系列在传入的 option.series 中的 index。当 componentType 为 'series' 时有意义。
seriesIndex: number,
// 系列名称。当 componentType 为 'series' 时有意义。
seriesName: string,
// 数据名,类目名
name: string,
// 数据在传入的 data 数组中的 index
dataIndex: number,
// 传入的原始数据项
data: Object,
// sankey、graph 等图表同时含有 nodeData 和 edgeData 两种 data,
// dataType 的值会是 'node' 或者 'edge',表示当前点击在 node 还是 edge 上。
// 其他大部分图表中只有一种 data,dataType 无意义。
dataType: string,
// 传入的数据值
value: number|Array
// 数据图形的颜色。当 componentType 为 'series' 时有意义。
color: string
}
暂时先更这么多