OzoneAsai commited on
Commit
310edae
·
verified ·
1 Parent(s): 0018c44

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +119 -79
index.html CHANGED
@@ -19,19 +19,64 @@
19
  padding: 10px 20px;
20
  font-size: 16px;
21
  margin: 10px;
 
22
  }
23
- .regex-container, .options-container {
24
- margin: 20px;
25
- text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
- .regex-container textarea {
28
- width: 80%;
29
- height: 60px;
 
 
 
 
 
 
 
 
30
  font-size: 16px;
31
  }
32
  .message {
33
  color: red;
34
  font-weight: bold;
 
 
 
 
 
 
 
 
35
  }
36
  </style>
37
  <!-- D3.jsの読み込み -->
@@ -40,34 +85,7 @@
40
  <body>
41
  <h1>リアルタイムセンサーデータプロット</h1>
42
  <button id="connectButton">シリアルポートに接続</button>
43
-
44
- <div class="regex-container">
45
- <h2>正規表現設定</h2>
46
- <p>以下の正規表現を使用してシリアルデータを解析します。3つのキャプチャグループ(左、中央、右センサー)を含むように設定してください。</p>
47
- <textarea id="regexInput">Left Sensor:\s*(\d+)\s*\|\s*Center Sensor:\s*(\d+)\s*\|\s*Right Sensor:\s*(\d+)</textarea><br>
48
- <button id="applyRegexButton">適用</button>
49
- <div id="regexMessage" class="message"></div>
50
- </div>
51
-
52
- <div class="options-container">
53
- <h2>表示オプション</h2>
54
- <label>
55
- <input type="checkbox" id="includeZeroCheckbox" checked>
56
- Y軸に0を含める
57
- </label>
58
- <br>
59
- <label>
60
- <input type="checkbox" id="useSplineCheckbox" checked>
61
- スプライン曲線を使用
62
- </label>
63
- </div>
64
-
65
- <div class="options-container">
66
- <h2>データ保持数</h2>
67
- <input type="number" id="maxPointsInput" value="75" min="10" max="1000">
68
- <button id="applyMaxPointsButton">適用</button>
69
- <div id="maxPointsMessage" class="message"></div>
70
- </div>
71
 
72
  <div id="charts">
73
  <div class="chart-container">
@@ -86,7 +104,43 @@
86
 
87
  <div id="rawDataOutput">
88
  <h2>Rawデータ</h2>
89
- <pre id="rawDataDisplay"></pre>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  </div>
91
 
92
  <script>
@@ -111,6 +165,36 @@
111
  const applyMaxPointsButton = document.getElementById('applyMaxPointsButton');
112
  const maxPointsMessage = document.getElementById('maxPointsMessage');
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  // -------------------------------
115
  // オプションのイベントリスナー
116
  // -------------------------------
@@ -417,50 +501,6 @@
417
  }
418
  }
419
 
420
- // -------------------------------
421
- // グラフの更新ロジックの改善
422
- // -------------------------------
423
- function updateCharts() {
424
- for (let key in charts) {
425
- const chart = charts[key];
426
- // Yスケールの更新
427
- let yMin, yMax;
428
- if (includeZeroCheckbox.checked) {
429
- yMin = d3.min(chart.data.concat([0])) || 0;
430
- yMax = d3.max(chart.data.concat([0])) || 1023;
431
- } else {
432
- yMin = d3.min(chart.data) || 0;
433
- yMax = d3.max(chart.data) || 1023;
434
- }
435
- chart.yScale.domain([Math.min(yMin, 0), Math.max(yMax, 0)]);
436
-
437
- // Y軸の再描画
438
- chart.svg.select(".y-axis")
439
- .transition()
440
- .duration(500)
441
- .call(d3.axisLeft(chart.yScale));
442
-
443
- // パスの更新
444
- chart.path
445
- .datum(chart.data)
446
- .attr("d", chart.line);
447
- }
448
-
449
- // Xスケールの更新(常に0からMAX_POINTS -1)
450
- for (let key in charts) {
451
- const chart = charts[key];
452
- chart.xScale.domain([0, MAX_POINTS - 1]);
453
- chart.svg.select(".x-axis")
454
- .transition()
455
- .duration(500)
456
- .call(d3.axisBottom(chart.xScale));
457
- }
458
- }
459
-
460
- // -------------------------------
461
- // 初期データの保持とグラフのリセット
462
- // -------------------------------
463
- // 必要に応じて追加
464
  </script>
465
  </body>
466
  </html>
 
19
  padding: 10px 20px;
20
  font-size: 16px;
21
  margin: 10px;
22
+ cursor: pointer;
23
  }
24
+ /* モーダルダイアログのスタイル */
25
+ .modal {
26
+ display: none; /* 初期状態では非表示 */
27
+ position: fixed; /* 固定位置 */
28
+ z-index: 1; /* 他の要素より前面に表示 */
29
+ left: 0;
30
+ top: 0;
31
+ width: 100%; /* 幅を全画面に */
32
+ height: 100%; /* 高さを全画面に */
33
+ overflow: auto; /* 必要に応じてスクロール */
34
+ background-color: rgba(0, 0, 0, 0.4); /* 背景を半透明に */
35
+ }
36
+ .modal-content {
37
+ background-color: #fefefe;
38
+ margin: 10% auto; /* 上下にマージン、中央揃え */
39
+ padding: 20px;
40
+ border: 1px solid #888;
41
+ width: 80%; /* 幅を80%に */
42
+ max-width: 600px; /* 最大幅を600pxに */
43
+ border-radius: 8px;
44
+ position: relative;
45
+ }
46
+ .close {
47
+ color: #aaa;
48
+ float: right;
49
+ font-size: 28px;
50
+ font-weight: bold;
51
+ position: absolute;
52
+ right: 20px;
53
+ top: 10px;
54
+ cursor: pointer;
55
  }
56
+ .close:hover,
57
+ .close:focus {
58
+ color: black;
59
+ text-decoration: none;
60
+ }
61
+ .regex-container textarea,
62
+ .options-container input[type="number"] {
63
+ width: 100%;
64
+ padding: 8px;
65
+ margin: 8px 0;
66
+ box-sizing: border-box;
67
  font-size: 16px;
68
  }
69
  .message {
70
  color: red;
71
  font-weight: bold;
72
+ margin-top: 10px;
73
+ }
74
+ .modal-buttons {
75
+ text-align: right;
76
+ margin-top: 20px;
77
+ }
78
+ .modal-buttons button {
79
+ margin-left: 10px;
80
  }
81
  </style>
82
  <!-- D3.jsの読み込み -->
 
85
  <body>
86
  <h1>リアルタイムセンサーデータプロット</h1>
87
  <button id="connectButton">シリアルポートに接続</button>
88
+ <button id="settingsButton">設定</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  <div id="charts">
91
  <div class="chart-container">
 
104
 
105
  <div id="rawDataOutput">
106
  <h2>Rawデータ</h2>
107
+ <pre id="rawDataDisplay" style="text-align: left; width: 80%; margin: 0 auto; max-height: 200px; overflow: auto; border: 1px solid #ccc; padding: 10px;"></pre>
108
+ </div>
109
+
110
+ <!-- モーダルダイアログ -->
111
+ <div id="settingsModal" class="modal">
112
+ <div class="modal-content">
113
+ <span class="close">&times;</span>
114
+ <h2>設定</h2>
115
+ <div class="regex-container">
116
+ <h3>正規表現設定</h3>
117
+ <p>以下の正規表現を使用してシリアルデータを解析します。3つのキャプチャグループ(左、中央、右センサー)を含むように設定してください。</p>
118
+ <textarea id="regexInput">Left Sensor:\s*(\d+)\s*\|\s*Center Sensor:\s*(\d+)\s*\|\s*Right Sensor:\s*(\d+)</textarea><br>
119
+ <button id="applyRegexButton">適用</button>
120
+ <div id="regexMessage" class="message"></div>
121
+ </div>
122
+ <div class="options-container">
123
+ <h3>表示オプション</h3>
124
+ <label>
125
+ <input type="checkbox" id="includeZeroCheckbox" checked>
126
+ Y軸に0を含める
127
+ </label>
128
+ <br>
129
+ <label>
130
+ <input type="checkbox" id="useSplineCheckbox" checked>
131
+ スプライン曲線を使用
132
+ </label>
133
+ </div>
134
+ <div class="options-container">
135
+ <h3>データ保持数</h3>
136
+ <input type="number" id="maxPointsInput" value="75" min="10" max="1000">
137
+ <button id="applyMaxPointsButton">適用</button>
138
+ <div id="maxPointsMessage" class="message"></div>
139
+ </div>
140
+ <div class="modal-buttons">
141
+ <button id="closeSettingsButton">閉じる</button>
142
+ </div>
143
+ </div>
144
  </div>
145
 
146
  <script>
 
165
  const applyMaxPointsButton = document.getElementById('applyMaxPointsButton');
166
  const maxPointsMessage = document.getElementById('maxPointsMessage');
167
 
168
+ // -------------------------------
169
+ // モーダルダイアログの設定
170
+ // -------------------------------
171
+ const settingsModal = document.getElementById('settingsModal');
172
+ const settingsButton = document.getElementById('settingsButton');
173
+ const closeModalSpan = document.querySelector('.modal .close');
174
+ const closeSettingsButton = document.getElementById('closeSettingsButton');
175
+
176
+ // モーダルを開く
177
+ settingsButton.onclick = function() {
178
+ settingsModal.style.display = "block";
179
+ }
180
+
181
+ // モーダルを閉じる(×ボタン)
182
+ closeModalSpan.onclick = function() {
183
+ settingsModal.style.display = "none";
184
+ }
185
+
186
+ // モーダルを閉じる(閉じるボタン)
187
+ closeSettingsButton.onclick = function() {
188
+ settingsModal.style.display = "none";
189
+ }
190
+
191
+ // モーダル外をクリックすると閉じる
192
+ window.onclick = function(event) {
193
+ if (event.target == settingsModal) {
194
+ settingsModal.style.display = "none";
195
+ }
196
+ }
197
+
198
  // -------------------------------
199
  // オプションのイベントリスナー
200
  // -------------------------------
 
501
  }
502
  }
503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  </script>
505
  </body>
506
  </html>