交易深度图怎么用echarts做
配置项如下
option = {
backgroundColor: '#fff',
tooltip: {
trigger: 'axis',
formatter: (params, ticket, callback) => {
//console.log(option.tooltip.borderColor)
let str = '';
let tit = "委托价";
for (let i = 0; i < params.length; i++) {
str = tit + params[i].value[0] + '<br />' +
params[i].seriesName + ': ฿' + Math.round(params[i].value[1]);
}
return str
},
axisPointer: {
type: 'line',
opacity: 0,
snap: true,
lineStyle: {
opacity: 0,
width: 0
}
},
grid: {
bottom: 100,
x: 100
},
textStyle: {
fontSize: 12,
color: '#666',
fontFamily: 'sans-serif'
},
backgroundColor: '#fff',
borderColor: '#ccc',
borderWidth: 1,
// trigger: 'axis'
},
legend: {
itemWidth: 10,
data: [{
name: "累计买单",
icon: 'circle',
}, {
name: "累计卖单",
icon: 'circle',
}],
// data:['累计买单','累计卖单'],
bottom: 4,
padding: [20, 0, 0, 0],
textStyle: {
fontSize: 12
}
},
title: {
left: 'center',
text: "深度10%",
textStyle: {
fontSize: 14,
fontWeight: 400,
color: '#666'
}
},
toolbox: {
show: false
},
xAxis: {
type: 'value',
scale: true,
nameGap: 26,
name: 'BTC' + ' ' + "价格",
nameLocation: 'middle',
nameTextStyle: {
fontSize: 12,
color: '#666'
},
splitLine: {
show: false
},
axisTick: {
alignWithLabel: true
},
axisLabel: {
interval: 0,
formatter: function(params, ticket, callback) {
// return '$' + parseInt(params)
//console.log(params,formatMoney(params,'$'))
return formatMoney(params, '$')
}
},
min: function(val) {
return val.min
},
max: function(val) {
return val.max
}
},
yAxis: {
type: 'value',
name: 'BTC' + ' ' + "数量",
nameRotate: 90,
nameLocation: 'middle',
nameTextStyle: {
fontSize: 12,
color: '#666'
},
splitLine: {
show: false
},
nameGap: 46,
axisLabel: {
interval: 0,
formatter: function(params, ticket, callback) {
return params + '฿'
}
},
max: function(val) {
let v = parseInt(val.max) % 10;
let n = 10;
if (v > 0) {
n = v;
}
return parseInt(val.max) + 10 + (10 - n)
}
},
dataZoom: [{
type: 'inside',
disabled: true
}],
series: [{
name: "累计买单",
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 5,
showSymbol: false,
itemStyle: {
normal: {
color: '#0FB14B',
borderWidth: 1,
borderColor: '#fff'
}
},
areaStyle: {
normal: {
color: '#0FB14B',
}
},
data: [
[5800.0, 32.6912],
[6000.0, 32.690200000000004],
[6100.0, 28.757600000000004],
[6200.0, 28.657600000000002],
[6300.0, 28.5576],
[6400.0, 28.4576],
[6500.0, 28.357599999999998],
[7000.0, 27.857599999999998],
[7098.0, 11.857599999999998],
[7500.0, 11.856599999999998],
[7600.0, 11.748999999999999],
[8022.2, 11.348999999999998],
[8027.13, 10.151499999999999],
[8029.4, 8.9073],
[8037.52, 7.6544],
[8079.85, 6.407],
[8085.9, 5.0578],
[8095.76, 3.8316],
[8097.14, 2.6899],
[8199.9, 1.4302000000000001],
[8202.0, 0.6911]
]
},
{
name: "累计卖单",
type: 'line',
smooth: true,
symbol: 'diamond',
showSymbol: false,
symbolSize: 5,
itemStyle: {
normal: {
color: '#A50000',
borderWidth: 1,
borderColor: '#fff'
}
},
areaStyle: {
normal: {
color: '#A50000'
}
},
data: [
[8269.0, 0.4416],
[8319.48, 1.8422],
[8323.8, 3.3439],
[8337.25, 4.6240000000000006]
],
}
]
};