-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use latest Chart.js ESLint config (tab -> space)
- Loading branch information
1 parent
3589a49
commit 86f299f
Showing
13 changed files
with
360 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
] | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}), | ||
}], | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.