- // 折线数据
- var data = [
- { name: ‘2019/04/04 08:05:08’, value: [‘2019/04/04 08:05:08’, 80] },
- { name: ‘2019/04/04 09:05:08’, value: [‘2019/04/04 09:05:08’, 60] },
- { name: ‘2019/04/04 10:18:18’, value: [‘2019/04/04 10:18:18’, 90] },
- { name: ‘2019/04/04 11:18:18’, value: [‘2019/04/04 11:18:18’, 70] }
- ];
- // x 时间轴数据
- var anchor = [
- { name: ’07:00:00′, value: [‘2019/04/04 07:00:00’, 0] },
- { name: ’00:00:00′, value: [‘2019/04/04 14:00:00’, 0] }
- ];
- // 详细配置
- var option = {
- title: {
- text: ‘x / y 轴错位折线图’
- },
- tooltip: {
- trigger: ‘axis’,
- formatter: function (params) {
- params = params[0];
- var date = new Date(params.name);
- return date.getHours() + ‘:’ + date.getMinutes();;
- },
- axisPointer: {
- animation: false
- }
- },
- xAxis: {
- type: ‘time’,
- splitLine: {
- show: false
- },
- axisLabel: {
- formatter: function (val) {
- debugger;
- var n = new Date(val)
- return n.getHours() + ‘:’ + n.getMinutes();
- }
- },
- splitNumber: 12
- },
- yAxis: {
- type: ‘value’,
- boundaryGap: [0, ‘100%’],
- splitLine: {
- show: false
- }
- },
- series: [{
- name: ‘模拟数据’,
- type: ‘line’,
- showSymbol: false,
- hoverAnimation: false,
- data: data
- },
- {
- name: ‘anchor’,
- type: ‘line’,
- showSymbol: false,
- data: anchor,
- itemStyle: { normal: { opacity: 0 } },
- lineStyle: { normal: { opacity: 0 } }
- }]
- };
本文链接地址: echarts X / Y 错位折线图