From 1279c9c927d1d563f4719f8edfb410f280e1e606 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Wed, 13 Mar 2019 11:36:10 +0200 Subject: [PATCH] Make decimalPlaces private and update CDN links (#6131) --- docs/README.md | 2 +- docs/getting-started/README.md | 2 +- src/core/core.helpers.js | 3 ++- src/scales/scale.linearbase.js | 2 +- test/specs/core.helpers.tests.js | 16 ++++++++-------- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/README.md b/docs/README.md index d0b0544ab0c..9592ecf2c10 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,7 +4,7 @@ ## Installation -You can download the latest version of Chart.js from the [GitHub releases](https://github.com/chartjs/Chart.js/releases/latest) or use a [Chart.js CDN](https://cdnjs.com/libraries/Chart.js). Detailed installation instructions can be found on the [installation](./getting-started/installation.md) page. +You can download the latest version of Chart.js from the [GitHub releases](https://github.com/chartjs/Chart.js/releases/latest) or use a [Chart.js CDN](https://www.jsdelivr.com/package/npm/chart.js). Detailed installation instructions can be found on the [installation](./getting-started/installation.md) page. ## Creating a Chart diff --git a/docs/getting-started/README.md b/docs/getting-started/README.md index 5a879c4ce51..9dd7ed684d0 100644 --- a/docs/getting-started/README.md +++ b/docs/getting-started/README.md @@ -11,7 +11,7 @@ First, we need to have a canvas in our page. Now that we have a canvas we can use, we need to include Chart.js in our page. ```html - + ``` Now, we can create a chart. We add a script to our page: diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 5b4aec34c7e..7922747dee9 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -125,8 +125,9 @@ module.exports = function() { * i.e. the number of digits after the decimal point, of the value of this Number. * @param {number} x - A number. * @returns {number} The number of decimal places. + * @private */ - helpers.decimalPlaces = function(x) { + helpers._decimalPlaces = function(x) { if (!helpers.isFinite(x)) { return; } diff --git a/src/scales/scale.linearbase.js b/src/scales/scale.linearbase.js index 24816e9225e..7f68279db6c 100644 --- a/src/scales/scale.linearbase.js +++ b/src/scales/scale.linearbase.js @@ -44,7 +44,7 @@ function generateTicks(generationOptions, dataRange) { if (stepSize || isNullOrUndef(precision)) { // If a precision is not specified, calculate factor based on spacing - factor = Math.pow(10, helpers.decimalPlaces(spacing)); + factor = Math.pow(10, helpers._decimalPlaces(spacing)); } else { // If the user specified a precision, round to that number of decimal places factor = Math.pow(10, precision); diff --git a/test/specs/core.helpers.tests.js b/test/specs/core.helpers.tests.js index b0c7431c859..a075c0e8d85 100644 --- a/test/specs/core.helpers.tests.js +++ b/test/specs/core.helpers.tests.js @@ -73,14 +73,14 @@ describe('Core helper tests', function() { }); it('should get the correct number of decimal places', function() { - expect(helpers.decimalPlaces(100)).toBe(0); - expect(helpers.decimalPlaces(1)).toBe(0); - expect(helpers.decimalPlaces(0)).toBe(0); - expect(helpers.decimalPlaces(0.01)).toBe(2); - expect(helpers.decimalPlaces(-0.01)).toBe(2); - expect(helpers.decimalPlaces('1')).toBe(undefined); - expect(helpers.decimalPlaces('')).toBe(undefined); - expect(helpers.decimalPlaces(undefined)).toBe(undefined); + expect(helpers._decimalPlaces(100)).toBe(0); + expect(helpers._decimalPlaces(1)).toBe(0); + expect(helpers._decimalPlaces(0)).toBe(0); + expect(helpers._decimalPlaces(0.01)).toBe(2); + expect(helpers._decimalPlaces(-0.01)).toBe(2); + expect(helpers._decimalPlaces('1')).toBe(undefined); + expect(helpers._decimalPlaces('')).toBe(undefined); + expect(helpers._decimalPlaces(undefined)).toBe(undefined); }); it('should get an angle from a point', function() {