From b916221d9f9d077091c33b3b2ed437c280027489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Tue, 7 May 2024 21:47:40 +0800 Subject: [PATCH] update --- example/example_en_US.ts | 2 +- example/example_zh_CN.ts | 2 +- example/qml/chart/T_LineChart.qml | 20 +++++++++++++++++++- src/FluTableModel.h | 1 - 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 7b417a49..5e6b05f1 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -1402,7 +1402,7 @@ My only desire is to be permitted to drive out the traitors and restore the Han. T_LineChart - + Line Chart diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index e798dfc6..9699fa8f 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -1500,7 +1500,7 @@ My only desire is to be permitted to drive out the traitors and restore the Han. T_LineChart - + Line Chart 线型图 diff --git a/example/qml/chart/T_LineChart.qml b/example/qml/chart/T_LineChart.qml index 88e92b3e..45837660 100644 --- a/example/qml/chart/T_LineChart.qml +++ b/example/qml/chart/T_LineChart.qml @@ -7,7 +7,9 @@ import "../component" FluScrollablePage{ + id: root title: qsTr("Line Chart") + property var data : [] FluFrame{ Layout.preferredWidth: 500 @@ -15,13 +17,14 @@ FluScrollablePage{ padding: 10 Layout.topMargin: 20 FluChart{ + id: chart anchors.fill: parent chartType: 'line' chartData: { return { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'My First Dataset', - data: [65, 59, 80, 81, 56, 55, 40], + data: root.data, fill: false, borderColor: 'rgb(75, 192, 192)', tension: 0.1 @@ -41,5 +44,20 @@ FluScrollablePage{ } } } + 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() + } } } diff --git a/src/FluTableModel.h b/src/FluTableModel.h index e2cf8879..80e56e57 100644 --- a/src/FluTableModel.h +++ b/src/FluTableModel.h @@ -8,7 +8,6 @@ class FluTableModel : public QAbstractTableModel { Q_OBJECT -Q_PROPERTY_AUTO(int, dataSourceSize) Q_PROPERTY_AUTO(QList, columnSource) Q_PROPERTY_AUTO(QList, rows) Q_PROPERTY(int rowCount READ rowCount CONSTANT)