Skip to content

Commit da32dc3

Browse files
committed
Migrate to Chart.js 3.x
1 parent b53ec16 commit da32dc3

25 files changed

+3133
-3211
lines changed

.eslintrc.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
extends: chartjs
22

3-
parserOptions:
4-
sourceType: module
5-
63
env:
4+
es6: true
75
browser: true
86
node: true
7+
8+
parserOptions:
9+
ecmaVersion: 2018
10+
sourceType: module
11+
ecmaFeatures:
12+
impliedStrict: true
13+
modules: true
14+
15+
rules:
16+
class-methods-use-this: "off"
17+
complexity: ["warn", 10]
18+
max-statements: ["warn", 30]
19+
no-empty-function: "off"
20+
no-use-before-define: ["error", { "functions": false }]

gulpfile.js

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,92 +12,92 @@ var {exec} = require('child_process');
1212
var pkg = require('./package.json');
1313

1414
var argv = require('yargs')
15-
.option('output', {alias: 'o', default: 'dist'})
16-
.option('samples-dir', {default: 'samples'})
17-
.option('docs-dir', {default: 'docs'})
18-
.argv;
15+
.option('output', {alias: 'o', default: 'dist'})
16+
.option('samples-dir', {default: 'samples'})
17+
.option('docs-dir', {default: 'docs'})
18+
.argv;
1919

2020
function run(bin, args) {
21-
return new Promise((resolve, reject) => {
22-
var exe = '"' + process.execPath + '"';
23-
var src = require.resolve(bin);
24-
var ps = exec([exe, src].concat(args || []).join(' '));
21+
return new Promise((resolve, reject) => {
22+
var exe = '"' + process.execPath + '"';
23+
var src = require.resolve(bin);
24+
var ps = exec([exe, src].concat(args || []).join(' '));
2525

26-
ps.stdout.pipe(process.stdout);
27-
ps.stderr.pipe(process.stderr);
28-
ps.on('close', (error) => {
29-
if (error) {
30-
reject(error);
31-
} else {
32-
resolve();
33-
}
34-
});
35-
});
26+
ps.stdout.pipe(process.stdout);
27+
ps.stderr.pipe(process.stderr);
28+
ps.on('close', (error) => {
29+
if (error) {
30+
reject(error);
31+
} else {
32+
resolve();
33+
}
34+
});
35+
});
3636
}
3737

3838
gulp.task('build', function() {
39-
return run('rollup/bin/rollup', ['-c', argv.watch ? '--watch' : '']);
39+
return run('rollup/dist/bin/rollup', ['-c', argv.watch ? '--watch' : '']);
4040
});
4141

4242
gulp.task('lint', function() {
43-
var files = [
44-
'src/**/*.js',
45-
'*.js'
46-
];
43+
var files = [
44+
'src/**/*.js',
45+
'*.js'
46+
];
4747

48-
var options = {
49-
rules: {
50-
complexity: [1, 10],
51-
'max-statements': [1, 30]
52-
}
53-
};
48+
var options = {
49+
rules: {
50+
complexity: [1, 10],
51+
'max-statements': [1, 30]
52+
}
53+
};
5454

55-
return gulp.src(files)
56-
.pipe(eslint(options))
57-
.pipe(eslint.format())
58-
.pipe(eslint.failAfterError());
55+
return gulp.src(files)
56+
.pipe(eslint(options))
57+
.pipe(eslint.format())
58+
.pipe(eslint.failAfterError());
5959
});
6060

6161
gulp.task('samples', function() {
62-
// since we moved the dist files one folder up (package root), we need to rewrite
63-
// samples src="../dist/ to src="../ and then copy them in the /samples directory.
64-
var out = path.join(argv.output, argv.samplesDir);
65-
return gulp.src('samples/**/*', {base: 'samples'})
66-
.pipe(streamify(replace(/src="((?:\.\.\/)+)dist\//g, 'src="$1', {skipBinary: true})))
67-
.pipe(gulp.dest(out));
62+
// since we moved the dist files one folder up (package root), we need to rewrite
63+
// samples src="../dist/ to src="../ and then copy them in the /samples directory.
64+
var out = path.join(argv.output, argv.samplesDir);
65+
return gulp.src('samples/**/*', {base: 'samples'})
66+
.pipe(streamify(replace(/src="((?:\.\.\/)+)dist\//g, 'src="$1', {skipBinary: true})))
67+
.pipe(gulp.dest(out));
6868
});
6969

7070
gulp.task('package', gulp.series(gulp.parallel('build', 'samples'), function() {
71-
var out = argv.output;
72-
var streams = merge(
73-
gulp.src(path.join(out, argv.samplesDir, '**/*'), {base: out}),
74-
gulp.src([path.join(out, '*.js'), 'LICENSE.md'])
75-
);
71+
var out = argv.output;
72+
var streams = merge(
73+
gulp.src(path.join(out, argv.samplesDir, '**/*'), {base: out}),
74+
gulp.src([path.join(out, '*.js'), 'LICENSE.md'])
75+
);
7676

77-
return streams
78-
.pipe(zip(pkg.name + '.zip'))
79-
.pipe(gulp.dest(out));
77+
return streams
78+
.pipe(zip(pkg.name + '.zip'))
79+
.pipe(gulp.dest(out));
8080
}));
8181

8282
gulp.task('bower', function() {
83-
var json = JSON.stringify({
84-
name: pkg.name,
85-
description: pkg.description,
86-
homepage: pkg.homepage,
87-
license: pkg.license,
88-
version: pkg.version,
89-
main: argv.output + '/' + pkg.name + '.js',
90-
ignore: [
91-
'.codeclimate.yml',
92-
'.gitignore',
93-
'.npmignore',
94-
'.travis.yml',
95-
'scripts'
96-
]
97-
}, null, 2);
83+
var json = JSON.stringify({
84+
name: pkg.name,
85+
description: pkg.description,
86+
homepage: pkg.homepage,
87+
license: pkg.license,
88+
version: pkg.version,
89+
main: argv.output + '/' + pkg.name + '.js',
90+
ignore: [
91+
'.codeclimate.yml',
92+
'.gitignore',
93+
'.npmignore',
94+
'.travis.yml',
95+
'scripts'
96+
]
97+
}, null, 2);
9898

99-
return file('bower.json', json, {src: true})
100-
.pipe(gulp.dest('./'));
99+
return file('bower.json', json, {src: true})
100+
.pipe(gulp.dest('./'));
101101
});
102102

103103
gulp.task('default', gulp.parallel('build'));

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"homepage": "https://nagix.github.io/chartjs-plugin-streaming",
44
"description": "Chart.js plugin for live streaming data",
55
"author": "Akihiko Kusanagi <nagi@nagi-p.com> (https://nagix.github.io/)",
6-
"version": "1.8.0",
6+
"version": "2.0.0-beta.1",
77
"license": "MIT",
88
"jsdelivr": "dist/chartjs-plugin-streaming.min.js",
99
"unpkg": "dist/chartjs-plugin-streaming.min.js",
@@ -31,24 +31,23 @@
3131
"test": "test"
3232
},
3333
"devDependencies": {
34-
"chart.js": "~2.8.0",
35-
"eslint-config-chartjs": "^0.1.0",
34+
"@rollup/plugin-commonjs": "^18.0.0",
35+
"@rollup/plugin-node-resolve": "^11.2.1",
36+
"chart.js": "^3.0.0",
37+
"eslint-config-chartjs": "^0.3.0",
3638
"gulp": "^4.0.0",
3739
"gulp-eslint": "^5.0.0",
3840
"gulp-file": "^0.4.0",
3941
"gulp-replace": "^1.0.0",
4042
"gulp-streamify": "^1.0.2",
4143
"gulp-zip": "^4.2.0",
4244
"merge2": "^1.2.3",
43-
"rollup": "^1.6.0",
44-
"rollup-plugin-commonjs": "^9.2.1",
45-
"rollup-plugin-istanbul": "^2.0.1",
46-
"rollup-plugin-node-resolve": "^4.0.1",
47-
"rollup-plugin-terser": "^4.0.4",
48-
"yargs": "^13.2.2"
45+
"rollup": "^2.45.1",
46+
"rollup-plugin-istanbul": "^3.0.0",
47+
"rollup-plugin-terser": "^7.0.2",
48+
"yargs": "^16.2.0"
4949
},
5050
"peerDependencies": {
51-
"chart.js": ">= 2.7.0 < 3",
52-
"moment": "^2.10.2"
51+
"chart.js": "^3.0.0"
5352
}
5453
}

rollup.config.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,46 @@ const banner = `/*!
99
*/`;
1010

1111
module.exports = [
12-
{
13-
input: 'src/index.js',
14-
output: {
15-
name: 'ChartStreaming',
16-
file: `dist/${pkg.name}.js`,
17-
banner: banner,
18-
format: 'umd',
19-
indent: false,
20-
globals: {
21-
moment: 'moment',
22-
'chart.js': 'Chart'
23-
}
24-
},
25-
external: [
26-
'moment',
27-
'chart.js',
28-
]
29-
},
30-
{
31-
input: 'src/index.js',
32-
output: {
33-
name: 'ChartStreaming',
34-
file: `dist/${pkg.name}.min.js`,
35-
format: 'umd',
36-
indent: false,
37-
globals: {
38-
moment: 'moment',
39-
'chart.js': 'Chart'
40-
}
41-
},
42-
plugins: [
43-
terser({
44-
output: {
45-
preamble: banner
46-
}
47-
})
48-
],
49-
external: [
50-
'moment',
51-
'chart.js'
52-
]
53-
}
12+
{
13+
input: 'src/index.js',
14+
output: {
15+
name: 'ChartStreaming',
16+
file: `dist/${pkg.name}.js`,
17+
banner: banner,
18+
format: 'umd',
19+
indent: false,
20+
globals: {
21+
'chart.js': 'Chart',
22+
'chart.js/helpers': 'Chart.helpers'
23+
}
24+
},
25+
external: [
26+
'chart.js',
27+
'chart.js/helpers'
28+
]
29+
},
30+
{
31+
input: 'src/index.js',
32+
output: {
33+
name: 'ChartStreaming',
34+
file: `dist/${pkg.name}.min.js`,
35+
format: 'umd',
36+
indent: false,
37+
globals: {
38+
'chart.js': 'Chart',
39+
'chart.js/helpers': 'Chart.helpers'
40+
}
41+
},
42+
plugins: [
43+
terser({
44+
output: {
45+
preamble: banner
46+
}
47+
})
48+
],
49+
external: [
50+
'chart.js',
51+
'chart.js/helpers'
52+
]
53+
}
5454
];

0 commit comments

Comments
 (0)