Toggle navigation
窗口人员在线
By
神经质Dusty521
2018-11-28 13:33:46
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
//获取当前日期 function getNowFormatDate() { var date = new Date(); var seperator1 = "/"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; return currentdate; } var data = []; //开始时间和结束时间 var endTime = getNowFormatDate() + ' 18:00'; var startTime = getNowFormatDate() + ' 8:00'; //Y 坐标的值 var categories = ['王伟', '李明', '张三', '李四', '王五'] // 人员状态 var types = [{ name: '在线', color: '#46BCFF' }, { name: '离线', color: '#FF5959' }, { name: '暂停', color: '#D9D9D9' }, { name: '延时服务在线', color: '#00FAFC' } ]; //服务端获取数据组装数据 // data.push({ // name: typeItem.name, // value: [ // index, // baseTime, // baseTime += duration, // duration // ], // itemStyle: { // normal: { // color: typeItem.color // } // } // }); //模拟数据 data = [{ name: '在线', value: [0, '2018/12/4 8:00', '2018/12/4 9:12'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [0, '2018/12/4 9:12', '2018/12/4 9:30'], itemStyle: { normal: { color: '#FF5959' } } }, { name: '暂停', value: [0, '2018/12/4 9:30', '2018/12/4 10:30'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '延时服务在线', value: [0, '2018/12/4 10:30', '2018/12/4 19:00'], itemStyle: { normal: { color: '#00FAFC' } } }, { name: '在线', value: [1, '2018/12/4 8:00', '2018/12/4 9:12'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [1, '2018/12/4 9:12', '2018/12/4 9:30'], itemStyle: { normal: { color: '#FF5959' } } }, { name: '暂停', value: [1, '2018/12/4 9:30', '2018/12/4 10:30'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '延时服务在线', value: [1, '2018/12/4 10:30', '2018/12/4 12:00'], itemStyle: { normal: { color: '#00FAFC' } } }, { name: '在线', value: [1, '2018/12/4 14:00', '2018/12/4 18:12'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '暂停', value: [1, '2018/12/4 12:00', '2018/12/4 14:00'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '在线', value: [2, '2018/12/4 8:00', '2018/12/4 9:12'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [2, '2018/12/4 9:12', '2018/12/4 9:30'], itemStyle: { normal: { color: '#FF5959' } } }, { name: '暂停', value: [2, '2018/12/4 9:30', '2018/12/4 10:30'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '延时服务在线', value: [2, '2018/12/4 10:30', '2018/12/4 12:00'], itemStyle: { normal: { color: '#00FAFC' } } }, { name: '在线', value: [2, '2018/12/4 14:00', '2018/12/4 18:12'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '暂停', value: [2, '2018/12/4 12:00', '2018/12/4 14:00'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '在线', value: [3, '2018/12/4 8:00', '2018/12/4 12:00'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [3, '2018/12/4 12:00', '2018/12/4 13:30'], itemStyle: { normal: { color: '#FF5959' } } }, { name: '暂停', value: [3, '2018/12/4 13:30', '2018/12/4 14:00'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '延时服务在线', value: [3, '2018/12/4 14:00', '2018/12/4 14:02'], itemStyle: { normal: { color: '#00FAFC' } } }, { name: '在线', value: [3, '2018/12/4 14:02', '2018/12/4 17:12'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [3, '2018/12/4 17:12', '2018/12/4 18:00'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '在线', value: [4, '2018/12/4 8:00', '2018/12/4 9:00'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [4, '2018/12/4 9:00', '2018/12/4 10:30'], itemStyle: { normal: { color: '#FF5959' } } }, { name: '暂停', value: [4, '2018/12/4 10:30', '2018/12/4 11:00'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '延时服务在线', value: [4, '2018/12/4 11:00', '2018/12/4 13:00'], itemStyle: { normal: { color: '#00FAFC' } } }, { name: '在线', value: [4, '2018/12/4 13:00', '2018/12/4 14:00'], itemStyle: { normal: { color: '#46BCFF' } } }, { name: '离线', value: [4, '2018/12/4 14:00', '2018/12/4 15:00'], itemStyle: { normal: { color: '#D9D9D9' } } }, { name: '延时服务在线', value: [4, '2018/12/4 15:00', '2018/12/4 16:00'], itemStyle: { normal: { color: '#00FAFC' } } }, { name: '在线', value: [4, '2018/12/4 16:00', '2018/12/4 18:00'], itemStyle: { normal: { color: '#46BCFF' } } }, ] function renderItem(params, api) { var categoryIndex = api.value(0); var start = api.coord([api.value(1), categoryIndex]); var end = api.coord([api.value(2), categoryIndex]); var height = api.size([0, 1])[1] * 0.6; return { type: 'rect', shape: echarts.graphic.clipRectByRect({ x: start[0], y: start[1] - height / 2, width: end[0] - start[0], height: height }, { x: params.coordSys.x, y: params.coordSys.y, width: params.coordSys.width, height: params.coordSys.height }), style: api.style() }; } option = { //提示框组件 tooltip: { formatter: function(params) { //拼接显示参数 return params.marker + params.name + ' : ' + params.value[1] + ' - ' + params.value[2]; } }, title: { text: '', left: 'center' }, //图例相关属性 legend: { data: types, selectedMode: false, }, //区域缩放 (请勿修改) dataZoom: [{ type: 'slider', filterMode: 'weakFilter', showDataShadow: false, top: 400, height: 10, borderColor: 'transparent', backgroundColor: '#e2e2e2', handleIcon: 'M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z', // jshint ignore:line handleSize: 20, handleStyle: { shadowBlur: 6, shadowOffsetX: 1, shadowOffsetY: 2, shadowColor: '#aaa' }, labelFormatter: '' }, { type: 'inside', filterMode: 'weakFilter' }], //图表高 grid: { height: 300 }, //X轴属性 xAxis: { type: 'time', min: startTime, max: endTime, scale: true }, //Y轴属性 yAxis: { data: categories }, series: [{ name: types[0].name, type: 'bar', data: [], color: '#46BCFF' }, { name: types[1].name, type: 'bar', data: [], color: '#FF5959' }, { name: types[2].name, type: 'bar', data: [], color: '#D9D9D9' }, { name: types[3].name, type: 'bar', data: [], color: '#00FAFC' }, { type: 'custom', //开发者自己提供图形渲染的逻辑。这个渲染逻辑一般命名为 renderItem renderItem: renderItem, itemStyle: { normal: { //图形透明度 opacity: 1.0 } }, encode: { // 表示维度 1、2映射到 x 轴。 x: [1, 2], y: 0, }, data: data } ] };