Fixed locale issues for balance chart tooltip and x-axis labels
This commit is contained in:
parent
955169112d
commit
338e6f5fa9
|
@ -11569,7 +11569,6 @@ var Scale = core_element.extend({
|
||||||
// Generate labels using all non-skipped ticks
|
// Generate labels using all non-skipped ticks
|
||||||
labels = me._convertTicksToLabels(me._ticksToDraw);
|
labels = me._convertTicksToLabels(me._ticksToDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
me.ticks = labels; // BACKWARD COMPATIBILITY
|
me.ticks = labels; // BACKWARD COMPATIBILITY
|
||||||
|
|
||||||
// IMPORTANT: after this point, we consider that `this.ticks` will NEVER change!
|
// IMPORTANT: after this point, we consider that `this.ticks` will NEVER change!
|
||||||
|
@ -13052,7 +13051,12 @@ var scale_linear = scale_linearbase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getLabelForIndex: function(index, datasetIndex) {
|
getLabelForIndex: function(index, datasetIndex) {
|
||||||
return this._getScaleLabel(this.chart.data.datasets[datasetIndex].data[index]);
|
var scaleLabel = this._getScaleLabel(this.chart.data.datasets[datasetIndex].data[index]);
|
||||||
|
var optionsTooltips = this.chart.options.tooltips;
|
||||||
|
if (optionsTooltips && optionsTooltips.format && optionsTooltips.format.enabled && optionsTooltips.format.valueCallback) {
|
||||||
|
return optionsTooltips.format.valueCallback(scaleLabel);
|
||||||
|
}
|
||||||
|
return scaleLabel;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
|
@ -14566,6 +14570,11 @@ var scale_time = core_scale.extend({
|
||||||
if (typeof label === 'string') {
|
if (typeof label === 'string') {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
var tooltipsFormat = me.chart.options.tooltips.format;
|
||||||
|
if (tooltipsFormat && tooltipsFormat.enabled && tooltipsFormat.callback) {
|
||||||
|
return tooltipsFormat.callback(label)
|
||||||
|
}
|
||||||
|
|
||||||
return adapter.format(toTimestamp(me, label), timeOpts.displayFormats.datetime);
|
return adapter.format(toTimestamp(me, label), timeOpts.displayFormats.datetime);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -14584,7 +14593,13 @@ var scale_time = core_scale.extend({
|
||||||
var tick = ticks[index];
|
var tick = ticks[index];
|
||||||
var tickOpts = options.ticks;
|
var tickOpts = options.ticks;
|
||||||
var major = majorUnit && majorFormat && tick && tick.major;
|
var major = majorUnit && majorFormat && tick && tick.major;
|
||||||
var label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
|
var labelFormat = me.chart.options.scales.labelFormat;
|
||||||
|
var label;
|
||||||
|
if (labelFormat && labelFormat.enabled && labelFormat.callback)
|
||||||
|
label = labelFormat.callback(time);
|
||||||
|
else
|
||||||
|
label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
|
||||||
|
|
||||||
var nestedTickOpts = major ? tickOpts.major : tickOpts.minor;
|
var nestedTickOpts = major ? tickOpts.major : tickOpts.minor;
|
||||||
var formatter = resolve$5([
|
var formatter = resolve$5([
|
||||||
nestedTickOpts.callback,
|
nestedTickOpts.callback,
|
||||||
|
|
|
@ -132,6 +132,13 @@ Item {
|
||||||
|
|
||||||
chart.animateToNewData()
|
chart.animateToNewData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property var dateToShortLabel: function (value) {
|
||||||
|
const range = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)
|
||||||
|
return range === ChartStoreBase.TimeRange.Weekly || range === ChartStoreBase.TimeRange.Monthly ?
|
||||||
|
LocaleUtils.getDayMonth(value) :
|
||||||
|
LocaleUtils.getMonthYear(value)
|
||||||
|
}
|
||||||
chart.chartType: 'line'
|
chart.chartType: 'line'
|
||||||
chart.chartData: {
|
chart.chartData: {
|
||||||
return {
|
return {
|
||||||
|
@ -170,6 +177,15 @@ Item {
|
||||||
//},
|
//},
|
||||||
//pan:{enabled:true,mode:'x'},
|
//pan:{enabled:true,mode:'x'},
|
||||||
tooltips: {
|
tooltips: {
|
||||||
|
format: {
|
||||||
|
enabled: graphDetail.selectedGraphType === AssetsDetailView.GraphType.Balance,
|
||||||
|
callback: function (value) {
|
||||||
|
return graphDetail.dateToShortLabel(value)
|
||||||
|
},
|
||||||
|
valueCallback: function(value) {
|
||||||
|
return LocaleUtils.currencyAmountToLocaleString({ amount: value, symbol: RootStore.currencyStore.currentCurrencySymbol, displayDecimals: 2 })
|
||||||
|
}
|
||||||
|
},
|
||||||
intersect: false,
|
intersect: false,
|
||||||
displayColors: false,
|
displayColors: false,
|
||||||
callbacks: {
|
callbacks: {
|
||||||
|
@ -179,12 +195,21 @@ Item {
|
||||||
label += ': ';
|
label += ': ';
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = LocaleUtils.currencyAmountToLocaleString({ amount: tooltipItem.yLabel.toFixed(2), symbol: RootStore.currencyStore.currentCurrencySymbol })
|
if (graphDetail.selectedGraphType === AssetsDetailView.GraphType.Balance)
|
||||||
|
return label + tooltipItem.yLabel // already formatted in tooltips.value.callback
|
||||||
|
|
||||||
|
const value = LocaleUtils.currencyAmountToLocaleString({ amount: tooltipItem.yLabel, symbol: RootStore.currencyStore.currentCurrencySymbol, displayDecimals: 2 })
|
||||||
return label + value
|
return label + value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
|
labelFormat: {
|
||||||
|
callback: function (value) {
|
||||||
|
return graphDetail.dateToShortLabel(value)
|
||||||
|
},
|
||||||
|
enabled: graphDetail.selectedGraphType === AssetsDetailView.GraphType.Balance,
|
||||||
|
},
|
||||||
xAxes: [{
|
xAxes: [{
|
||||||
id: 'x-axis-1',
|
id: 'x-axis-1',
|
||||||
position: 'bottom',
|
position: 'bottom',
|
||||||
|
|
Loading…
Reference in New Issue