Skip to content

Commit b1c4b6b

Browse files
committed
Refactor solution plotting: rename plot div ID for clarity and update plotSolution function to accept dynamic div ID for rendering
1 parent f89eedc commit b1c4b6b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

examples/solidHeatTransferScript/exampleSolidHeatTransfer01/FEAScriptExampleSolidHeatTransfer01.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<!-- Webpage text -->
5858
<body>
5959
<h1>Heat Conduction in a Two-Dimensional Fin</h1>
60-
<div id="plot"></div>
60+
<div id="solutionPlot"></div>
6161

6262
<p>
6363
The mesh configuration and boundary conditions can be adjusted by editing
@@ -146,7 +146,8 @@ <h1>Heat Conduction in a Two-Dimensional Fin</h1>
146146
nodesCoordinates,
147147
solverConfig,
148148
meshConfig.meshDimension,
149-
"contour"
149+
"contour",
150+
"solutionPlot"
150151
);
151152
});
152153
</script>

src/visualization/plotSolutionScript.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
* @param {string} solverConfig - Parameter specifying the type of solver
1616
* @param {string} meshDimension - The dimension of the solution
1717
* @param {string} plotType - The type of plot
18+
* @param {string} plotDivId - The id of the div where the plot will be rendered
1819
*/
1920
export function plotSolution(
2021
solutionVector,
2122
nodesCoordinates,
2223
solverConfig,
2324
meshDimension,
24-
plotType
25+
plotType,
26+
plotDivId
2527
) {
2628
const { nodesXCoordinates, nodesYCoordinates } = nodesCoordinates;
2729

2830
// Check if the device is in vertical position
2931
if (window.innerHeight > window.innerWidth) {
30-
document.getElementById("plot").innerHTML =
32+
document.getElementById(plotDivId).innerHTML =
3133
"Cannot draw the results. Please turn your phone to horizontal position to see the results.";
3234
return;
3335
}
@@ -94,6 +96,6 @@ export function plotSolution(
9496
};
9597

9698
// Create the contour plot using Plotly
97-
Plotly.newPlot("plot", data, layout);
99+
Plotly.newPlot(plotDivId, data, layout);
98100
}
99101
}

0 commit comments

Comments
 (0)