feat(wallet): Fixed balance history chart to use new balance history data based on transfers

This commit is contained in:
Ivan Belyakov 2023-09-15 19:27:00 +02:00 committed by IvanBelyakoff
parent 7171094f01
commit 955169112d
2 changed files with 15 additions and 17 deletions

View File

@ -141,7 +141,7 @@ Item {
yAxisId: 'y-axis-1',
backgroundColor: (Theme.palette.name === "dark") ? 'rgba(136, 176, 255, 0.2)' : 'rgba(67, 96, 223, 0.2)',
borderColor: (Theme.palette.name === "dark") ? 'rgba(136, 176, 255, 1)' : 'rgba(67, 96, 223, 1)',
borderWidth: 3,
borderWidth: graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? 3 : 2,
pointRadius: 0,
data: RootStore.marketHistoryIsLoading ? [] : graphDetail.dataRange,
parsing: false,
@ -156,6 +156,11 @@ Item {
legend: {
display: false
},
elements: {
line: {
cubicInterpolationMode: 'monotone' // without it interpolation makes the line too curvy that can extend horizontally farther then data points
}
},
//TODO enable zoom
//zoom: {
// enabled: true,
@ -173,8 +178,9 @@ Item {
if (label) {
label += ': ';
}
label += tooltipItem.yLabel.toFixed(2);
return label.slice(0,label.indexOf(":")+1) + " %1".arg(RootStore.currencyStore.currentCurrencySymbol) + label.slice(label.indexOf(":") + 2, label.length);
const value = LocaleUtils.currencyAmountToLocaleString({ amount: tooltipItem.yLabel.toFixed(2), symbol: RootStore.currencyStore.currentCurrencySymbol })
return label + value
}
}
},
@ -182,6 +188,7 @@ Item {
xAxes: [{
id: 'x-axis-1',
position: 'bottom',
type: graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? 'category' : 'time',
gridLines: {
drawOnChartArea: false,
drawBorder: false,
@ -195,6 +202,9 @@ Item {
minRotation: 0,
maxTicksLimit: graphDetail.maxTicksLimit,
},
time: {
minUnit: 'day' // for '7days' timeframe, otherwise labels are '10PM', '10AM', '10PM', etc
}
}],
yAxes: [{
position: 'left',

View File

@ -31,27 +31,22 @@ ChartStoreBase {
switch(timeRange) {
case ChartStoreBase.TimeRange.Weekly:
root.weeklyData = balanceData
root.weeklyTimeRange = timeRangeData
root.weeklyMaxTicks = 0
break;
case ChartStoreBase.TimeRange.Monthly:
root.monthlyData = balanceData
root.monthlyTimeRange = timeRangeData
root.monthlyMaxTicks = 0
break;
case ChartStoreBase.TimeRange.HalfYearly:
root.halfYearlyData = balanceData
root.halfYearlyTimeRange = timeRangeData
root.halfYearlyMaxTicks = 0
break;
case ChartStoreBase.TimeRange.Yearly:
root.yearlyData = balanceData
root.yearlyTimeRange = timeRangeData
root.yearlyMaxTicks = 0
break;
case ChartStoreBase.TimeRange.All:
root.allData = balanceData
root.allTimeRange = timeRangeData
root.allTimeRangeTicks = 0
break;
default:
@ -92,20 +87,13 @@ ChartStoreBase {
return
}
var tmpTimeRange = []
var tmpDataValues = []
for(let i = 0; i < response.historicalData.length; i++) {
let dataEntry = response.historicalData[i]
let dateString = response.timeInterval == ChartStoreBase.TimeRange.Weekly || response.timeInterval == ChartStoreBase.TimeRange.Monthly
? LocaleUtils.getDayMonth(dataEntry.time * 1000)
: LocaleUtils.getMonthYear(dataEntry.time * 1000)
tmpTimeRange.push(dateString)
tmpDataValues.push(dataEntry.value)
tmpDataValues.push({ x: new Date(dataEntry.time * 1000), y: dataEntry.value })
}
root.setData(response.address, response.tokenSymbol, response.currencySymbol, response.timeInterval, tmpTimeRange, tmpDataValues)
root.setData(response.address, response.tokenSymbol, response.currencySymbol, response.timeInterval, [], tmpDataValues)
}
}
}