Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/scales/scale.linearbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,6 @@ export default class LinearScaleBase extends Scale {
}

getLabelForValue(value) {
return formatNumber(value, this.options.locale);
return formatNumber(value, this.chart.options.locale);
}
}
2 changes: 1 addition & 1 deletion src/scales/scale.logarithmic.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default class LogarithmicScale extends Scale {
* @return {string}
*/
getLabelForValue(value) {
return value === undefined ? '0' : formatNumber(value, this.options.locale);
return value === undefined ? '0' : formatNumber(value, this.chart.options.locale);
}

/**
Expand Down
40 changes: 40 additions & 0 deletions test/specs/scale.linear.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,46 @@ describe('Linear Scale', function() {
expect(chart.scales.y.getLabelForValue(7)).toBe('7');
});

it('Should correctly use the locale setting when getting a label', function() {
var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
xAxisID: 'x',
yAxisID: 'y',
data: [{
x: 10,
y: 100
}, {
x: -10,
y: 0
}, {
x: 0,
y: 0
}, {
x: 99,
y: 7
}]
}],
},
options: {
locale: 'de-DE',
scales: {
x: {
type: 'linear',
position: 'bottom'
},
y: {
type: 'linear'
}
}
}
});
chart.update();

expect(chart.scales.y.getLabelForValue(7.07)).toBe('7,07');
});

it('Should correctly determine the min and max data values when stacked mode is turned on', function() {
var chart = window.acquireChart({
type: 'line',
Expand Down
33 changes: 33 additions & 0 deletions test/specs/scale.logarithmic.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,39 @@ describe('Logarithmic Scale tests', function() {
expect(chart.scales.y.getLabelForValue(150)).toBe('150');
});

it('should correctly use the locale when generating the label', function() {
var chart = window.acquireChart({
type: 'bar',
data: {
datasets: [{
yAxisID: 'y',
data: [10, 5, 5000, 78, 450]
}, {
yAxisID: 'y1',
data: [1, 1000, 10, 100],
}, {
yAxisID: 'y',
data: [150]
}],
labels: []
},
options: {
locale: 'de-DE',
scales: {
y: {
type: 'logarithmic'
},
y1: {
position: 'right',
type: 'logarithmic'
}
}
}
});

expect(chart.scales.y.getLabelForValue(10.25)).toBe('10,25');
});

describe('when', function() {
var data = [
{
Expand Down