@@ -12,28 +12,37 @@ Item {
1212 property bool showGraphDots: settingsManager .graphShowDots
1313 property color legendColor: Theme .colorSubText
1414
15- property real limitMin : 0
16- property real limitMax : 0
15+ property real valueMin_p : 0
16+ property real valueMax_p : 100
1717
18- property real valueMin: 0
19- property real valueMax: 20
18+ property real valueMin_v: 0
19+ property real valueMax_v: 20
20+ property real limitMin_v: 0
21+ property real limitMax_v: 0
2022
2123 // //////////////////////////////////////////////////////////////////////////
2224
2325 function loadGraph () {
2426 if (typeof currentDevice === " undefined" || ! currentDevice) return
2527 // console.log("chartBatteryHistory // loadGraph() >> " + currentDevice)
2628
27- battery2Data .visible = true // currentDevice.hasBatteryVoltage
28- battery2Data .clear ()
29+ // // DATA
30+ batteryData_p .clear ()
31+ batteryData_v .clear ()
32+
33+ batteryData_p .visible = true
34+ batteryData_v .visible = false // currentDevice.hasBatteryVoltage
2935
36+ // // AXIS
3037 axisPercents .min = 0
3138 axisPercents .max = 100
32- axisVolts .min = valueMin
33- axisVolts .max = valueMax
3439
35- chartBatteryHistory .limitMin = (currentPreset) ? currentPreset .voltageMin : 0
36- chartBatteryHistory .limitMax = (currentPreset) ? currentPreset .voltageMax : 0
40+ axisVolts .min = valueMin_v
41+ axisVolts .max = valueMax_v
42+
43+ // // LEGEND
44+ chartBatteryHistory .limitMin_v = (currentPreset) ? currentPreset .voltageMin : 0
45+ chartBatteryHistory .limitMax_v = (currentPreset) ? currentPreset .voltageMax : 0
3746 chartBatteryHistory .legendColor = Qt .rgba (legendColor .r , legendColor .g , legendColor .b , 0.8 )
3847 }
3948
@@ -45,16 +54,16 @@ Item {
4554 var count = 0 // currentDevice.countDataNamed("battery2", days)
4655
4756 // // DATA
48- battery2Data .clear ()
57+ batteryData_v .clear ()
4958
50- currentDevice .getChartData_batteryHistory (axisTime, battery2Data , false , days)
59+ currentDevice .getChartData_batteryHistory (axisTime, batteryData_v , false , days)
5160
5261 // // AXIS
5362 // axisVolts.min = currentDevice.voltMin*0.85
5463 // axisVolts.max = currentDevice.voltMax*1.15
5564
5665 // / Graph visibility
57- count = battery2Data .count
66+ count = batteryData_v .count
5867 aioGraph .visible = (count > 1 )
5968 noDataIndicator .visible = (count <= 0 )
6069 showGraphDots = (settingsManager .graphShowDots && count < 16 )
@@ -65,21 +74,23 @@ Item {
6574
6675 if (currentPreset) {
6776 // console.log("DeviceBatteryMonitor // onPresetUpdated() >> " + currentPreset.name)
68- chartBatteryHistory .limitMin = currentPreset .voltageMin
69- chartBatteryHistory .limitMax = currentPreset .voltageMax
77+ chartBatteryHistory .limitMin_v = currentPreset .voltageMin
78+ chartBatteryHistory .limitMax_v = currentPreset .voltageMax
7079 } else {
7180 // console.log("DeviceBatteryMonitor // onPresetUpdated() >> empty preset")
72- chartBatteryHistory .limitMin = 0
73- chartBatteryHistory .limitMax = 0
81+ chartBatteryHistory .limitMin_v = 0
82+ chartBatteryHistory .limitMax_v = 0
7483 }
7584 }
7685
77- function qpoint_lerp (p0 , p1 , x ) { return (p0 .y + (x - p0 .x ) * ((p1 .y - p0 .y ) / (p1 .x - p0 .x ))) }
86+ function isIndicator () { return false }
87+ function resetIndicator () { }
7888
7989 // //////////////////////////////////////////////////////////////////////////
8090
8191 ChartView {
8292 id: aioGraph
93+
8394 anchors .fill : parent
8495 anchors .topMargin : - 28
8596 anchors .leftMargin : - 24
@@ -101,10 +112,17 @@ Item {
101112 gridLineColor: Theme .colorSeparator ; }
102113
103114 LineSeries {
104- id: battery2Data
115+ id: batteryData_p
105116 useOpenGL: useOpenGL
106117 pointsVisible: showGraphDots
107118 color: Theme .colorBlue ; width: 2 ;
119+ axisY: axisPercents; axisX: axisTime;
120+ }
121+ LineSeries {
122+ id: batteryData_v
123+ useOpenGL: useOpenGL
124+ pointsVisible: showGraphDots
125+ color: Theme .colorGreen ; width: 2 ;
108126 axisY: axisVolts; axisX: axisTime;
109127 }
110128
@@ -126,47 +144,7 @@ Item {
126144 }
127145
128146 function moveIndicator (mouse , isMoving ) {
129- var mmm = Qt .point (mouse .x , mouse .y )
130- /*
131- // we adjust coordinates with graph area margins
132- var ppp = Qt.point(mouse.x, mouse.y)
133- ppp.x = ppp.x + aioGraph.anchors.rightMargin
134- ppp.y = ppp.y - aioGraph.anchors.topMargin
135-
136- // map mouse position to graph value // mpmp.x is the timestamp
137- var mpmp = aioGraph.mapToValue(mmm, batteryData)
138-
139- //console.log("clicked " + mouse.x + " " + mouse.y)
140- //console.log("clicked adjusted " + ppp.x + " " + ppp.y)
141- //console.log("clicked mapped " + mpmp.x + " " + mpmp.y)
142-
143- if (isMoving) {
144- // dragging outside the graph area?
145- if (mpmp.x < batteryData.at(0).x){
146- ppp.x = aioGraph.mapToPosition(batteryData.at(0), batteryData).x + aioGraph.anchors.rightMargin
147- mpmp.x = batteryData.at(0).x
148- }
149- if (mpmp.x > batteryData.at(batteryData.count-1).x){
150- ppp.x = aioGraph.mapToPosition(batteryData.at(batteryData.count-1), batteryData).x + aioGraph.anchors.rightMargin
151- mpmp.x = batteryData.at(batteryData.count-1).x
152- }
153- } else {
154- // did we clicked outside the graph area?
155- if (mpmp.x < batteryData.at(0).x || mpmp.x > batteryData.at(batteryData.count-1).x) {
156- resetIndicator()
157- return
158- }
159- }
160-
161- // indicators is now visible
162- dateIndicator.visible = true
163- verticalIndicator.visible = true
164- verticalIndicator.x = ppp.x
165- verticalIndicator.clickedCoordinates = mpmp
166-
167- // update the indicator data
168- updateIndicator()
169- */
147+ //
170148 }
171149 }
172150
@@ -187,10 +165,10 @@ Item {
187165 anchors .left : parent .left
188166 anchors .right : parent .right
189167
190- y: UtilsNumber .mapNumber (Math .min (limitMax, valueMax ), // value
191- valueMin, valueMax , // from
168+ y: UtilsNumber .mapNumber (Math .min (limitMax_v, valueMax_v ), // value
169+ valueMin_p, valueMax_v , // from
192170 aioGraph .plotArea .height , 0 ) // to
193- height: ((Math .min (limitMax, valueMax ) - limitMin ) / (valueMax - valueMin )) * aioGraph .plotArea .height
171+ height: ((Math .min (limitMax_v, valueMax_v ) - limitMin_v ) / (valueMax_v - valueMin_v )) * aioGraph .plotArea .height
194172
195173 color: Theme .colorGreen
196174 opacity: 0.20
0 commit comments