Skip to content

Commit

Permalink
Merge pull request #19 from sgratzl/release/v3.7.1
Browse files Browse the repository at this point in the history
Release v3.7.1
  • Loading branch information
sgratzl authored Feb 21, 2022
2 parents 7f37572 + 851f746 commit 388c338
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- run: yarn build
- run: yarn lint
- run: yarn test
- run: yarn samples
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ npm-debug.log*
/.vscode/extensions.json
/docs
*.tsbuildinfo
__diff_output__
__diff_output__

/samples/type_test.js
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
/.vscode
*.png
*.tgz
*.tsbuildinfo
*.tsbuildinfo
/samples/type_test.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ The ESM build of the library supports tree shaking thus having no side effects.
Variant A:

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

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

new Chart(ctx, {
type: BoxPlotController.id,
type: 'boxplot',
data: [...],
});
```
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sgratzl/chartjs-chart-boxplot",
"description": "Chart.js module for charting boxplots and violin charts",
"version": "3.7.0",
"version": "3.7.1",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -106,6 +106,7 @@
"test": "jest --passWithNoTests",
"test:watch": "jest --passWithNoTests --watch",
"test:coverage": "jest --passWithNoTests --coverage",
"samples": "yarn tsc samples/type_test.ts",
"lint": "yarn run eslint && yarn run prettier",
"fix": "yarn run eslint:fix && yarn run prettier:write",
"prettier:write": "prettier \"*\" \"*/**\" --write",
Expand Down
67 changes: 67 additions & 0 deletions samples/type_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Chart, LinearScale, CategoryScale } from 'chart.js';
import { BoxPlotController, BoxAndWiskers, Violin, ViolinController } from '../build';

// register controller in chart.js and ensure the defaults are set
Chart.register(BoxPlotController, BoxAndWiskers, Violin, ViolinController, LinearScale, CategoryScale);

const ctx = document.querySelector('canvas').getContext('2d');

const myBar = new Chart(ctx, {
type: 'boxplot',
data: {
labels: ['vs'],
datasets: [
{
label: 'Dataset 1',
outlierRadius: 10,
data: [
[1, 2, 3, 4, 5],
{
min: 1,
q1: 2,
median: 3,
q3: 4,
max: 5,
},
],
},
],
},
options: {
elements: {
boxplot: {
outlierRadius: 10,
},
},
},
});

const myViolin = new Chart(ctx, {
type: 'violin',
data: {
labels: ['vs'],
datasets: [
{
label: 'Dataset 1',
outlierRadius: 10,
data: [
[1, 2, 3, 4, 5],
{
min: 1,
q1: 2,
median: 3,
q3: 4,
max: 5,
},
],
},
],
},
options: {
elements: {
violin: {
outlierRadius: 10,
},
},
},
});
4 changes: 3 additions & 1 deletion src/controllers/BoxPlotController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ChartConfiguration,
LinearScale,
CategoryScale,
AnimationOptions,
} from 'chart.js';
import { merge } from 'chart.js/helpers';
import { asBoxPlotStats, IBaseStats, IBoxPlot, IBoxplotOptions } from '../data';
Expand Down Expand Up @@ -57,7 +58,8 @@ export interface BoxPlotControllerDatasetOptions
extends ControllerDatasetOptions,
IBoxplotOptions,
ScriptableAndArrayOptions<IBoxAndWhiskersOptions, 'boxplot'>,
ScriptableAndArrayOptions<CommonHoverOptions, 'boxplot'> {}
ScriptableAndArrayOptions<CommonHoverOptions, 'boxplot'>,
AnimationOptions<'boxplot'> {}

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

Expand Down
4 changes: 3 additions & 1 deletion src/controllers/ViolinController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ChartConfiguration,
LinearScale,
CategoryScale,
AnimationOptions,
} from 'chart.js';
import { merge } from 'chart.js/helpers';
import { asViolinStats, IBaseStats, IViolin, IViolinOptions } from '../data';
Expand Down Expand Up @@ -66,7 +67,8 @@ export interface ViolinControllerDatasetOptions
extends ControllerDatasetOptions,
IViolinOptions,
ScriptableAndArrayOptions<IViolinElementOptions, 'violin'>,
ScriptableAndArrayOptions<CommonHoverOptions, 'violin'> {}
ScriptableAndArrayOptions<CommonHoverOptions, 'violin'>,
AnimationOptions<'violin'> {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IViolinChartOptions {}
Expand Down
6 changes: 6 additions & 0 deletions src/elements/BoxAndWiskers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,9 @@ export class BoxAndWiskers extends StatsBase<IBoxAndWhiskerProps, IBoxAndWhisker

static defaultRoutes = /* #__PURE__ */ { ...BarElement.defaultRoutes, ...baseRoutes };
}

declare module 'chart.js' {
export interface ElementOptionsByType<TType extends ChartType> {
boxplot: ScriptableAndArrayOptions<IBoxAndWhiskersOptions & CommonHoverOptions, ScriptableContext<TType>>;
}
}
6 changes: 6 additions & 0 deletions src/elements/Violin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ export class Violin extends StatsBase<IViolinElementProps, IViolinElementOptions

static defaultRoutes = /* #__PURE__ */ { ...BarElement.defaultRoutes, ...baseRoutes };
}

declare module 'chart.js' {
export interface ElementOptionsByType<TType extends ChartType> {
violin: ScriptableAndArrayOptions<IViolinElementOptions & CommonHoverOptions, ScriptableContext<TType>>;
}
}

0 comments on commit 388c338

Please sign in to comment.