Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel2
Web
Commits
871354df
Commit
871354df
authored
Apr 30, 2025
by
Gezer
Browse files
added Chart component to frontend, but didnt test
parent
94121baa
Changes
1
Show whitespace changes
Inline
Side-by-side
frontend/src/components/LiveChart.vue
0 → 100644
View file @
871354df
<
template
>
<Line
:date=
"charData"
:options=
"chartOptions"
/>
</
template
>
<
script
setup
>
import
{
Line
}
from
'
vue-chartjs
'
import
{
Chart
as
ChartJS
,
Title
,
Tooltip
,
Legend
,
LineElement
,
PointElement
,
LinearScale
,
CategoryScale
}
from
'
chart.js
'
import
{
ref
,
reactive
}
from
'
vue
'
const
chartRef
=
ref
()
ChartJS
.
register
(
Title
,
Tooltip
,
Legend
,
LineElement
,
PointElement
,
LinearScale
,
CategoryScale
)
const
MAX_POINTS
=
100
const
charData
=
reactive
({
labels
:
[],
datasets
:[
{
label
:
'
co2
'
,
data
:
[],
borderColor
:
'
rgb(255,99,132)
'
,
tension
:
0.1
},
{
label
:
'
humidity
'
,
data
:
[],
borderColor
:
'
rgb(255,99,132)
'
,
tension
:
0.1
},
{
label
:
'
temperature
'
,
data
:
[],
borderColor
:
'
rgb(255,99,132)
'
,
tension
:
0.1
}
]
})
const
chartOptions
=
{
responsive
:
true
,
animation
:
false
,
scales
:{
y
:{
beginAtZero
:
true
}
}
}
defineExpose
({
chartData
,
updateChart
:
()
=>
chartRef
.
value
?.
chart
?.
update
()
})
defineProps
({
msg
:
String
,
})
const
count
=
ref
(
0
)
</
script
>
<
style
scoped
>
</
style
>
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment