d3画时钟
来源:互联网 发布:java项目名命名规则 编辑:程序博客网 时间:2024/06/05 17:39
代码如下:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> .axis path,.axis line{ fill:none; stroke:black; shape-rendering:crispEdges; } .axis text{ font-family:sans-serif; font-size:11px; } .time{ font-family: cursive; font-size:40px; stroke: black; stroke-width:2; } </style></head><body> <script type="text/javascript" src = "http://d3js.org/d3.v3.min.js" charset = "utf-8"></script> <script type="text/javascript"> var width = 500; var height = 500; var svg = d3.select("body") .append("svg") .attr("width",width) .attr("height",height) function getTimeString(){ var time = new Date(); var hours = time.getHours(); var minutes = time.getMinutes(); var seconds = time.getSeconds(); hours = hours < 10 ? "0" + hours:hours; minutes = minutes < 10 ? "0" + minutes:minutes; seconds = seconds < 10 ? "0" + seconds:seconds; return hours + ":" + minutes + ":" + seconds; } var timeText = svg.append("text") .attr("x",100) .attr("y",100) .attr("class","time") .text(getTimeString()); setInterval(updateTime,1000); function updateTime(){ timeText.text(getTimeString()); } </script></body></html>
运行结果如下图所示:
阅读全文
0 0
- d3画时钟
- D3.js时钟
- d3画柱状图
- d3画树形图
- d3画中国地图
- d3画过渡动画
- d3之画地图
- d3
- D3
- d3
- D3
- D3
- D3
- D3
- D3
- d3.js画一个直方图
- D3+mysql 画Force图
- d3.js 画圆形菜单
- 卷积神经网络 权值共享 是什么 简单易懂版
- Android五大组件-Activity
- nginx日志处理
- Python爬虫实战之抓取淘宝MM照片(三)
- LGTB与序列 状压dp
- d3画时钟
- ie6 半字符攻击
- 安卓学习
- vxworks 421 service not available 解决方法
- STM32的位段操作
- 嵌入式
- 使用sublime text3 连接sftp/ftp(远程服务器)
- 查找——平均查找长度
- java 将list中name,对应的id放入map