初始化:
let myCharts = echarts.init(document.getElementById('xx'));初始化时可以传入主题:
let myCharts = echarts.init(document.getElementById('xx'),'dark');页面优化 : loading
myCharts.showLoading();基本用法:
let options = {
color:['#f1f2f3','#g7g3gs'], //自定义调色板,修改线条颜色
title:{
text:'基本图标'
},
tooltip:{
trigger:'axis'
},
grid:{
left:'3%',
top:'3%'
},
legend:{
data:['xx']
},
xAixs:{
type:'category',
data:[]
},
yAxis:{
type:'value'
},
series:{
type:'line',
data:[]
}
}
myCharts.setOption(options);title设置 标题
show:true,//显示策略,默认值true,可选为:true(显示) | false(隐藏)
subtext: '副标题',//副标题文本,'\n'指定换行
x:'center'//水平安放位置,默认为'left',可选为:'center' | 'left' | 'right' | {number}(x坐标,单位px)
y: 'top',//垂直安放位置,默认为top,可选为:'top' | 'bottom' | 'center' | {number}(y坐标,单位px)
textAlign: null,//水平对齐方式,默认根据x设置自动调整,可选为: left' | 'right' | 'center
backgroundColor: 'rgba(0,0,0,0)',//标题背景颜色,默认'rgba(0,0,0,0)'透明
borderColor: '#ccc',//标题边框颜色,默认'#ccc'
borderWidth: 0,//标题边框线宽,单位px,默认为0(无边框)
padding: 5,//标题内边距,单位px,默认各方向内边距为5,接受数组分别设定上右下左边距
textStyle: {//主标题文本样式{ "fontSize": 18, "fontWeight": "bolder","color": "#333"}
fontFamily: 'Arial, Verdana, sans...',
fontSize: 12,
fontStyle: 'normal',
fontWeight: 'normal',
},
subtextStyle: {//副标题文本样式{"color": "#aaa"}
fontFamily: 'Arial, Verdana, sans...',
fontSize: 12,
fontStyle: 'normal',
fontWeight: 'normal',
}
tooltip设置 提示悬浮框
show:true,//是否显示
trigger:axis|item|none,//axis(一般在柱状图、折线图中使用)item(一般在散列图、饼状图使用) none不触发
showContent:true,//显示提示框浮层,默认显示
trigger:mousemove //触发条件 mousemove、click、mousemove|click
showDelay:1000,//浮层显示的延迟,单位为ms
hideDelay:1000,//浮层关闭的延迟
position:'top',//top、left、right、bottom、[10, 10]、[50%, 50%]
formatter:'{a}:{b}',//{a}系列名{b}数据名{c}数值名{d}{e}
backgroundColor: 'rgba(0,0,0,0)',//背景颜色
borderColor: '#ccc',//边框颜色
borderWidth: 0,//边框线宽,单位px
padding: 5,//内边距,单位px
textStyle: {//文本样式
color: '',
fontSize: 12,
fontStyle: 'normal',
fontWeight: 'normal',
}
grid设置 绘图内网格
show:true,//是否显示
left:'',
right:'',
top:'',
bottom:'',
width:'',
height:'',
containLabel:true//是否包含坐标轴的刻度标签
backgroundColor: 'rgba(0,0,0,0)',//背景颜色
borderColor: '#ccc',//边框颜色
borderWidth: 0,//边框线宽,单位px
shadowbar:10,//阴影的模糊大小
shadowcolor:'',//阴影颜色
shadowoffsetX:'',//阴影水平方向偏移距离
shadowoffsetY:'',//阴影垂直方向偏移距离
legend 不同系列的标志 颜色和名字等
show:true,
...
xAxis 横坐标
show:true,type:'category',//坐标轴类型 category类目轴(离散) value 数值轴(连续数值) time 时间轴 log对数轴
min,最小刻度
max,最大刻度
axisTick:{//坐标轴相关设置
show:true //是否显示坐标轴刻度
}
axisLine:{//坐标轴轴线相关设置
show:true,//是否显示坐标轴轴线
lineStyle:{
color:'',
type:'solid'//solid 、dotted、dashed
}
}yAxis 纵坐标
show:true,type:'category',//坐标轴类型 category类目轴(离散) value 数值轴(连续数值) time 时间轴 log对数轴
min,最小刻度
max,最大刻度
axisTick:{//坐标轴相关设置
show:true //是否显示坐标轴刻度
}
axisLine:{//坐标轴轴线相关设置
show:true,//是否显示坐标轴轴线
lineStyle:{
color:'',
type:'solid'//solid 、dotted、dashed
}
}series
type:'line', // line、pie、bar
name:''//系列名称,用于tooltip的显示,legend 的图例筛选
xAxisIndex:'',
YAxisIndex:'',
itemStyle:{},
lineStyle:{},
data:{}|[]