FluentUI/example/qml/chart/T_LineChart.qml

64 lines
1.7 KiB
QML
Raw Permalink Normal View History

2023-12-05 11:42:21 +08:00
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
import "../component"
FluScrollablePage{
2024-05-07 21:47:40 +08:00
id: root
2024-03-09 18:26:54 +08:00
title: qsTr("Line Chart")
2024-05-07 21:47:40 +08:00
property var data : []
2023-12-05 11:42:21 +08:00
2024-03-29 16:56:09 +08:00
FluFrame{
2024-03-29 16:23:16 +08:00
Layout.preferredWidth: 500
Layout.preferredHeight: 370
padding: 10
2023-12-05 11:42:21 +08:00
Layout.topMargin: 20
FluChart{
2024-05-07 21:47:40 +08:00
id: chart
2023-12-05 11:42:21 +08:00
anchors.fill: parent
chartType: 'line'
chartData: { return {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First Dataset',
2024-05-07 21:47:40 +08:00
data: root.data,
2023-12-05 11:42:21 +08:00
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
}]
}
}
chartOptions: { return {
maintainAspectRatio: false,
title: {
display: true,
text: 'Chart.js Line Chart - Stacked'
},
tooltips: {
mode: 'index',
intersect: false
}
}
}
}
2024-05-07 21:47:40 +08:00
Timer{
id: timer
interval: 300
repeat: true
onTriggered: {
root.data.push(Math.random()*100)
if(root.data.length>7){
root.data.shift()
}
chart.animateToNewData()
}
}
Component.onCompleted: {
timer.restart()
}
2023-12-05 11:42:21 +08:00
}
}