142 lines
3.1 KiB
HTML
Generated
142 lines
3.1 KiB
HTML
Generated
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
-->
|
|
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<script src="lib/simpleRequire.js"></script>
|
|
<script src="lib/config.js"></script>
|
|
<script src="lib/facePrint.js"></script>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
</head>
|
|
<body>
|
|
<style>
|
|
html, body, #main {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
<div id="main"></div>
|
|
<script>
|
|
|
|
require([
|
|
'echarts'
|
|
], function (echarts) {
|
|
|
|
function randomData() {
|
|
return (Math.random() + 3).toFixed(3);
|
|
}
|
|
|
|
var chart = echarts.init(document.getElementById('main'));
|
|
|
|
|
|
|
|
|
|
function randomData() {
|
|
now = new Date(+now + oneDay);
|
|
value = value + Math.random() * 21 - 10;
|
|
return {
|
|
name: now.toString(),
|
|
value: [
|
|
[now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
|
|
Math.round(value)
|
|
]
|
|
}
|
|
}
|
|
|
|
var data = [];
|
|
var now = +new Date(1997, 9, 3);
|
|
var oneDay = 24 * 3600 * 1000;
|
|
var value = Math.random() * 1000;
|
|
for (var i = 0; i < 1000; i++) {
|
|
data.push(randomData());
|
|
}
|
|
|
|
option = {
|
|
title: {
|
|
text: '动态数据 + 时间坐标轴'
|
|
},
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
formatter: function (params) {
|
|
params = params[0];
|
|
var date = new Date(params.name);
|
|
return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
|
|
},
|
|
axisPointer: {
|
|
animation: false
|
|
}
|
|
},
|
|
xAxis: {
|
|
type: 'time',
|
|
splitLine: {
|
|
show: false
|
|
}
|
|
},
|
|
yAxis: {
|
|
type: 'value',
|
|
// boundaryGap: [0, '100%'],
|
|
max: 'dataMax',
|
|
minorSplitLine: {
|
|
show: true
|
|
},
|
|
minorTick: {
|
|
show: true
|
|
}
|
|
},
|
|
series: [{
|
|
name: '模拟数据',
|
|
type: 'line',
|
|
showSymbol: false,
|
|
hoverAnimation: false,
|
|
data: data
|
|
}]
|
|
};
|
|
|
|
setInterval(function () {
|
|
|
|
for (var i = 0; i < 5; i++) {
|
|
data.shift();
|
|
data.push(randomData());
|
|
}
|
|
|
|
chart.setOption({
|
|
series: [{
|
|
data: data
|
|
}]
|
|
});
|
|
}, 1000);
|
|
|
|
chart.setOption(option);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
</script>
|
|
</body>
|
|
</html> |