html 绘制体温单,使用zrender.js绘制体温单效果
时间: 2023-10-03 09:05:30 浏览: 87
可以使用zrender.js绘制体温单。以下是一个简单的例子:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>绘制体温单</title>
<script src="https://cdn.bootcdn.net/ajax/libs/zrender/5.1.2/zrender.min.js"></script>
</head>
<body>
<div id="main" style="width: 600px; height: 400px;"></div>
<script>
var dom = document.getElementById("main");
var myChart = zrender.init(dom);
// 绘制网格线
var grid = new zrender.Rect({
shape: {
x: 50,
y: 50,
width: 500,
height: 300
},
style: {
stroke: "#ccc",
lineWidth: 1
}
});
myChart.add(grid);
// 绘制刻度线
for (var i = 0; i <= 10; i++) {
var line = new zrender.Line({
shape: {
x1: 50 + i * 50,
y1: 50,
x2: 50 + i * 50,
y2: 350
},
style: {
stroke: "#ccc",
lineWidth: 1
}
});
myChart.add(line);
}
// 绘制日期
var dateText = new zrender.Text({
style: {
text: "日期",
x: 20,
y: 200,
textBaseline: "middle",
textAlign: "center"
}
});
myChart.add(dateText);
// 绘制体温
var temperatureText = new zrender.Text({
style: {
text: "体\n温",
x: 25,
y: 300,
textBaseline: "middle",
textAlign: "center"
}
});
myChart.add(temperatureText);
for (var i = 0; i <= 10; i++) {
var date = new zrender.Text({
style: {
text: "2020-01-" + (i + 1),
x: 75 + i * 50,
y: 25,
textBaseline: "middle",
textAlign: "center"
}
});
myChart.add(date);
var temperature = new zrender.Text({
style: {
text: "36." + (Math.random() * 10).toFixed(1),
x: 75 + i * 50,
y: 325,
textBaseline: "middle",
textAlign: "center"
}
});
myChart.add(temperature);
}
</script>
</body>
</html>
```
这是一个简单的体温单,包括网格线、刻度线、日期和体温。可以根据需求进行修改和扩展,例如增加曲线图等。
阅读全文