<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
最近做大屏相關需求,產品說需要炫酷一點的效果,於是做了一些echart相關的動效
設定dataZoom當前縮放值,加定時器,實現輪播效果。
範例:
option = { color: ['#1E90FF', '#FFA500'], tooltip: { trigger: 'axis', axisPointer: {} }, grid: { left: 20, right: 20, bottom: 0, containLabel: true }, legend: { data: [ { name: '負載電量', itemStyle: { color: '#FAAD14' } }, { name: '中央空調冷量', itemStyle: { color: '#01E6F5' } } ], textStyle: { color: '#fff' } }, dataZoom: { type: 'inside' }, xAxis: [ { type: 'category', axisLabel: { margin: 20, textStyle: { color: '#fff' } }, data: [ '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', '00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00' ], axisPointer: { type: 'shadow' } } ], yAxis: [ { type: 'value', name: 'kWh', nameTextStyle: { color: '#fff' }, splitLine: { show: true, lineStyle: { color: 'rgba(255, 255, 255, 0.2)' } }, axisLabel: { margin: 20, textStyle: { color: '#fff' } } }, { type: 'value', name: 'kWh', nameTextStyle: { color: '#fff' }, splitLine: { show: false, lineStyle: { color: 'rgba(255, 255, 255, 0.2)' } }, axisLabel: { margin: 20, textStyle: { color: '#d1e6eb' } } } ], series: [ { name: '負載電量', type: 'bar', yAxisIndex: 0, itemStyle: { color: { x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(250,173,20, 1)' }, { offset: 0.5, color: 'rgba(250,173,20, 0.8)' }, { offset: 1, color: 'rgba(250,173,20,0.5)' } ] } }, tooltip: { valueFormatter(value) { if (typeof value === 'number') return value.toFixed(2) + 'kWh'; else return '-'; } }, data: [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name: '中央空調冷量', type: 'bar', yAxisIndex: 1, itemStyle: { color: { x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(1,230,245, 1)' }, { offset: 0.5, color: 'rgba(1,230,245, 0.8)' }, { offset: 1, color: 'rgba(1,230,245,0.5)' } ] } }, tooltip: { valueFormatter(value) { if (typeof value === 'number') return value.toFixed(2) + 'kWh'; else return '-'; } }, data: [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.10333333333333333, 0.0, 0.0, 0.0, 3.5133333333333336, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 2.2733333333333334, 0.0 ] } ], func: (myChart, option) => { let start = 0, end = 7; option.dataZoom.startValue = option.xAxis[0].data[start]; // option.dataZoom.endValue = option.xAxis[0].data[end]; myChart.setOption(option); if (this.electInterval) { clearInterval(this.electInterval); } this.electInterval = setInterval(function () { option.dataZoom.startValue = option.xAxis[0].data[start]; option.dataZoom.endValue = option.xAxis[0].data[end]; myChart.setOption(option); start += 1; end += 1; if (end >= option.xAxis[0].data.length) { end = 7; start = 0; } }, 5000); }, }; option.func(myChart, option)
多條曲線疊加,但注意,需要監聽legendselectchanged事件,
option = { tooltip: { trigger: 'axis', show: true, }, grid: { left: 20, right: 20, bottom: 0, containLabel: true, }, dataZoom: { type: 'inside', }, legend: { textStyle: { color: '#fff', borderColor: '#fff' } }, func: (myChart, option) => { // 修復無圖表資料切換bug if (option.series[0].data.length <= 0 && option.series[1].data.length <= 0) { return; } option.series[2].data = option.series[0].data; option.series[3].data = option.series[0].data; option.series[4].data = option.series[1].data; option.series[5].data = option.series[1].data; // setTimeout修復初始載入動效沒生效bug setTimeout(() => { myChart.clear(); myChart.setOption(option); }, 100) if (this.loadInterval) { clearInterval(this.loadInterval); } this.loadInterval = setInterval(() => { myChart.clear(); myChart.setOption(option); }, 6000); myChart.on('legendselectchanged', function (params) { let selectArr = Object.values(params.selected); option.series[2].data = option.series[0].data; option.series[3].data = option.series[0].data; option.series[4].data = option.series[1].data; option.series[5].data = option.series[1].data; if (!selectArr[0]) { option.series[2].data = []; option.series[3].data = []; } if (!selectArr[1]) { option.series[4].data = []; option.series[5].data = []; } myChart.setOption(option); }); }, xAxis: [ { type: 'category', boundaryGap: true, axisLine: { show: true, lineStyle: { color: 'rgba(255, 255, 255, 0.2)' } }, axisLabel: { textStyle: { color: '#fff', margin: 15 } }, axisTick: { show: false }, data: ['10:55','11:00','11:05','11:10','11:15','11:20','11:25','11:30','11:35','11:40','11:45','11:50','11:55','12:00','12:05','12:10','12:15','12:20','12:25','12:30','12:35','12:40','12:45','12:50','12:55','13:00','13:05','13:10','13:15','13:20','13:25','13:30','13:35','13:40','13:45','13:50','13:55','14:00','14:05','14:10','14:15','14:20','14:25','14:30','14:35','14:40','14:45','14:50','14:55','15:00','15:05','15:10','15:15','15:20','15:25','15:30','15:35','15:40','15:45','15:50','15:55','16:00','16:05','16:10','16:15','16:20','16:25','16:30','16:35','16:40','16:45','16:50','16:55','17:00','17:05','17:10','17:15','17:20','17:25','17:30','17:35','17:40','17:45','17:50','17:55','18:00','18:05','18:10','18:15','18:20','18:25','18:30','18:35','18:40','18:45','18:50','18:55','19:00','19:05','19:10','19:15','19:20','19:25','19:30','19:35','19:40','19:45','19:50','19:55','20:00','20:05','20:10','20:15','20:20','20:25','20:30','20:35','20:40','20:45','20:50','20:55','21:00','21:05','21:10','21:15','21:20','21:25','21:30','21:35','21:40','21:45','21:50','21:55','22:00','22:05','22:10','22:15','22:20','22:25','22:30','22:35','22:40','22:45','22:50','22:55','23:00','23:05','23:10','23:15','23:20','23:25','23:30','23:35','23:40','23:45','23:50','23:55','00:00','00:05','00:10','00:15','00:20','00:25','00:30','00:35','00:40','00:45','00:50','00:55','01:00','01:05','01:10','01:15','01:20','01:25','01:30','01:35','01:40','01:45','01:50','01:55','02:00','02:05','02:10','02:15','02:20','02:25','02:30','02:35','02:40','02:45','02:50','02:55','03:00','03:05','03:10','03:15','03:20','03:25','03:30','03:35','03:40','03:45','03:50','03:55','04:00','04:05','04:10','04:15','04:20','04:25','04:30','04:35','04:40','04:45','04:50','04:55','05:00','05:05','05:10','05:15','05:20','05:25','05:30','05:35','05:40','05:45','05:50','05:55','06:00','06:05','06:10','06:15','06:20','06:25','06:30','06:35','06:40','06:45','06:50','06:55','07:00','07:05','07:10','07:15','07:20','07:25','07:30','07:35','07:40','07:45','07:50','07:55','08:00','08:05','08:10','08:15','08:20','08:25','08:30','08:35','08:40','08:45','08:50','08:55','09:00','09:05','09:10','09:15','09:20','09:25','09:30','09:35','09:40','09:45','09:50','09:55','10:00','10:05','10:10','10:15','10:20','10:25','10:30','10:35','10:40','10:45','10:50','10:55',] } ], yAxis: [ { type: 'value', name: 'kW', nameTextStyle: { color: '#fff' }, splitNumber: 7, splitLine: { show: true, lineStyle: { color: 'rgba(255, 255, 255, 0.2)' } }, axisLine: { show: false }, axisLabel: { margin: 20, textStyle: { color: '#d1e6eb' } }, axisTick: { show: false } }, { type: 'value', name: 'kW', splitNumber: 7, nameTextStyle: { color: '#fff' }, splitLine: { show: false, lineStyle: { color: 'rgba(255, 255, 255, 0.2)' } }, axisLine: { show: false }, axisLabel: { margin: 20, textStyle: { color: '#d1e6eb' } }, axisTick: { show: false } } ], series: [ { name: '電負荷', type: 'line', smooth: true, symbol: 'none', animation: false, areaStyle: { color: { x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(250,173,20, 1)' }, { offset: 0.5, color: 'rgba(250,173,20, 0.8)' }, { offset: 1, color: 'rgba(250,173,20,0.5)' } ] } }, color: '#FAAD14', tooltip: { trigger: 'axis', show: true, valueFormatter(value) { if (typeof value === 'number') return value.toFixed(2) + 'kW'; else return '-'; }, }, data: [0.0,0.0,0.0,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0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,] }, { name: '空調負荷', type: 'line', smooth: true, symbol: 'none', yAxisIndex: 1, animation: false, areaStyle: { color: { x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(1,230,245, 1)' }, { offset: 0.5, color: 'rgba(1,230,245, 0.8)' }, { offset: 1, color: 'rgba(1,230,245,0.5)' } ] } }, color: '#01E6F5', tooltip: { trigger: 'axis', show: true, valueFormatter(value) { if (typeof value === 'number') return value.toFixed(2) + 'kW'; else return '-'; }, }, data: [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,6.2,6.2,6.2,6.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,6.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,6.2,0.0,0.0,0.0,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,6.2,3.634,6.2,6.2,6.2,6.2,6.2,] }, { type: 'line', smooth: true, lineStyle: { color: '#FFDF6F', join: 'round', shadowColor: '#FFDF6F', shadowBlur: 6 }, tooltip: { trigger: 'axis', show: false }, symbol: 'none', animationDelay: 50, animationDuration: 5000, data: [] }, { type: 'line', smooth: true, lineStyle: { color: '#FAAD14' }, tooltip: { trigger: 'axis', show: false }, symbol: 'none', animationDelay: 700, animationDuration: 5000, data: [] }, { type: 'line', smooth: true, yAxisIndex: 1, lineStyle: { color: '#88F8FF', join: 'round', shadowColor: '#88F8FF', shadowBlur: 6 }, tooltip: { trigger: 'axis', show: false }, symbol: 'none', animationDelay: 50, animationDuration: 5000, data: [] }, { type: 'line', smooth: true, yAxisIndex: 1, lineStyle: { color: '#01E6F5' }, tooltip: { trigger: 'axis', show: false }, symbol: 'none', animationDelay: 700, animationDuration: 5000, data: [] } ] } option.func(myChart, option)
使用highlight, downplay
option = { color: '#5470c6', textStyle: { color: 'rgba(255,255,255, 0.65)' }, grid: { containLabel: true, show: false, left: '0%', top: '18%', right: '3%', bottom: '4%' }, xAxis: { type: 'category', data: [ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31' ] }, yAxis: { type: 'value', name: '電量 (kWh)', nameTextStyle: { padding: [0, 0, 0, 12] }, axisLine: { show: false }, splitLine: { show: true, lineStyle: { color: 'rgba(255,255,255,0.1)' } } }, series: [ { data: [ { value: 60.0, name: '01', text: 60.0, showText: '100' }, { value: 15.96, name: '02', text: 15.96, showText: '100' }, { value: 34.95, name: '03', text: 34.95, showText: '100' }, { value: 30.16, name: '04', text: 30.16, showText: '100' }, { value: 44.36, name: '05', text: 44.36, showText: '100' }, { value: 43.99, name: '06', text: 43.99, showText: '100' }, { value: 34.62, name: '07', text: 34.62, showText: '100' }, { value: 106.42, name: '08', text: 106.42, showText: '100' }, { value: 101.34, name: '09', text: 101.34, showText: '100' }, { value: 119.57, name: '10', text: 119.57, showText: '100' }, { value: 107.8, name: '11', text: 107.8, showText: '100' }, { value: 112.52, name: '12', text: 112.52, showText: '100' }, { value: 116.99, name: '13', text: 116.99, showText: '100' }, { value: 109.11, name: '14', text: 109.11, showText: '100' }, { value: 86.08, name: '15', text: 86.08, showText: '100' }, { value: 95.06, name: '16', text: 95.06, showText: '100' }, { value: 91.39, name: '17', text: 91.39, showText: '100' }, { value: 77.3, name: '18', text: 77.3, showText: '100' }, { value: 88.7, name: '19', text: 88.7, showText: '100' }, { value: 116.72, name: '20', text: 116.72, showText: '100' }, { value: 105.08, name: '21', text: 105.08, showText: '100' }, { value: 47.76, name: '22', text: 47.76, showText: '100' }, { value: 0.0, name: '23', text: 0.0, showText: '100' }, { value: 0.0, name: '24', text: 0.0, showText: '100' }, { value: 0.0, name: '25', text: 0.0, showText: '100' }, { value: 0.0, name: '26', text: 0.0, showText: '100' }, { value: 0.0, name: '27', text: 0.0, showText: '100' }, { value: 0.0, name: '28', text: 0.0, showText: '100' }, { value: 0.0, name: '29', text: 0.0, showText: '100' }, { value: 0.0, name: '30', text: 0.0, showText: '100' }, { value: 0.0, name: '31', text: 0.0, showText: '100' } ], type: 'bar', smooth: true, itemStyle: { normal: { color: function (params) { const lastIndex = 21; const commonColorOption = { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, global: false // 預設為 false }; if (params.dataIndex === lastIndex) { return Object.assign(commonColorOption, { colorStops: [ { offset: 0, color: '#FFB600' }, { offset: 1, color: '#ffb60021' } ] }); } return Object.assign(commonColorOption, { colorStops: [ { offset: 0, color: '#01E6F5' }, { offset: 1, color: '#1890ff24' } ] }); }, barBorderRadius: [1, 1, 0, 0] } }, emphasis: { itemStyle: { shadowColor: '#fff', shadowBlur: 10 } } } ], tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', label: { backgroundColor: '#6a7985' } }, formatter: function (datas) { var res = datas[0].name + '<br/>'; res = res + '電量 (kWh):' + datas[0].data.text; return res; } }, func: (myChart, option, isSame) => { this.historyTimer && clearInterval(this.historyTimer); const indexString = sessionStorage.getItem( 'monitor_screen_generation_history_index' ); let index = isSame && indexString ? Number(indexString) : -1; //高亮所在下標 let dataLength = 22; this.historyTimer = setInterval(() => { index = (index + 1) % dataLength; const newData = option.series[0].data.map((item, i) => { let newItem; if (index === i) { const color = i === dataLength - 1 ? '#FAAD14' : '#01E6F5'; newItem = Object.assign(item, { label: { show: true, position: 'top', color: color, fontSize: '12px', formatter: (params) => { return params.value[params.encode.x[0]]; } } }); } else { newItem = Object.assign(item, { label: null }); } return newItem; }); if (index > dataLength) { index = 0; } sessionStorage.setItem( 'monitor_screen_generation_history_index', JSON.stringify(index) ); option.series[0].data = newData; myChart.setOption(option); myChart.dispatchAction({ type: 'downplay', seriesIndex: new Array(index + 1).fill(1).map((v, i) => i) }); myChart.dispatchAction({ type: 'highlight', seriesIndex: 0, dataIndex: index }); }, 2000); } }; option.func(myChart, option)
以上就是echart實現大屏動效範例詳解的詳細內容,更多關於echart大屏動效的資料請關注it145.com其它相關文章!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45