Add graphs generated from journey data
[harbour-pedalo.git] / qml / pages / Stats.qml
index 39ccc79..8e13f97 100644 (file)
@@ -1,5 +1,6 @@
 import QtQuick 2.0
 import Sailfish.Silica 1.0
+import harbour.pedalo.graph 1.0
 import "../components"
 
 Page {
@@ -70,5 +71,100 @@ Page {
                 horizontalAlignment: Text.AlignRight
             }
         }
+
+        SlideshowView {
+            id: graphsView
+            width: isPortrait ? parent.width : parent.width * 0.5
+            height: (isPortrait ? statsPage.height / 2.0 : statsPage.height) - Theme.paddingLarge
+            itemWidth: width
+            clip: true
+            anchors.left: isPortrait ? statsColumn.left : statsColumn.right
+            anchors.leftMargin: 0
+
+            y: (isPortrait ? (statsPage.height / 2.0) : statsColumn.y)
+
+            onModelChanged: {
+                console.log("Model changed");
+                model.updateAll();
+            }
+
+            model: statsmodel
+            delegate: Rectangle {
+                width: graphsView.itemWidth
+                height: graphsView.height
+                color: "transparent"
+
+                SectionHeader {
+                    id: sectionHeaderItem
+                    text: title
+                }
+
+                Graph {
+                    id: graph
+                    width: parent.width - Theme.horizontalPageMargin
+                    anchors.top: sectionHeaderItem.bottom
+                    height: (isPortrait ? (statsPage.height / 2.0) - Theme.paddingLarge : statsPage.height - Theme.paddingLarge - headerItem.height) - sectionHeaderItem.height
+                    anchors.left: parent.left
+                    model: values
+                    labelsx: labels
+                    //labelsy: ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
+                    unitsy: units
+                    primary: Theme.primaryColor
+                    secondary: Theme.highlightColor
+                    highlight: Theme.highlightColor
+                    miny: minval
+                    maxy: maxval
+                    stepy: step
+                    gap: 0.1
+                    fontsize: Theme.fontSizeExtraSmall
+                    /*
+                    PropertyAnimation on animate {
+                        id: animx
+                        duration: 2000
+                        easing.type: Easing.InOutExpo
+                        from: 0.0
+                        to: 1.0
+                    }
+                    */
+                }
+
+            }
+        }
+
+        /*
+        Column {
+            id: graphsColumn
+            spacing: Theme.paddingLarge
+            width: isPortrait ? parent.width : parent.width * 0.5
+            y: (isPortrait ? (statsPage.height / 2.0) : statsColumn.y)
+            anchors.left: isPortrait ? statsColumn.left : statsColumn.right
+            anchors.leftMargin: Theme.horizontalPageMargin
+
+
+            Graph {
+                id: graph
+                width: parent.width - 2 * Theme.horizontalPageMargin
+                height: isPortrait ? (statsPage.height / 2.0) - Theme.paddingLarge : statsPage.height - Theme.paddingLarge - headerItem.height
+                model: currentStatus.getGraphData()
+                labelsx: ["M", "T", "W", "Th", "F", "S", "Su", "A", "B", "C"]
+                //labelsy: ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
+                unitsy: "%"
+                primary: Theme.primaryColor
+                secondary: Theme.highlightColor
+                highlight: Theme.highlightColor
+                miny: 0.0
+                maxy: 1.0
+                stepy: 0.1
+                gap: 0.1
+                fontsize: Theme.fontSizeExtraSmall
+                PropertyAnimation on animate {
+                    duration: 2000
+                    easing.type: Easing.InOutExpo
+                    from: 0.0
+                    to: 1.0
+                }
+            }
+        }
+        */
     }
 }