Skip to content

Commit

Permalink
Use latest Chart.js ESLint config (tab -> space)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrunel committed Apr 9, 2021
1 parent 3589a49 commit 86f299f
Show file tree
Hide file tree
Showing 13 changed files with 360 additions and 350 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="docs/assets/banner.png"/>
<img src="docs/assets/banner.png"/>
</div>

[![github](https://img.shields.io/github/release/chartjs/chartjs-plugin-deferred.svg?style=flat-square&maxAge=600)](https://github.com/chartjs/chartjs-plugin-deferred/releases/latest) [![travis](https://img.shields.io/travis/chartjs/chartjs-plugin-deferred.svg?style=flat-square&maxAge=600)](https://travis-ci.org/chartjs/chartjs-plugin-deferred) [![codeclimate](https://img.shields.io/codeclimate/maintainability/chartjs/chartjs-plugin-deferred.svg?style=flat-square&maxAge=600)](https://codeclimate.com/github/chartjs/chartjs-plugin-deferred)
Expand Down Expand Up @@ -37,17 +37,21 @@ new Chart(ctx, {

You first need to install node dependencies (requires [Node.js](https://nodejs.org/)):

> npm install
```sh
> npm install
```

The following commands will then be available from the repository root:

> npm run build // build dist files
> npm run build:dev // build and watch for changes
> npm run lint // perform code linting
> npm run lint -- --fix // automatically fix linting problems
> npm run docs // generate documentation (`dist/docs`)
> npm run docs:dev // generate documentation and watch for changes
> npm run package // create tgz and zip archives with dist files
```sh
> npm run build // build dist files
> npm run build:dev // build and watch for changes
> npm run lint // perform code linting
> npm run lint -- --fix // automatically fix linting problems
> npm run docs // generate documentation (`dist/docs`)
> npm run docs:dev // generate documentation and watch for changes
> npm run package // create tgz and zip archives with dist files
```

## License

Expand Down
94 changes: 47 additions & 47 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
const pkg = require('../../package.json');

module.exports = {
dest: 'dist/docs',
theme: 'chartjs',
title: pkg.name,
description: pkg.description,
head: [
['link', {rel: 'icon', href: '/favicon.png'}],
],
plugins: [
['@vuepress/google-analytics', {
ga: 'UA-99068522-3'
}],
['redirect', {
redirectors: [
{base: '/samples', alternative: ['delay']},
{base: '/', alternative: ['guide/']},
],
}],
],
themeConfig: {
repo: 'chartjs/chartjs-plugin-deferred',
logo: '/favicon.png',
lastUpdated: 'Last Updated',
editLinks: true,
docsDir: 'docs',
chart: {
imports: [
['scripts/register.js'],
['scripts/defaults.js'],
['scripts/utils.js', 'Utils'],
]
},
nav: [
{text: 'Guide', link: '/guide/'},
{text: 'Samples', link: '/samples/'},
],
sidebar: {
'/guide/': [
'',
'installation',
'options',
],
'/samples/': [
'delay.md',
'offset.md',
]
}
}
dest: 'dist/docs',
theme: 'chartjs',
title: pkg.name,
description: pkg.description,
head: [
['link', {rel: 'icon', href: '/favicon.png'}],
],
plugins: [
['@vuepress/google-analytics', {
ga: 'UA-99068522-3'
}],
['redirect', {
redirectors: [
{base: '/samples', alternative: ['delay']},
{base: '/', alternative: ['guide/']},
],
}],
],
themeConfig: {
repo: 'chartjs/chartjs-plugin-deferred',
logo: '/favicon.png',
lastUpdated: 'Last Updated',
editLinks: true,
docsDir: 'docs',
chart: {
imports: [
['scripts/register.js'],
['scripts/defaults.js'],
['scripts/utils.js', 'Utils'],
]
},
nav: [
{text: 'Guide', link: '/guide/'},
{text: 'Samples', link: '/samples/'},
],
sidebar: {
'/guide/': [
'',
'installation',
'options',
],
'/samples/': [
'delay.md',
'offset.md',
]
}
}
};
14 changes: 10 additions & 4 deletions docs/guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@

[![npm](https://img.shields.io/npm/v/chartjs-plugin-deferred.svg?style=flat-square&maxAge=600)](https://npmjs.com/package/chartjs-plugin-deferred) [![npm downloads](https://img.shields.io/npm/dm/chartjs-plugin-deferred.svg?style=flat-square&maxAge=600)](https://npmjs.com/package/chartjs-plugin-deferred)

npm install chartjs-plugin-deferred --save
```sh
npm install chartjs-plugin-deferred --save
```

## Bower

[![bower](https://img.shields.io/bower/v/chartjs-plugin-deferred.svg?style=flat-square&maxAge=600)](https://libraries.io/bower/chartjs-plugin-deferred)

bower install chartjs-plugin-deferred --save
```sh
bower install chartjs-plugin-deferred --save
```

## CDN

[![jsdelivr](https://img.shields.io/npm/v/chartjs-plugin-deferred.svg?label=jsdelivr&style=flat-square&maxAge=600)](https://cdn.jsdelivr.net/npm/chartjs-plugin-deferred@latest/dist/) [![jsdelivr hits](https://data.jsdelivr.com/v1/package/npm/chartjs-plugin-deferred/badge)](https://www.jsdelivr.com/package/npm/chartjs-plugin-deferred)

By default, `https://cdn.jsdelivr.net/npm/chartjs-plugin-deferred` returns the latest (minified) version, however it's [**highly recommended**](https://www.jsdelivr.com/features) to always specify a version in order to avoid breaking changes. This can be achieved by appending `@{version}` to the url:

https://cdn.jsdelivr.net/npm/[email protected] // exact version
https://cdn.jsdelivr.net/npm/chartjs-plugin-deferred@1 // latest 1.x.x
```sh
https://cdn.jsdelivr.net/npm/[email protected] // exact version
https://cdn.jsdelivr.net/npm/chartjs-plugin-deferred@1 // latest 1.x.x
```

Read more about jsDeliver versioning on their [website](http://www.jsdelivr.com/).

Expand Down
18 changes: 9 additions & 9 deletions docs/scripts/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {defaults, helpers} from 'chart.js';
const {merge} = helpers;

merge(defaults.global, {
legend: {
display: false
},
title: {
display: false
},
tooltips: {
enabled: false
}
legend: {
display: false
},
title: {
display: false
},
tooltips: {
enabled: false
}
});
130 changes: 65 additions & 65 deletions docs/scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
function fallback(/* values ... */) {
var ilen = arguments.length;
var i = 0;
var v;
var ilen = arguments.length;
var i = 0;
var v;

for (; i < ilen; ++i) {
v = arguments[i];
if (v !== undefined) {
return v;
}
}
for (; i < ilen; ++i) {
v = arguments[i];
if (v !== undefined) {
return v;
}
}
}

export var COLORS = [
'#FF3784',
'#36A2EB',
'#4BC0C0',
'#F77825',
'#9966FF',
'#00A8C6',
'#379F7A',
'#CC2738',
'#8B628A',
'#8FBE00',
'#606060',
'#FF3784',
'#36A2EB',
'#4BC0C0',
'#F77825',
'#9966FF',
'#00A8C6',
'#379F7A',
'#CC2738',
'#8B628A',
'#8FBE00',
'#606060',
];

// Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
var _seed = Date.now();

export function srand(seed) {
_seed = seed;
_seed = seed;
}

export function rand(min, max) {
min = min === undefined ? 0 : min;
max = max === undefined ? 1 : max;
_seed = (_seed * 9301 + 49297) % 233280;
return min + (_seed / 233280) * (max - min);
min = min === undefined ? 0 : min;
max = max === undefined ? 1 : max;
_seed = (_seed * 9301 + 49297) % 233280;
return min + (_seed / 233280) * (max - min);
}

export function numbers(config) {
var cfg = config || {};
var min = fallback(cfg.min, 0);
var max = fallback(cfg.max, 1);
var from = fallback(cfg.from, []);
var count = fallback(cfg.count, 8);
var decimals = fallback(cfg.decimals, 8);
var continuity = fallback(cfg.continuity, 1);
var dfactor = Math.pow(10, decimals) || 0;
var data = [];
var i, value;
var cfg = config || {};
var min = fallback(cfg.min, 0);
var max = fallback(cfg.max, 1);
var from = fallback(cfg.from, []);
var count = fallback(cfg.count, 8);
var decimals = fallback(cfg.decimals, 8);
var continuity = fallback(cfg.continuity, 1);
var dfactor = Math.pow(10, decimals) || 0;
var data = [];
var i, value;

for (i = 0; i < count; ++i) {
value = (from[i] || 0) + rand(min, max);
if (rand() <= continuity) {
data.push(Math.round(dfactor * value) / dfactor);
} else {
data.push(null);
}
}
for (i = 0; i < count; ++i) {
value = (from[i] || 0) + rand(min, max);
if (rand() <= continuity) {
data.push(Math.round(dfactor * value) / dfactor);
} else {
data.push(null);
}
}

return data;
return data;
}

export function color(offset) {
var count = COLORS.length;
var index = offset === undefined ? ~~rand(0, count) : offset;
return COLORS[index % count];
var count = COLORS.length;
var index = offset === undefined ? ~~rand(0, count) : offset;
return COLORS[index % count];
}

export function generate() {
return {
labels: [0, 1, 2, 3, 4, 5, 6, 7],
datasets: [{
backgroundColor: color(0),
data: numbers({
count: 8,
max: 0,
min: -100
}),
}, {
backgroundColor: color(1),
data: numbers({
count: 8,
max: 100,
min: 0
}),
}],
};
return {
labels: [0, 1, 2, 3, 4, 5, 6, 7],
datasets: [{
backgroundColor: color(0),
data: numbers({
count: 8,
max: 0,
min: -100
}),
}, {
backgroundColor: color(1),
data: numbers({
count: 8,
max: 100,
min: 0
}),
}],
};
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"archiver": "^5.3.0",
"chart.js": "^2.9.4",
"eslint": "^7.23.0",
"eslint-config-chartjs": "^0.1.0",
"eslint-config-chartjs": "^0.3.0",
"rollup": "^2.44.0",
"rollup-plugin-terser": "^7.0.2",
"vuepress": "^1.8.2",
Expand Down
Loading

0 comments on commit 86f299f

Please sign in to comment.