Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make decimalPlaces private and update CDN links #6131

Merged
merged 3 commits into from Mar 13, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/README.md
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/core/core.helpers.js
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/scales/scale.linearbase.js
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions test/specs/core.helpers.tests.js
Expand Up @@ -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() {
Expand Down