Commit a4c85a7b authored by Santhanavanich's avatar Santhanavanich
Browse files

update

parent 90443acc
No related merge requests found
Pipeline #9121 passed with stage
in 21 seconds
Showing with 116 additions and 116 deletions
+116 -116
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
<script src="https://cdn.jsdelivr.net/npm/plotly.js-dist@latest"></script> <script src="https://cdn.jsdelivr.net/npm/plotly.js-dist@latest"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.1.2/echarts.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.1.2/echarts.min.js"></script>
<style> <style>
body {
background-color: white; /* Set the background color to white */
}
#plotlyContainer { #plotlyContainer {
height: 100vh; height: 100vh;
...@@ -17,18 +20,22 @@ ...@@ -17,18 +20,22 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
top: 6%; top: 6%;
right:100; right: 100; /* Assuming you meant right: 100px */
width: 100%; width: 100%;
z-index: 3; z-index: 3;
} }
#toggleSpaceTime {
padding: 10px 20px;
font-size: 16px;
}
</style> </style>
</head> </head>
<body> <body>
<!-- Add your HTML content here --> <!-- Add your HTML content here -->
<button id="toggleSpaceTime">Toggle Space-Time Cube</button> <button id="toggleSpaceTime">Bus Space-Time Cube Visualization </button>
<div id="spaceTimeCubeContainer" style="display: none;"> <div id="spaceTimeCubeContainer" style="display: none;">
<!-- Container for the space-time cube visualization --> <!-- Container for the space-time cube visualization -->
<div id="spaceTimeCube"></div> <div id="spaceTimeCube"></div>
...@@ -38,7 +45,6 @@ ...@@ -38,7 +45,6 @@
<div id="plotlyContainer"></div> <div id="plotlyContainer"></div>
<script> <script>
document.getElementById("toggleSpaceTime").addEventListener("click", function () { document.getElementById("toggleSpaceTime").addEventListener("click", function () {
const spaceTimeContainer = document.getElementById("spaceTimeCubeContainer"); const spaceTimeContainer = document.getElementById("spaceTimeCubeContainer");
console.log("Toggle button clicked"); console.log("Toggle button clicked");
...@@ -53,7 +59,7 @@ ...@@ -53,7 +59,7 @@
} }
}); });
function animateSpaceTimeRoute(url, containerId, trainColor, trainName) { function animateSpaceTimeRoute(url) {
fetch(url) fetch(url)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
...@@ -61,7 +67,7 @@ ...@@ -61,7 +67,7 @@
console.error('Invalid data format:', data); console.error('Invalid data format:', data);
return; return;
} }
const frames = data.features.map((feature, index) => { const frames = data.features.map((feature, index) => {
const coordinates = feature.geometry.coordinates; const coordinates = feature.geometry.coordinates;
const timestamps = feature.properties.datetimes; const timestamps = feature.properties.datetimes;
...@@ -70,43 +76,33 @@ const frames = data.features.map((feature, index) => { ...@@ -70,43 +76,33 @@ const frames = data.features.map((feature, index) => {
return; return;
} }
const lineColors = Array.from({ length: coordinates.length - 1 }, () => 'orange'); // Create an array of orange colors
return { return {
data: [ data: [{
{
type: 'scattermapbox',
lat: coordinates.map(coord => coord[1]),
lon: coordinates.map(coord => coord[0]),
mode: 'lines+markers', // Display both points and lines
marker: { size: 6, color: 'black' },
line: { color: 'black' }, // This line is not used when mode is 'lines+markers'
name: 'Bus route',
},
{
type: 'scatter3d', type: 'scatter3d',
x: coordinates.map(coord => coord[0]), x: coordinates.map(coord => coord[0]),
y: coordinates.map(coord => coord[1]), y: coordinates.map(coord => coord[1]),
z: timestamps.map((time, i) => new Date(time).toISOString()), z: timestamps.map((time, i) => new Date(time).toISOString()),
mode: 'lines+markers', // Change mode to display both points and lines mode: 'lines+markers', // Change mode to display both points and lines
marker: { color: 'black', size: 5 }, marker: {color: 'black',size: 5},
line: { color: 'red', size: 3 }, line: {color: 'red',size: 3
},
name: 'Bus trajectory line', name: 'Bus trajectory line',
}, },
], ],
name: `frame${index + 1}`, name: `frame${index + 1}`,
}; };
}); });
const layout = {
// Set the layout with mapbox style and access token margin: {
const layout = { t: 0,
mapbox: { b: 0,
style: 'light', l: 0,
center: { lon: frames[0].data[0].lon[0], lat: frames[0].data[0].lat[0] }, r: 0
zoom: 10,
accesstoken: 'pk.eyJ1IjoicmVkaWV0OTk2MyIsImEiOiJjbHJ1cmk5aGUwaDRvMmpuYWM4Z2NqcmZuIn0.c11HYT-5ucd6g6mL03bp3Q', // Mapbox access token
}, },
margin: { t: 0, b: 0, l: 0, r: 0 }, paper_bgcolor: 'white',
plot_bgcolor: 'white',
scene: { scene: {
xaxis: { xaxis: {
title: 'Long', title: 'Long',
...@@ -150,15 +146,18 @@ const frames = data.features.map((feature, index) => { ...@@ -150,15 +146,18 @@ const frames = data.features.map((feature, index) => {
bold: true bold: true
} }
}, },
// Common font settings for both
font: { font: {
family: 'Arial, sans-serif', family: 'Arial, sans-serif',
size: 12, size: 12,
color: 'black', color: 'black',
bold: true bold: true
} }
},
legend: {
traceorder: 'normal' // Set traceorder to 'normal' to display legends
} }
}; };
// Initialize Plotly container // Initialize Plotly container
Plotly.newPlot('plotlyContainer', frames[0].data, layout); Plotly.newPlot('plotlyContainer', frames[0].data, layout);
...@@ -167,7 +166,8 @@ const frames = data.features.map((feature, index) => { ...@@ -167,7 +166,8 @@ const frames = data.features.map((feature, index) => {
.catch(error => { .catch(error => {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);
}); });
} }
</script> </script>
</body> </body>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment