diff --git a/package/contents/ui/components/functions.js b/package/contents/ui/components/functions.js index 356bc7b..9aabbc5 100644 --- a/package/contents/ui/components/functions.js +++ b/package/contents/ui/components/functions.js @@ -20,15 +20,15 @@ function getNetworkDialectInfo(dialect) { suffix: i18nc("kilobyte suffix", "Bps"), kiloChar: "k", KiBDiff: 1.024, - multiplier: 1000, + multiplier: 1024, }; case "kilobit": return { name: "kilobit", suffix: i18nc("kilobit suffix", "bps"), kiloChar: "k", - KiBDiff: 8.192, - multiplier: 1000, + KiBDiff: 8, + multiplier: 1024, }; default: return { diff --git a/package/contents/ui/components/graph/NetworkGraph.qml b/package/contents/ui/components/graph/NetworkGraph.qml index b10f8c6..0429c42 100644 --- a/package/contents/ui/components/graph/NetworkGraph.qml +++ b/package/contents/ui/components/graph/NetworkGraph.qml @@ -41,6 +41,9 @@ RMBaseGraph.TwoSensorsGraph { } // Override methods, for commulate sensors and support custom dialect + property var _downloadValue + property var _uploadValue + _update: () => { // Cummulate sensors by group let data; @@ -56,9 +59,9 @@ RMBaseGraph.TwoSensorsGraph { } } - // Fix dialect - downloadValue *= dialect.KiBDiff; - uploadValue *= dialect.KiBDiff; + // Fix dialect AND store it for update label + _downloadValue = downloadValue *= dialect.KiBDiff; + _uploadValue = uploadValue *= dialect.KiBDiff; // Insert datas root._insertChartData(0, downloadValue); @@ -70,7 +73,24 @@ RMBaseGraph.TwoSensorsGraph { _updateData(1); } } - _formatValue: (_, data) => Functions.formatByteValue(data.value, dialect) + + function _updateData(index) { + // Cancel update if first data is not here + if (!sensorsModel.hasIndex(0, 0)) { + return; + } + + // Retrieve label need to update + const label = _getLabel(index); + if (typeof label === "undefined" || !label.enabled) { + return; + } + const value = index === 0 ? _downloadValue : _uploadValue; + + // Show value on label + label.text = Functions.formatByteValue(value, dialect); + label.visible = true; + } function _updateSensors() { if (typeof networkInterfaces.model.count === "undefined") {