Make decimalPlaces private and update CDN links (#6131)

This commit is contained in:
Jukka Kurkela 2019-03-13 11:36:10 +02:00 committed by Simon Brunel
parent 152f1d9725
commit 75e76cffe5
5 changed files with 13 additions and 12 deletions

View File

@ -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

View File

@ -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
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
```
Now, we can create a chart. We add a script to our page:

View File

@ -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;
}

View File

@ -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);

View File

@ -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() {