1 Star 26 Fork 5

losting/timeline

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
Muhammad Towfique Imam 提交于 2024-11-30 14:23 . Added timezone support
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="https://github.com/thelostword" />
<title>timeline</title>
</head>
<body>
<canvas id="Timeline"></canvas>
<div>
<span>current time:</span>
<br>
<strong id="TimeValue"></strong>
<br>
<span>Time Range:</span>
<br>
<strong id="TimeRange"></strong>
<br>
<span>Number of milliseconds per pixel:</span>
<br>
<strong id="MsPerPixel"></strong>
</div>
<script type="module">
import TimeLine, { format } from './dist/timeline.es.js';
const timezone = 'America/New_York';
const timeline = new TimeLine('#Timeline', {
timezone,
fill: false,
zoom: 4,
});
timeline.draw({
currentTime: 1651827817000,
areas: [{
startTime: 1651827433000,
endTime: 1651829413000,
bgColor: '#f897aa'
},{
startTime: 1651829533000,
endTime: 1651832533000,
}],
});
const TimeValue = document.querySelector('#TimeValue');
TimeValue.textContent = format(timeline.getCurrentTime(), 'YYYY-MM-DD HH:mm:ss', timezone);
const TimeRange = document.querySelector('#TimeRange');
const timeRange = timeline.getTimeRange();
TimeRange.textContent = timeRange ? `${format(timeRange[0], 'YYYY-MM-DD HH:mm:ss', timezone)} ~ ${format(timeRange[1], 'YYYY-MM-DD HH:mm:ss', timezone)}` : 'Undefined';
const MsPerPixel = document.querySelector('#MsPerPixel');
MsPerPixel.textContent = `${timeline.getMsPerPixel()} ms`;
timeline.on('dragged', (timestamp) => {
TimeValue.textContent = format(timestamp, 'YYYY-MM-DD HH:mm:ss', timezone);
// update timeRange
const timeRange = timeline.getTimeRange();
TimeRange.textContent = timeRange ? `${format(timeRange[0], 'YYYY-MM-DD HH:mm:ss', timezone)} ~ ${format(timeRange[1], 'YYYY-MM-DD HH:mm:ss', timezone)}` : 'Undefined';
});
timeline.on('zoom', (zoom) => {
MsPerPixel.textContent = `${timeline.getMsPerPixel()} ms`;
console.log(zoom);
});
console.log(timeline);
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/thelostword/timeline.git
[email protected]:thelostword/timeline.git
thelostword
timeline
timeline
main

搜索帮助