Skip to content

Commit 388c338

Browse files
authored
Merge pull request #19 from sgratzl/release/v3.7.1
Release v3.7.1
2 parents 7f37572 + 851f746 commit 388c338

File tree

10 files changed

+95
-7
lines changed

10 files changed

+95
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- run: yarn build
2626
- run: yarn lint
2727
- run: yarn test
28+
- run: yarn samples
2829
- uses: actions/upload-artifact@v2
2930
if: failure()
3031
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ npm-debug.log*
2121
/.vscode/extensions.json
2222
/docs
2323
*.tsbuildinfo
24-
__diff_output__
24+
__diff_output__
25+
26+
/samples/type_test.js

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
/.vscode
1313
*.png
1414
*.tgz
15-
*.tsbuildinfo
15+
*.tsbuildinfo
16+
/samples/type_test.js

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ The ESM build of the library supports tree shaking thus having no side effects.
8383
Variant A:
8484

8585
```js
86-
import Chart, { LinearScale, CategoryScale } from 'chart.js';
86+
import { Chart, LinearScale, CategoryScale } from 'chart.js';
8787
import { BoxPlotController, BoxAndWiskers } from '@sgratzl/chartjs-chart-boxplot';
8888

8989
// register controller in chart.js and ensure the defaults are set
9090
Chart.register(BoxPlotController, BoxAndWiskers, LinearScale, CategoryScale);
9191
...
9292

9393
new Chart(ctx, {
94-
type: BoxPlotController.id,
94+
type: 'boxplot',
9595
data: [...],
9696
});
9797
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sgratzl/chartjs-chart-boxplot",
33
"description": "Chart.js module for charting boxplots and violin charts",
4-
"version": "3.7.0",
4+
"version": "3.7.1",
55
"publishConfig": {
66
"access": "public"
77
},
@@ -106,6 +106,7 @@
106106
"test": "jest --passWithNoTests",
107107
"test:watch": "jest --passWithNoTests --watch",
108108
"test:coverage": "jest --passWithNoTests --coverage",
109+
"samples": "yarn tsc samples/type_test.ts",
109110
"lint": "yarn run eslint && yarn run prettier",
110111
"fix": "yarn run eslint:fix && yarn run prettier:write",
111112
"prettier:write": "prettier \"*\" \"*/**\" --write",

samples/type_test.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { Chart, LinearScale, CategoryScale } from 'chart.js';
2+
import { BoxPlotController, BoxAndWiskers, Violin, ViolinController } from '../build';
3+
4+
// register controller in chart.js and ensure the defaults are set
5+
Chart.register(BoxPlotController, BoxAndWiskers, Violin, ViolinController, LinearScale, CategoryScale);
6+
7+
const ctx = document.querySelector('canvas').getContext('2d');
8+
9+
const myBar = new Chart(ctx, {
10+
type: 'boxplot',
11+
data: {
12+
labels: ['vs'],
13+
datasets: [
14+
{
15+
label: 'Dataset 1',
16+
outlierRadius: 10,
17+
data: [
18+
[1, 2, 3, 4, 5],
19+
{
20+
min: 1,
21+
q1: 2,
22+
median: 3,
23+
q3: 4,
24+
max: 5,
25+
},
26+
],
27+
},
28+
],
29+
},
30+
options: {
31+
elements: {
32+
boxplot: {
33+
outlierRadius: 10,
34+
},
35+
},
36+
},
37+
});
38+
39+
const myViolin = new Chart(ctx, {
40+
type: 'violin',
41+
data: {
42+
labels: ['vs'],
43+
datasets: [
44+
{
45+
label: 'Dataset 1',
46+
outlierRadius: 10,
47+
data: [
48+
[1, 2, 3, 4, 5],
49+
{
50+
min: 1,
51+
q1: 2,
52+
median: 3,
53+
q3: 4,
54+
max: 5,
55+
},
56+
],
57+
},
58+
],
59+
},
60+
options: {
61+
elements: {
62+
violin: {
63+
outlierRadius: 10,
64+
},
65+
},
66+
},
67+
});

src/controllers/BoxPlotController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
ChartConfiguration,
99
LinearScale,
1010
CategoryScale,
11+
AnimationOptions,
1112
} from 'chart.js';
1213
import { merge } from 'chart.js/helpers';
1314
import { asBoxPlotStats, IBaseStats, IBoxPlot, IBoxplotOptions } from '../data';
@@ -57,7 +58,8 @@ export interface BoxPlotControllerDatasetOptions
5758
extends ControllerDatasetOptions,
5859
IBoxplotOptions,
5960
ScriptableAndArrayOptions<IBoxAndWhiskersOptions, 'boxplot'>,
60-
ScriptableAndArrayOptions<CommonHoverOptions, 'boxplot'> {}
61+
ScriptableAndArrayOptions<CommonHoverOptions, 'boxplot'>,
62+
AnimationOptions<'boxplot'> {}
6163

6264
export type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & IBaseStats);
6365

src/controllers/ViolinController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
ChartConfiguration,
99
LinearScale,
1010
CategoryScale,
11+
AnimationOptions,
1112
} from 'chart.js';
1213
import { merge } from 'chart.js/helpers';
1314
import { asViolinStats, IBaseStats, IViolin, IViolinOptions } from '../data';
@@ -66,7 +67,8 @@ export interface ViolinControllerDatasetOptions
6667
extends ControllerDatasetOptions,
6768
IViolinOptions,
6869
ScriptableAndArrayOptions<IViolinElementOptions, 'violin'>,
69-
ScriptableAndArrayOptions<CommonHoverOptions, 'violin'> {}
70+
ScriptableAndArrayOptions<CommonHoverOptions, 'violin'>,
71+
AnimationOptions<'violin'> {}
7072

7173
// eslint-disable-next-line @typescript-eslint/no-empty-interface
7274
export interface IViolinChartOptions {}

src/elements/BoxAndWiskers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,9 @@ export class BoxAndWiskers extends StatsBase<IBoxAndWhiskerProps, IBoxAndWhisker
226226

227227
static defaultRoutes = /* #__PURE__ */ { ...BarElement.defaultRoutes, ...baseRoutes };
228228
}
229+
230+
declare module 'chart.js' {
231+
export interface ElementOptionsByType<TType extends ChartType> {
232+
boxplot: ScriptableAndArrayOptions<IBoxAndWhiskersOptions & CommonHoverOptions, ScriptableContext<TType>>;
233+
}
234+
}

src/elements/Violin.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,9 @@ export class Violin extends StatsBase<IViolinElementProps, IViolinElementOptions
108108

109109
static defaultRoutes = /* #__PURE__ */ { ...BarElement.defaultRoutes, ...baseRoutes };
110110
}
111+
112+
declare module 'chart.js' {
113+
export interface ElementOptionsByType<TType extends ChartType> {
114+
violin: ScriptableAndArrayOptions<IViolinElementOptions & CommonHoverOptions, ScriptableContext<TType>>;
115+
}
116+
}

0 commit comments

Comments
 (0)