qml: piechart from wallet.get_balances_for_piechart
This commit is contained in:
@@ -56,14 +56,21 @@ Pane {
|
||||
implicitHeight: 220 // TODO: sane value dependent on screen
|
||||
innerOffset: 6
|
||||
function updateSlices() {
|
||||
var totalB = Daemon.currentWallet.totalBalance.satsInt
|
||||
var onchainB = Daemon.currentWallet.confirmedBalance.satsInt
|
||||
var frozenB = Daemon.currentWallet.frozenBalance.satsInt
|
||||
var lnB = Daemon.currentWallet.lightningBalance.satsInt
|
||||
var p = Daemon.currentWallet.getBalancesForPiechart()
|
||||
var total = p['total']
|
||||
piechart.slices = [
|
||||
{ v: lnB/totalB, color: constants.colorPiechartLightning, text: 'Lightning' },
|
||||
{ v: (onchainB-frozenB)/totalB, color: constants.colorPiechartOnchain, text: 'On-chain' },
|
||||
{ v: frozenB/totalB, color: constants.colorPiechartFrozen, text: 'On-chain (frozen)' },
|
||||
{ v: p['lightning']/total,
|
||||
color: constants.colorPiechartLightning, text: qsTr('Lightning') },
|
||||
{ v: p['confirmed']/total,
|
||||
color: constants.colorPiechartOnchain, text: 'On-chain' },
|
||||
{ v: p['frozen']/total,
|
||||
color: constants.colorPiechartFrozen, text: 'On-chain (frozen)' },
|
||||
{ v: p['unconfirmed']/total,
|
||||
color: constants.colorPiechartFrozen, text: 'Unconfirmed' },
|
||||
{ v: p['unmatured']/total,
|
||||
color: constants.colorPiechartFrozen, text: 'Unmatured' },
|
||||
{ v: p['f_lightning']/total,
|
||||
color: constants.colorPiechartLightningFrozen, text: 'Frozen Lightning' },
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -154,7 +161,7 @@ Pane {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ButtonContainer {
|
||||
Layout.fillWidth: true
|
||||
FlatButton {
|
||||
|
||||
@@ -48,7 +48,11 @@ Item {
|
||||
|
||||
property color colorPiechartOnchain: Qt.darker(Material.accentColor, 1.50)
|
||||
property color colorPiechartFrozen: 'gray'
|
||||
property color colorPiechartLightning: 'orange' //Qt.darker(Material.accentColor, 1.20)
|
||||
property color colorPiechartLightning: 'orange'
|
||||
property color colorPiechartLightningFrozen: Qt.darker('orange', 1.20)
|
||||
property color colorPiechartUnconfirmed: Qt.darker(Material.accentColor, 2.00)
|
||||
property color colorPiechartUnmatured: 'magenta'
|
||||
|
||||
property color colorPiechartParticipant: 'gray'
|
||||
property color colorPiechartSignature: 'yellow'
|
||||
|
||||
|
||||
@@ -745,3 +745,16 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
tx = self.wallet.db.get_transaction(txid)
|
||||
txqr = tx.to_qr_data()
|
||||
return [str(tx), txqr[0], txqr[1]]
|
||||
|
||||
@pyqtSlot(result='QVariantMap')
|
||||
def getBalancesForPiechart(self):
|
||||
confirmed, unconfirmed, unmatured, frozen, lightning, f_lightning = balances = self.wallet.get_balances_for_piechart()
|
||||
return {
|
||||
'confirmed': confirmed,
|
||||
'unconfirmed': unconfirmed,
|
||||
'unmatured': unmatured,
|
||||
'frozen': frozen,
|
||||
'lightning': int(lightning),
|
||||
'f_lightning': int(f_lightning),
|
||||
'total': sum([int(x) for x in list(balances)])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user