Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Szabo_sem_pr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Szabó, Gabriel
Szabo_sem_pr
Commits
56870afa
Commit
56870afa
authored
9 months ago
by
Szabó, Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
e92a1a5c
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webpage/templates/page2.html
+130
-0
130 additions, 0 deletions
webpage/templates/page2.html
with
130 additions
and
0 deletions
webpage/templates/page2.html
0 → 100644
+
130
−
0
View file @
56870afa
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Spectrum
</title>
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
>
<script
src=
"https://cdn.jsdelivr.net/npm/chart.js"
></script>
<style>
body
,
html
{
margin
:
0
;
padding
:
0
;
height
:
90%
;
}
canvas
{
width
:
95%
;
height
:
90%
;
}
</style>
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
id=
"navbar"
>
<a
class=
"navbar-brand"
href=
"#"
>
MODUMIN
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarNav"
aria-controls=
"navbarNav"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarNav"
>
<ul
class=
"navbar-nav"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"/"
>
Home
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"/page1"
>
Midi note
</a>
</li>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"/page2"
>
Spectrum
</a>
</li>
</ul>
</div>
<div
class=
"ml-auto"
>
<span
class=
"navbar-text"
>
Pico IP: {{ pico_ip }}
</span>
</div>
</nav>
<canvas
id=
"myChart"
></canvas>
<script>
document
.
addEventListener
(
'
DOMContentLoaded
'
,
function
()
{
var
ctx
=
document
.
getElementById
(
'
myChart
'
).
getContext
(
'
2d
'
);
var
myChart
=
new
Chart
(
ctx
,
{
type
:
'
bar
'
,
data
:
{
labels
:
[],
datasets
:
[{
label
:
'
Spectrum
'
,
data
:
[],
borderColor
:
'
black
'
,
backgroundColor
:
'
black
'
,
borderWidth
:
1
}]
},
options
:
{
responsive
:
true
,
maintainAspectRatio
:
false
,
scales
:
{
xAxes
:
[{
type
:
'
linear
'
,
display
:
true
,
scaleLabel
:
{
display
:
true
,
labelString
:
'
Frequency (Hz)
'
},
ticks
:
{
min
:
20
,
// Hz
max
:
15000
,
// Hz
callback
:
function
(
value
,
index
,
values
)
{
return
Math
.
round
(
value
)
+
'
Hz
'
;
}
},
gridLines
:
{
display
:
false
}
}],
yAxes
:
[{
display
:
true
,
ticks
:
{
beginAtZero
:
true
,
suggestedMax
:
40
}
}]
}
}
});
function
updateChart
()
{
fetch
(
'
/page2_data
'
)
.
then
(
response
=>
{
if
(
!
response
.
ok
)
{
throw
new
Error
(
'
Network response was not ok
'
+
response
.
statusText
);
}
return
response
.
text
();
})
.
then
(
data
=>
{
console
.
log
(
'
Fetched data:
'
,
data
);
if
(
data
.
includes
(
'
Error
'
))
{
throw
new
Error
(
data
);
}
const
values
=
data
.
split
(
'
,
'
).
map
(
value
=>
parseFloat
(
value
.
trim
()));
if
(
values
.
length
===
0
||
values
.
some
(
isNaN
))
{
throw
new
Error
(
'
Invalid data format
'
);
}
const
labels
=
Array
.
from
(
Array
(
values
.
length
).
keys
()).
map
((
_
,
index
)
=>
index
*
Math
.
round
(
30000
/
4096
));
console
.
log
(
'
Parsed labels:
'
,
labels
);
console
.
log
(
'
Parsed values:
'
,
values
);
myChart
.
data
.
labels
=
labels
;
myChart
.
data
.
datasets
[
0
].
data
=
values
;
myChart
.
update
();
})
.
catch
(
error
=>
console
.
error
(
'
Error fetching or processing data:
'
,
error
));
}
// Update the chart every 500ms
setInterval
(
updateChart
,
500
);
});
</script>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment