(https://github.com/apache/incubator-echarts/blob/master/index.js)
tooltip: {
enterable: true //鼠标是否可进入提示框浮层中
},
tooltip: {
confine: true
},
tooltip: {
extraCssText: 'z-index:999'
},
label: {
normal: {
formatter: '{a|{c}}\n{b|{b}}\n{hr|}\n\n\n',
rich: {
a: {
fontSize: 18,
lineHeight: 25,
align: 'left'
},
b: {
align: 'left',
fontSize: 12,
lineHeight: 12,
color: "#999999"
},
}
}
}
// 或者
tooltip : {
formatter: function (params) {
return “名称:” +params.name
}
}
tooltip: {
formatter: function(a) {
return '' + a + ''
}
}
// x轴和y轴的
dataZoom: [
{
type: 'inside', // 内置在坐标系中 通过鼠标滚轮或者手指touch进行处罚
start: 50,
end: 100
}
]
dataZoom: [
{
type: 'slider', // 在外部 显示为滑动条形的一个组件,可直接拖动使用
start: 50,
end: 100
}
]
xAxis: {
axisLabel: {
rotate:40
}
}
xAxis: {
axisLabel: {
interval: 0,
formatter:function(value)
{
return value.split("").join("\n");
}
}
}
grid: {
top: '10%',
right: '10%',
bottom: '10%',
left: '10%'
},
series: [{
name: '高于拿地版',
type: 'bar',
barWidth: '24',
stack: 'cost', // 代表叠加的形态,如果去掉这个,该条就会单独出来
data: [20,30,10]
},
{
name: '与拿地版持平',
type: 'bar',
barWidth: '24',
stack: 'cost',
data: [10,20,30]
}]
series: [{
type: 'bar',
data: [],
markLine: {
symbol: "none", // 去除平均线的箭头
data: [
{
type: 'average',
name: '平均线',
lineStyle: {
width: 1,
color: "#D7372F"
},
label: {
fontSize: 11,
lineHeight: 15,
color: '#666666',
position: 'insideEndTop',
formatter: '{b}:{c}',
},
}
]
}
}]
或
series: [{
type: 'bar',
data: [10,20,10],
},{
type: 'line',
data: [10,20,10],
markLine: {
symbol: "none", // 去除平均线的箭头
data: [
{
type: 'average',
name: '平均线',
lineStyle: {
width: 1,
color: "#D7372F"
},
label: {
fontSize: 11,
lineHeight: 15,
color: '#666666',
position: 'insideEndTop',
formatter: '{b}:{c}',
},
}
]
}
}]
// zoneJson为要渲染的地图json
echarts.registerMap('zone', zoneJson);
option = {
geo: {
map: 'zone', // 地图
zoom: 1.2,
roam: true, // 地图可拖动
label: {
normal: {
show: true, // 是否显示对应地名
}
},
},
}
// on(eventName,function)
// ('click'、'dblclick'、'mousedown'、'mousemove'、'mouseup'、'mouseover'、'mouseout'、'globalout'、'contextmenu')
myChart.on('click', function (params) {
console.log(params.name);
});
//chart.on(eventName, query, handler)
// 使用 query 只对指定的组件的图形元素的触发回调
chart.on('click', 'series', function () {})
chart.on('click', 'series.line', function () {})
chart.on('click', 'dataZoom', function () {})
chart.on('click', 'xAxis.category', function () {})
// 例: 给x轴的文字添加点击事件,y轴同理
// 将xAxis或者yAxis的属性triggerEvent 置为 true;
chart.on('click', 'xAxis', function () {})
// 移除事件(避免点击事件重复促发)
myChart.off('click')
myChart.showLoading({
text: "图表数据正在努力加载...",
x: "center",
y: "center",
textStyle: {
color:"red",
fontSize:14
},
effect:"spin"
});
myChart.hideLoading();
window.onresize = this.myChart.resize
myChart.clear()
myChart.dispose()
// 可选png, jpeg
myChart.getDataURL("png")
myChart.dispatchAction({
type: 'highlight', // highlight/ downplay
seriesIndex: 0, // series数组里面的下标
dataIndex: 0 // 数据的下标
});
myChart.dispatchAction({
type: 'highlight',
// 可选,系列 index,可以是一个数组指定多个系列
seriesIndex?: number|Array,
// 可选,系列名称,可以是一个数组指定多个系列
seriesName?: string|Array,
// 可选,数据的 index
dataIndex?: number,
// 可选,数据的 名称
name?: string
})
myChart.dispatchAction({
type: 'legendSelect',
// 图例名称
name: string
})
myChart.dispatchAction({
type: 'legendScroll',
scrollDataIndex: number,
legendId: string
})
myChart.dispatchAction({
type: 'legendScroll',
scrollDataIndex: number,
legendId: string
})
myChart.dispatchAction({
type:'showTip',
//屏幕上的x坐标
x: number,
//屏幕上的y坐标
y: number,
//本次显示tooltip的位置,只在本次action生效。缺省则使用option中定义的tooltip位置
position: Array.<number> | String | Function
})
// 或
myChart.dispatch({
type: 'showTip',
// 系列的 index,在 tooltip 的 trigger 为 axis 的时候可选。
seriesIndex?: number,
// 数据的 index,如果不指定也可以通过 name 属性根据名称指定数据
dataIndex?: number,
// 可选,数据名称,在有 dataIndex 的时候忽略
name?: string,
// 本次显示 tooltip 的位置。只在本次 action 中生效。
// 缺省则使用 option 中定义的 tooltip 位置。
position: Array.<number>|string|Function,
})
持续更新…