JavedA commited on
Commit
48cb32a
1 Parent(s): 3a238b7

loader is working finde - not as desired, but its okay

Browse files
Code/Visuals/Plotly/plt_1.py CHANGED
@@ -97,8 +97,8 @@ fig.update_layout(
97
  )
98
 
99
 
100
- fig.write_html("./tornado.html",
101
- div_id= "plt_Div",
102
  include_plotlyjs = "cdn")
103
 
104
  fig.write_image("Data/6_Html_Data/1_Logo_Img/2_Tornado.svg")
 
97
  )
98
 
99
 
100
+ fig.write_html("./Data/6_Html_Data/0_Viz/mPV_16.78.html",
101
+ div_id= "tornado_main",
102
  include_plotlyjs = "cdn")
103
 
104
  fig.write_image("Data/6_Html_Data/1_Logo_Img/2_Tornado.svg")
Data/6_Html_Data/0_Viz/mPV_16.78.html CHANGED
The diff for this file is too large to render. See raw diff
 
Data/6_Html_Data/1_Logo_Img/2_Tornado.svg CHANGED
Trials/1_Python_Code_Qmd.qmd ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Meet The Tornado {.unnumbered}
2
+
3
+ <div id="loader_Initial" class="cl_Loader">
4
+ </div>
5
+
6
+ <div id="content_Load" style="display:none;">
7
+
8
+ <!-- Code to generate the main image, i.e. the tornada -->
9
+
10
+ ```{python}
11
+ # | echo: false
12
+ #| code-fold: true
13
+ #| label: tornado_main
14
+ #|
15
+ import numpy as np
16
+ import plotly.io as pio
17
+ pio.renderers.default = "plotly_mimetype+notebook_connected"
18
+ import plotly.graph_objects as go # to combine figures
19
+
20
+ # load data from the numpy npz file
21
+ data = np.load('Data/6_Html_Data/0_Viz/plt_Dat_16.78.npz')
22
+
23
+ # extraxt the data - load it
24
+ x_Traj = data["x"]
25
+ y_Traj = data["y"]
26
+ z_Traj = data["z"]
27
+ x_Cone = data["x_Cone"]
28
+ y_Cone = data["y_Cone"]
29
+ z_Cone = data["z_Cone"]
30
+ u_Cone = data["u_Cone"]
31
+ v_Cone = data["v_Cone"]
32
+ w_Cone = data["w_Cone"]
33
+
34
+ # The trajectory
35
+ fig = go.Figure(data=[go.Scatter3d(
36
+ x= x_Traj,
37
+ y= y_Traj,
38
+ z= z_Traj,
39
+ name = "Trajectory",
40
+ showlegend = False,
41
+ )])
42
+
43
+
44
+ fig.update_traces(marker_size = 2,
45
+ mode = "lines",
46
+ marker_color ="green")
47
+
48
+
49
+ # Cones
50
+ fig_Cones = go.Figure(data=go.Cone( x = x_Cone ,
51
+ y = y_Cone ,
52
+ z = z_Cone ,
53
+ u = u_Cone ,
54
+ v = v_Cone ,
55
+ w = w_Cone ,
56
+ name = "Direction",
57
+ showlegend = False,
58
+
59
+ )
60
+ )
61
+
62
+
63
+ # hiding color-bar
64
+ fig_Cones.update_traces(showscale=False)
65
+
66
+ # combine cone and trajectory
67
+ fig.add_traces(data = fig_Cones.data)
68
+
69
+
70
+ # style the figure
71
+ fig.update_layout(
72
+ # plotlyexpress 3d axes:
73
+ scene = dict(
74
+ xaxis = dict(
75
+ showbackground = False,
76
+ showticklabels = False,
77
+ title='',
78
+ showgrid = False,
79
+ zeroline = False,),
80
+ yaxis = dict(
81
+ showbackground = False,
82
+ showticklabels = False,
83
+ title='',
84
+ showgrid = False,
85
+ zeroline = False,),
86
+ zaxis = dict(
87
+ showbackground = False,
88
+ showticklabels = False,
89
+ title='',
90
+ showgrid = False,
91
+ zeroline = False,
92
+ ),
93
+ ),
94
+ # template= 'plotly_dark'
95
+ # template= 'plotly'
96
+ paper_bgcolor='rgba(0,0,0,0)',
97
+ plot_bgcolor='rgba(0,0,0,0)',
98
+ modebar = dict(bgcolor='rgba(0, 0, 0, 0)'),
99
+ margin=dict(
100
+ l=0,
101
+ r=0,
102
+ b=0,
103
+ t=0,
104
+ pad=0
105
+ ),
106
+
107
+ scene_camera_eye=dict(x=0,
108
+ y=1,
109
+ z=0),
110
+ )
111
+
112
+ fig.show(div_id="here_Comes")
113
+ ```
114
+
115
+
116
+ </div>
117
+
118
+
119
+ <script>
120
+
121
+ /* ========================================================================== */
122
+ /* ============================ show_Lotti_Riksha =========================== */
123
+ /* ========================================================================== */
124
+ function show_Lotti_Riksha(){
125
+
126
+ console.log("I am about to show th riksha");
127
+ const player = document.querySelector('dotlottie-player');
128
+ player.load('./Data/7_Animation/Riksha.lottie');
129
+ }
130
+
131
+ /* ========================================================================== */
132
+ /* ======================== hideLoaderAndShowContent ======================== */
133
+ /* ========================================================================== */
134
+ function hideLoaderAndShowContent() {
135
+ const loader = document.getElementById("loader_Initial");
136
+ const content = document.getElementById("content_Load");
137
+
138
+ loader.style.display = "none";
139
+ content.style.display = "block";
140
+
141
+ // Load and display the riksha animation
142
+ show_Lotti_Riksha();
143
+ }
144
+
145
+
146
+ // This code defines a waitForScriptExecution function that sets up a MutationObserver to watch for changes in the div element with the class plotly-graph-div. When a change is detected, it logs a message, disconnects the observer, and hides the loader while showing the content.
147
+ function waitForScriptExecution() {
148
+
149
+ // the plotly figure has the id tornado_main
150
+ const tornadoMain = document.getElementById("tornado_main");
151
+
152
+ if (tornadoMain) {
153
+ // get the first element that is found by this class name
154
+ const targetDiv = tornadoMain.querySelector(".plotly-graph-div"); // Replace with the correct class name
155
+
156
+ if (targetDiv) {
157
+ const observer = new MutationObserver((mutationsList) => {
158
+ for (const mutation of mutationsList) {
159
+ if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
160
+ console.log("Script has been executed and the div content has changed.");
161
+ observer.disconnect();
162
+ hideLoaderAndShowContent();
163
+ break;
164
+ }
165
+ }
166
+ });
167
+
168
+ observer.observe(targetDiv, { childList: true });
169
+ }
170
+ }
171
+ }
172
+
173
+ // wait until the whole page has loaded once
174
+ window.addEventListener("load", function() {
175
+
176
+ // show_Lotti_Riksha()
177
+
178
+ // when the tornada plotly plot is shown let the riksha disappear
179
+ waitForScriptExecution();
180
+ });
181
+
182
+ </script>
183
+
184
+
185
+
Web_Code/CSS/css_0.css CHANGED
@@ -30,8 +30,12 @@
30
  visibility: hidden;
31
  }
32
 
 
 
 
 
33
  /* when the main page is opened, it might take some time to load everything - for that a loader shall be made visibe. */
34
- .cl_Loader {
35
  border: 16px solid #f3f3f3;
36
  border-radius: 50%;
37
  border-top: 16px solid #3498db;
@@ -50,4 +54,4 @@
50
  0% { transform: rotate(0deg); }
51
  100% { transform: rotate(360deg); }
52
  }
53
-
 
30
  visibility: hidden;
31
  }
32
 
33
+
34
+ /* <div id="loader_Initial" class="cl_Loader">
35
+ </div> */
36
+
37
  /* when the main page is opened, it might take some time to load everything - for that a loader shall be made visibe. */
38
+ /* .cl_Loader {
39
  border: 16px solid #f3f3f3;
40
  border-radius: 50%;
41
  border-top: 16px solid #3498db;
 
54
  0% { transform: rotate(0deg); }
55
  100% { transform: rotate(360deg); }
56
  }
57
+ */
index.qmd CHANGED
@@ -1,164 +1,55 @@
1
  # Meet The Tornado {.unnumbered}
2
 
3
- <div id="loader_Initial" class="cl_Loader">
4
- </div>
5
-
6
- <div id="content_Load" style="display:none;">
7
- <!-- Your webpage content goes here
8
 
 
 
 
 
 
 
 
9
 
10
- <!-- Code to generate the main image, i.e. the tornada -->
11
- ```{python}
12
- # | echo: false
13
- #| code-fold: true
14
- #| label: tornado_main
15
- #|
16
- import numpy as np
17
- import plotly.io as pio
18
- pio.renderers.default = "plotly_mimetype+notebook_connected"
19
- import plotly.graph_objects as go # to combine figures
20
-
21
- # load data from the numpy npz file
22
- data = np.load('Data/6_Html_Data/0_Viz/plt_Dat_16.78.npz')
23
-
24
- # extraxt the data - load it
25
- x_Traj = data["x"]
26
- y_Traj = data["y"]
27
- z_Traj = data["z"]
28
- x_Cone = data["x_Cone"]
29
- y_Cone = data["y_Cone"]
30
- z_Cone = data["z_Cone"]
31
- u_Cone = data["u_Cone"]
32
- v_Cone = data["v_Cone"]
33
- w_Cone = data["w_Cone"]
34
-
35
- # The trajectory
36
- fig = go.Figure(data=[go.Scatter3d(
37
- x= x_Traj,
38
- y= y_Traj,
39
- z= z_Traj,
40
- name = "Trajectory",
41
- showlegend = False,
42
- )])
43
-
44
-
45
- fig.update_traces(marker_size = 2,
46
- mode = "lines",
47
- marker_color ="green")
48
-
49
-
50
- # Cones
51
- fig_Cones = go.Figure(data=go.Cone( x = x_Cone ,
52
- y = y_Cone ,
53
- z = z_Cone ,
54
- u = u_Cone ,
55
- v = v_Cone ,
56
- w = w_Cone ,
57
- name = "Direction",
58
- showlegend = False,
59
-
60
- )
61
- )
62
-
63
-
64
- # hiding color-bar
65
- fig_Cones.update_traces(showscale=False)
66
-
67
- # combine cone and trajectory
68
- fig.add_traces(data = fig_Cones.data)
69
-
70
-
71
- # style the figure
72
- fig.update_layout(
73
- # plotlyexpress 3d axes:
74
- scene = dict(
75
- xaxis = dict(
76
- showbackground = False,
77
- showticklabels = False,
78
- title='',
79
- showgrid = False,
80
- zeroline = False,),
81
- yaxis = dict(
82
- showbackground = False,
83
- showticklabels = False,
84
- title='',
85
- showgrid = False,
86
- zeroline = False,),
87
- zaxis = dict(
88
- showbackground = False,
89
- showticklabels = False,
90
- title='',
91
- showgrid = False,
92
- zeroline = False,
93
- ),
94
- ),
95
- # template= 'plotly_dark'
96
- # template= 'plotly'
97
- paper_bgcolor='rgba(0,0,0,0)',
98
- plot_bgcolor='rgba(0,0,0,0)',
99
- modebar = dict(bgcolor='rgba(0, 0, 0, 0)'),
100
- margin=dict(
101
- l=0,
102
- r=0,
103
- b=0,
104
- t=0,
105
- pad=0
106
- ),
107
-
108
- scene_camera_eye=dict(x=0,
109
- y=1,
110
- z=0),
111
- )
112
-
113
- fig.show(div_id="here_Comes")
114
- ```
115
- </div>
116
-
117
 
118
  <script>
119
-
120
- function hideLoaderAndShowContent() {
121
- const loader = document.getElementById("loader_Initial");
122
- const content = document.getElementById("content_Load");
123
-
124
- loader.style.display = "none";
125
- content.style.display = "block";
126
  }
127
 
 
 
 
128
 
129
- // This code defines a waitForScriptExecution function that sets up a MutationObserver to watch for changes in the div element with the class plotly-graph-div. When a change is detected, it logs a message, disconnects the observer, and hides the loader while showing the content.
130
- function waitForScriptExecution() {
131
-
132
- // the plotly figure has the id tornado_main
133
- const tornadoMain = document.getElementById("tornado_main");
134
 
135
- if (tornadoMain) {
136
- // get the first element that is found by this class name
137
- const targetDiv = tornadoMain.querySelector(".plotly-graph-div"); // Replace with the correct class name
138
 
139
- if (targetDiv) {
140
- const observer = new MutationObserver((mutationsList) => {
141
- for (const mutation of mutationsList) {
142
- if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
143
- console.log("Script has been executed and the div content has changed.");
144
- observer.disconnect();
145
- hideLoaderAndShowContent();
146
- break;
147
- }
148
- }
149
- });
150
-
151
- observer.observe(targetDiv, { childList: true });
152
- }
153
- }
154
  }
155
 
156
  // wait until the whole page has loaded once
157
  window.addEventListener("load", function() {
158
- waitForScriptExecution();
 
 
 
 
 
 
 
 
 
 
 
159
  });
160
-
161
  </script>
162
-
163
-
164
-
 
1
  # Meet The Tornado {.unnumbered}
2
 
3
+ <!-- load dot lotti js code -->
4
+ <script src="https://unpkg.com/@dotlottie/player-component@1.0.0/dist/dotlottie-player.js"></script>
 
 
 
5
 
6
+ <dotlottie-player
7
+ autoplay
8
+ loop
9
+ mode="bounce"
10
+ src="./Data/7_Animation/Riksha.lottie"
11
+ style="width: 100% hegiht: 600px">
12
+ </dotlottie-player>
13
 
14
+ <div id="iframe_Tornado" style="display:none;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  <script>
17
+ function createIframe() {
18
+ const iframe = document.createElement("iframe");
19
+ iframe.src = "./Data/6_Html_Data/0_Viz/mPV_16.78.html";
20
+ iframe.frameBorder = "0";
21
+ iframe.width = "100%";
22
+ iframe.height = "600";
23
+ return iframe;
24
  }
25
 
26
+ function hide_Riksha() {
27
+ // get lottify riksha
28
+ const player = document.querySelector('dotlottie-player');
29
 
30
+ // get iframe container
31
+ const content = document.getElementById("iframe_Tornado");
 
 
 
32
 
33
+ // hide riksha
34
+ player.style.display = "none";
 
35
 
36
+ // show iframe container
37
+ content.style.display = "block";
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
  // wait until the whole page has loaded once
41
  window.addEventListener("load", function() {
42
+ console.log("whole page has loaded");
43
+
44
+ // create and insert iframe
45
+ const content = document.getElementById("iframe_Tornado");
46
+ const iframe = createIframe();
47
+ content.appendChild(iframe);
48
+
49
+ // hide riksha and show iframe when iframe content has loaded
50
+ iframe.addEventListener("load", function() {
51
+ console.log("iframe has loaded");
52
+ hide_Riksha();
53
+ });
54
  });
 
55
  </script>
 
 
 
trials.qmd CHANGED
@@ -2,7 +2,24 @@
2
 
3
  Thissince \gls{cnmc}
4
 
5
- <!-- src="" -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
 
8
 
 
2
 
3
  Thissince \gls{cnmc}
4
 
5
+ <!-- load lotti js code -->
6
+ <script src="https://unpkg.com/@dotlottie/player-component@1.0.0/dist/dotlottie-player.js"></script>
7
+
8
+ <dotlottie-player autoplay controls loop mode="normal" style="width: 320px"> </dotlottie-player>
9
+
10
+ <script>
11
+
12
+ // when th full page is laoded --> slows down quite abite
13
+ window.addEventListener("load", function() {
14
+ // when the tornada plotly plot is shown let the riksha disappear
15
+ const player = document.querySelector('dotlottie-player');
16
+ player.load('./Data/7_Animation/Riksha.lottie');
17
+ });
18
+
19
+ // this without addEventListener is much faster
20
+ // const player = document.querySelector('dotlottie-player');
21
+ // player.load('./Data/7_Animation/Riksha.lottie');
22
+ </script
23
 
24
 
25