46 lines
1.1 KiB
HTML
46 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Title</title>
|
|
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
|
<style>
|
|
/* 设置html和body的高度和宽度为100%,并移除边距和填充 */
|
|
html, body {
|
|
height: 100%;
|
|
width: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
/* 设置图表div的大小为视口的100% */
|
|
#plot {
|
|
height: 100vh;
|
|
width: 100vw;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="plot"></div>
|
|
<script>
|
|
var trace = {
|
|
x: [], y: [], z: [],
|
|
mode: 'markers',
|
|
type: 'scatter3d'
|
|
};
|
|
var layout = {
|
|
title: '3D Scatter Plot'
|
|
};
|
|
Plotly.newPlot('plot', [trace], layout);
|
|
|
|
setInterval(function(){
|
|
fetch('http://localhost:8000/data')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
Plotly.extendTraces('plot', { x: [[data.x]], y: [[data.y]], z: [[data.z]] }, [0]);
|
|
});
|
|
}, 1000); // 更新频率为每秒
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |