Skip to content

Commit

Permalink
Migrate to Chart.js v3.0.0-beta.7 (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
santam85 authored Dec 9, 2020
1 parent 8572a7b commit ade8c87
Show file tree
Hide file tree
Showing 68 changed files with 471 additions and 507 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea
.vscode/
bower.json
cc-test-reporter
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ The [plugin options](options.md) can be changed at 3 different levels and are ev

- per dataset: `dataset.datalabels.*`
- per chart: `options.plugins.datalabels.*`
- or globally: `Chart.defaults.global.plugins.datalabels.*`
- or globally: `Chart.defaults.plugins.datalabels.*`

For example:

```javascript
// Change default options for ALL charts
Chart.helpers.merge(Chart.defaults.global.plugins.datalabels, {
Chart.defaults.set('plugins.datalabels', {
color: '#FE777B'
});

Expand Down
8 changes: 4 additions & 4 deletions docs/guide/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ The following table lists all available options:
| `borderWidth` | `number` | Yes | Yes | `0`
| [`clamp`](positioning.md#clamping) | `boolean` | Yes | Yes | `false`
| [`clip`](positioning.md#clipping) | `boolean` | Yes | Yes | `false`
| `color` | [`Style`](#style-options) | Yes | Yes | [`defaultFontColor`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `color` | [`Style`](#style-options) | Yes | Yes | [`color`](http://www.chartjs.org/docs/latest/general/fonts.html)
| [`display`](positioning.md#visibility) | `boolean` \| `string` | Yes | Yes | `true`
| `font` | `object` | Yes | Yes | -
| `font.family` | `string` | - | - | [`defaultFontFamily`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `font.size` | `string` | - | - | [`defaultFontSize`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `font.style` | `string` | - | - | [`defaultFontStyle`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `font.family` | `string` | - | - | [`font.family`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `font.size` | `string` | - | - | [`font.size`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `font.style` | `string` | - | - | [`font.style`](http://www.chartjs.org/docs/latest/general/fonts.html)
| `font.weight` | `string` | - | - | `'normal'`
| [`font.lineHeight`](formatting.md#multiline-labels) | `number` \| `string` | - | - | `1.2`
| [`formatter`](formatting.md#data-transformation) | `function` \| `null` | - | - | -
Expand Down
2 changes: 1 addition & 1 deletion karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(karma) {
files: [
{pattern: './test/fixtures/**/*.js', included: false},
{pattern: './test/fixtures/**/*.png', included: false},
'node_modules/chart.js/dist/Chart.js',
'node_modules/chart.js/dist/chart.js',
'test/index.js',
'src/plugin.js'
].concat(args.inputs),
Expand Down
52 changes: 4 additions & 48 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
"types/*.d.ts"
],
"devDependencies": {
"@types/chart.js": "^2.9.27",
"@vuepress/plugin-google-analytics": "^1.7.1",
"chart.js": "~2.8.0",
"chart.js": "^3.0.0-beta.7",
"eslint-config-chartjs": "^0.1.0",
"eslint-plugin-es": "^3.0.1",
"eslint-plugin-html": "^6.1.1",
Expand Down Expand Up @@ -53,6 +52,6 @@
"yargs": "^16.1.0"
},
"peerDependencies": {
"chart.js": ">= 2.7.0 < 3"
"chart.js": "^3.0.0-beta.7"
}
}
27 changes: 14 additions & 13 deletions samples/advanced/custom-labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../style.css">
<link rel="icon" type="image/ico" href="../favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.0.0-beta.7"></script>
<script src="../../dist/chartjs-plugin-datalabels.js"></script>
<script src="../utils.js"></script>
</head>
Expand Down Expand Up @@ -44,22 +44,25 @@

Samples.srand(0);

Chart.helpers.merge(Chart.defaults.global, {
Chart.defaults.set({
aspectRatio: 4 / 3,
tooltips: false,
layout: {
padding: {
top: 32
}
},
elements: {
line: {
fill: false
fill: false,
tension: 0.4
}
},
plugins: {
legend: false,
title: false
legend: {
display: false
},
title: false,
tooltip: false
}
});
</script>
Expand Down Expand Up @@ -98,15 +101,13 @@
}
},
scales: {
xAxes: [{
x: {
display: false,
offset: true
}],
yAxes: [{
ticks: {
beginAtZero: true
}
}]
},
y: {
beginAtZero: true
}
}
}
});
Expand Down
15 changes: 9 additions & 6 deletions samples/advanced/multiple-labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../style.css">
<link rel="icon" type="image/ico" href="../favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.7.0/dist/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.0.0-beta.7"></script>
<script src="../../dist/chartjs-plugin-datalabels.js"></script>
<script src="../utils.js"></script>
</head>
Expand Down Expand Up @@ -43,9 +43,8 @@

Samples.srand(4);

Chart.helpers.merge(Chart.defaults.global, {
Chart.defaults.set({
aspectRatio: 4 / 3,
tooltips: false,
layout: {
padding: {
top: 42,
Expand All @@ -56,16 +55,20 @@
},
elements: {
line: {
fill: false
fill: false,
tension: 0.4
},
point: {
hoverRadius: 7,
radius: 5
}
},
plugins: {
legend: false,
title: false
legend: {
display: false,
},
title: false,
tooltip: false
}
});
</script>
Expand Down
20 changes: 11 additions & 9 deletions samples/charts/bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../style.css">
<link rel="icon" type="image/ico" href="../favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.0.0-beta.7"></script>
<script src="../../dist/chartjs-plugin-datalabels.js"></script>
<script src="../utils.js"></script>
</head>
Expand Down Expand Up @@ -41,9 +41,8 @@
labels.push('' + i);
}

Chart.helpers.merge(Chart.defaults.global, {
Chart.defaults.set({
aspectRatio: 4 / 3,
tooltips: false,
layout: {
padding: {
top: 42,
Expand All @@ -62,8 +61,11 @@
}
},
plugins: {
legend: false,
title: false
legend: {
display: false
},
title: false,
tooltip: false
}
});
</script>
Expand Down Expand Up @@ -122,12 +124,12 @@
}
},
scales: {
xAxes: [{
x: {
stacked: true
}],
yAxes: [{
},
y: {
stacked: true
}]
}
}
}
});
Expand Down
12 changes: 7 additions & 5 deletions samples/charts/bubble.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../style.css">
<link rel="icon" type="image/ico" href="../favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.0.0-beta.7"></script>
<script src="../../dist/chartjs-plugin-datalabels.js"></script>
<script src="../utils.js"></script>
</head>
Expand Down Expand Up @@ -53,9 +53,8 @@
return data;
}

Chart.helpers.merge(Chart.defaults.global, {
Chart.defaults.set({
aspectRatio: 1,
tooltips: false,
layout: {
padding: {
top: 42,
Expand All @@ -75,8 +74,11 @@
}
},
plugins: {
legend: false,
title: false
legend: {
display: false
},
title: false,
tooltip: false
}
});
</script>
Expand Down
12 changes: 7 additions & 5 deletions samples/charts/doughnut.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../style.css">
<link rel="icon" type="image/ico" href="../favicon.ico">
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.0.0-beta.7"></script>
<script src="../../dist/chartjs-plugin-datalabels.js"></script>
<script src="../utils.js"></script>
</head>
Expand Down Expand Up @@ -41,9 +41,8 @@
labels.push('' + i);
}

Chart.helpers.merge(Chart.defaults.global, {
Chart.defaults.set({
maintainAspectRatio: false,
tooltips: false,
layout: {
padding: 32
},
Expand All @@ -57,8 +56,11 @@
}
},
plugins: {
legend: false,
title: false
legend: {
display: false,
},
title: false,
tooltip: false
}
});
</script>
Expand Down
Loading

0 comments on commit ade8c87

Please sign in to comment.