@@ -29,7 +29,37 @@ export function plotSolution(
29
29
) {
30
30
const { nodesXCoordinates, nodesYCoordinates } = nodesCoordinates ;
31
31
32
- if ( meshDimension === "2D" && plotType === "contour" ) {
32
+ if ( meshDimension === "1D" && plotType === "line" ) {
33
+ // Flatten solutionVector
34
+ let yData = solutionVector . map ( arr => arr [ 0 ] ) ;
35
+ let xData = Array . from ( nodesXCoordinates ) ;
36
+
37
+ let lineData = {
38
+ x : xData ,
39
+ y : yData ,
40
+ mode : "lines" ,
41
+ type : "scatter" ,
42
+ line : { color : "rgb(219, 64, 82)" , width : 2 } ,
43
+ name : "Solution"
44
+ } ;
45
+
46
+ let maxWindowWidth = Math . min ( window . innerWidth , 700 ) ;
47
+ let maxPlotWidth = Math . max ( ...xData ) ;
48
+ let zoomFactor = maxWindowWidth / maxPlotWidth ;
49
+ let plotWidth = Math . max ( zoomFactor * maxPlotWidth , 400 ) ;
50
+ let plotHeight = 350 ;
51
+
52
+ let layout = {
53
+ title : `line plot - ${ solverConfig } ` ,
54
+ width : plotWidth ,
55
+ height : plotHeight ,
56
+ xaxis : { title : "x" } ,
57
+ yaxis : { title : "Solution" } ,
58
+ margin : { l : 70 , r : 40 , t : 50 , b : 50 }
59
+ } ;
60
+
61
+ Plotly . newPlot ( plotDivId , [ lineData ] , layout , { responsive : true } ) ;
62
+ } else if ( meshDimension === "2D" && plotType === "contour" ) {
33
63
// Calculate the number of nodes along the x-axis and y-axis
34
64
const numNodesX = new Set ( nodesXCoordinates ) . size ;
35
65
const numNodesY = new Set ( nodesYCoordinates ) . size ;
0 commit comments