qml: avoid hue wrap-around for fees < 1sat/vbyte, limit precision.
This commit is contained in:
@@ -352,7 +352,7 @@ class FeeHistogram:
|
||||
|
||||
def get_capped_data(self):
|
||||
""" used by QML """
|
||||
data = self._data or [[FEERATE_DEFAULT_RELAY/1000,1]]
|
||||
data = self._data or [[FEERATE_DEFAULT_RELAY/1000, 1]]
|
||||
# cap the histogram to a limited number of megabytes
|
||||
bytes_limit = 10*1000*1000
|
||||
bytes_current = 0
|
||||
@@ -360,10 +360,12 @@ class FeeHistogram:
|
||||
for item in sorted(data, key=lambda x: x[0], reverse=True):
|
||||
if bytes_current >= bytes_limit:
|
||||
break
|
||||
slot = min(item[1], bytes_limit-bytes_current)
|
||||
slot = min(item[1], bytes_limit - bytes_current)
|
||||
bytes_current += slot
|
||||
# round & limit precision
|
||||
value = int(item[0] * 100) / 100
|
||||
capped_histogram.append([
|
||||
max(FEERATE_MIN_RELAY/1000, item[0]), # clamped to [FEERATE_MIN_RELAY/1000,inf[
|
||||
max(FEERATE_MIN_RELAY/1000, value), # clamped to [FEERATE_MIN_RELAY/1000,inf]
|
||||
slot, # width of bucket
|
||||
bytes_current, # cumulative depth at far end of bucket
|
||||
])
|
||||
|
||||
@@ -118,7 +118,7 @@ Pane {
|
||||
Layout.preferredWidth: 300 * (modelData[1] / Network.feeHistogram.total)
|
||||
Layout.fillWidth: true
|
||||
height: parent.height
|
||||
color: Qt.hsva(2/3-(2/3*(Math.log(Math.min(600, modelData[0]))/Math.log(600))), 0.8, 1, 1)
|
||||
color: Qt.hsva(2/3-(2/3*(Math.log(Math.min(600, Math.max(modelData[0], 1)))/Math.log(600))), 0.8, 1, 1)
|
||||
ToolTip.text: (qsTr("%1 around depth %2")
|
||||
.arg(modelData[0] + " " + UI_UNIT_NAME.FEERATE_SAT_PER_VB)
|
||||
.arg((modelData[2]/1000000).toFixed(2) + " " + UI_UNIT_NAME.MEMPOOL_MB)
|
||||
|
||||
Reference in New Issue
Block a user