diff --git a/src/plugins/plugin.tooltip.js b/src/plugins/plugin.tooltip.js index 0c5bc1eed5e..f5c136e9be9 100644 --- a/src/plugins/plugin.tooltip.js +++ b/src/plugins/plugin.tooltip.js @@ -77,13 +77,14 @@ defaults._set('tooltips', { // Args are: (tooltipItem, data) beforeLabel: helpers.noop, label: function(tooltipItem, data) { - var label = data.datasets[tooltipItem.datasetIndex].label || ''; + let label = data.datasets[tooltipItem.datasetIndex].label || ''; if (label) { label += ': '; } - if (!helpers.isNullOrUndef(tooltipItem.value)) { - label += tooltipItem.value; + const value = tooltipItem.value; + if (!helpers.isNullOrUndef(value)) { + label += value; } return label; }, diff --git a/src/scales/scale.linearbase.js b/src/scales/scale.linearbase.js index 4c5d73b5465..3d894ad767c 100644 --- a/src/scales/scale.linearbase.js +++ b/src/scales/scale.linearbase.js @@ -242,6 +242,10 @@ class LinearScaleBase extends Scale { me._endValue = end; me._valueRange = end - start; } + + getLabelForValue(value) { + return new Intl.NumberFormat().format(value); + } } export default LinearScaleBase; diff --git a/src/scales/scale.logarithmic.js b/src/scales/scale.logarithmic.js index d44963a41a3..3df308276a3 100644 --- a/src/scales/scale.logarithmic.js +++ b/src/scales/scale.logarithmic.js @@ -136,7 +136,7 @@ class LogarithmicScale extends Scale { } getLabelForValue(value) { - return value === undefined ? 0 : value; + return value === undefined ? 0 : new Intl.NumberFormat().format(value); } getPixelForTick(index) { diff --git a/test/specs/scale.linear.tests.js b/test/specs/scale.linear.tests.js index ef3f7e8d87b..073aa31dc22 100644 --- a/test/specs/scale.linear.tests.js +++ b/test/specs/scale.linear.tests.js @@ -332,7 +332,7 @@ describe('Linear Scale', function() { }); chart.update(); - expect(chart.scales.y.getLabelForValue(7)).toBe(7); + expect(chart.scales.y.getLabelForValue(7)).toBe('7'); }); it('Should correctly determine the min and max data values when stacked mode is turned on', function() { diff --git a/test/specs/scale.logarithmic.tests.js b/test/specs/scale.logarithmic.tests.js index 567bdcee44e..0cab2eef7d6 100644 --- a/test/specs/scale.logarithmic.tests.js +++ b/test/specs/scale.logarithmic.tests.js @@ -738,7 +738,7 @@ describe('Logarithmic Scale tests', function() { } }); - expect(chart.scales.y.getLabelForValue(150)).toBe(150); + expect(chart.scales.y.getLabelForValue(150)).toBe('150'); }); describe('when', function() { diff --git a/test/specs/scale.radialLinear.tests.js b/test/specs/scale.radialLinear.tests.js index a2580661579..576d0b4dcf5 100644 --- a/test/specs/scale.radialLinear.tests.js +++ b/test/specs/scale.radialLinear.tests.js @@ -414,7 +414,7 @@ describe('Test the radial linear scale', function() { } } }); - expect(chart.scales.r.getLabelForValue(5)).toBe(5); + expect(chart.scales.r.getLabelForValue(5)).toBe('5'); }); it('should get the correct distance from the center point', function() {