Skip to content

Commit

Permalink
Merge pull request #77 from sgratzl/release/v4.4.0
Browse files Browse the repository at this point in the history
Release v4.4.0
  • Loading branch information
sgratzl committed Mar 14, 2024
2 parents a8725a3 + 4bf939c commit b975f5d
Show file tree
Hide file tree
Showing 12 changed files with 2,400 additions and 2,148 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i -g yarn
- run: yarn config set checksumBehavior ignore
- name: Cache Node.js modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
./.yarn/cache
Expand All @@ -27,7 +27,7 @@ jobs:
- run: yarn build
- run: yarn lint
- run: yarn test
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: failure()
with:
name: diff outputs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/deploy_website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm i -g yarn
- run: yarn config set checksumBehavior ignore
- name: Cache Node.js modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
./.yarn/cache
Expand All @@ -34,10 +34,10 @@ jobs:
${{ runner.os }}-yarn2-v5
- run: yarn install
- run: yarn docs:build
- uses: actions/configure-pages@v2
- uses: actions/upload-pages-artifact@v1
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
- name: Deploy
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
12 changes: 6 additions & 6 deletions .github/workflows/release_helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Extract version
Expand Down Expand Up @@ -51,14 +51,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i -g yarn
- run: yarn config set checksumBehavior ignore
- name: Cache Node.js modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
./.yarn/cache
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: dev
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
Expand Down
672 changes: 336 additions & 336 deletions .yarn/releases/yarn-4.0.2.cjs → .yarn/releases/yarn-4.1.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ packageExtensions:
dependencies:
eslint-import-resolver-node: "*"

yarnPath: .yarn/releases/yarn-4.0.2.cjs
yarnPath: .yarn/releases/yarn-4.1.1.cjs
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chartjs-chart-wordcloud",
"description": "Chart.js module for word clouds",
"version": "4.3.3",
"version": "4.4.0",
"author": {
"name": "Samuel Gratzl",
"email": "[email protected]",
Expand Down Expand Up @@ -58,46 +58,46 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.12",
"@types/jest-image-snapshot": "^6.4.0",
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@types/node": "^20.11.27",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@yarnpkg/sdks": "^3.1.0",
"canvas": "^2.11.2",
"canvas-5-polyfill": "^0.1.5",
"chart.js": "^4.4.1",
"eslint": "^8.56.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"chart.js": "^4.4.2",
"eslint": "^8.57.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-image-snapshot": "^6.4.0",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"rollup": "^4.13.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.0",
"ts-jest": "^29.1.1",
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"typedoc": "^0.25.7",
"typedoc": "^0.25.12",
"typedoc-plugin-markdown": "^4.0.0-next.16",
"typedoc-vitepress-theme": "^1.0.0-next.7",
"typescript": "^5.3.3",
"vitepress": "^1.0.0-rc.39",
"vue": "^3.4.15",
"typedoc-vitepress-theme": "^1.0.0-next.9",
"typescript": "^5.4.2",
"vitepress": "^1.0.0-rc.45",
"vue": "^3.4.21",
"vue-chartjs": "^5.3.0"
},
"resolutions": {
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0"
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0"
},
"scripts": {
"clean": "rimraf --glob build node_modules \"*.tgz\" \"*.tsbuildinfo\"",
Expand All @@ -124,5 +124,5 @@
"@types/d3-cloud": "^1.2.9",
"d3-cloud": "^1.2.7"
},
"packageManager": "yarn@4.0.2"
"packageManager": "yarn@4.1.1"
}
50 changes: 42 additions & 8 deletions src/controllers/WordCloudController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
/**
* @hidden
*/
static readonly defaults = {
static readonly defaults = /* #__PURE__ */ {
datasets: {
fit: true,
animation: {
colors: {
properties: ['color', 'strokeStyle'],
Expand All @@ -57,7 +56,7 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
/**
* @hidden
*/
static readonly overrides = {
static readonly overrides = /* #__PURE__ */ {
scales: {
x: {
type: 'linear',
Expand Down Expand Up @@ -93,7 +92,8 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
*/
update(mode: UpdateMode): void {
super.update(mode);
this.rand = rnd(this.chart.id);
const dsOptions = (this as any).options as IWordCloudControllerDatasetOptions;
this.rand = rnd(dsOptions.randomRotationSeed ?? this.chart.id);
const meta = this._cachedMeta;

const elems = (meta.data || []) as unknown as WordElement[];
Expand All @@ -105,13 +105,21 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
*/
updateElements(elems: WordElement[], start: number, count: number, mode: UpdateMode): void {
this.wordLayout.stop();
const dsOptions = (this as any).options as IWordCloudControllerDatasetOptions;
const xScale = this._cachedMeta.xScale as { left: number; right: number };
const yScale = this._cachedMeta.yScale as { top: number; bottom: number };

const w = xScale.right - xScale.left;
const h = yScale.bottom - yScale.top;
const labels = this.chart.data.labels as string[];

const growOptions: IAutoGrowOptions = {
maxTries: 3,
scalingFactor: 1.2,
};
// update with configured options
Object.assign(growOptions, dsOptions?.autoGrow ?? {});

const words: (ICloudWord & Record<string, unknown>)[] = [];
for (let i = start; i < start + count; i += 1) {
const o = this.resolveDataElementOptions(i, mode) as unknown as IWordElementOptions;
Expand Down Expand Up @@ -139,14 +147,18 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
// syncish since no time limit is set
this.wordLayout.random(this.rand).words(words);

const run = (factor = 1, tries = 3): void => {
const run = (factor = 1, tries = growOptions.maxTries): void => {
this.wordLayout
.size([w * factor, h * factor])
.on('end', (tags, bounds) => {
if (tags.length < labels.length) {
if (tries > 0) {
// try again with a factor of 1.2
run(factor * 1.2, tries - 1);
const f =
typeof growOptions.scalingFactor === 'function'
? growOptions.scalingFactor(factor, tags, labels.length)
: factor * growOptions.scalingFactor;
run(f, tries - 1);
return;
}
// eslint-disable-next-line no-console
Expand All @@ -155,7 +167,6 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
const wb = bounds[1].x - bounds[0].x;
const hb = bounds[1].y - bounds[0].y;

const dsOptions = (this as any).options as IWordCloudControllerDatasetOptions;
const scale = dsOptions.fit ? Math.min(w / wb, h / hb) : 1;
const indices = new Set(labels.map((_, i) => i));
tags.forEach((tag) => {
Expand Down Expand Up @@ -203,16 +214,39 @@ export class WordCloudController extends DatasetController<'wordCloud', WordElem
}
}

export interface IAutoGrowOptions {
/**
* @default 3
*/
maxTries: number;
/**
* @default 1.2
*/
scalingFactor: number | ((currentFactor: number, fitted: ICloudWord[], total: number) => number);
}

export interface IWordCloudControllerDatasetOptions
extends ControllerDatasetOptions,
ScriptableAndArrayOptions<IWordElementOptions, ScriptableContext<'wordCloud'>>,
ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'wordCloud'>>,
AnimationOptions<'wordCloud'> {
/**
* whether to fit the word cloud to the map, by scaling to the actual bounds
* @default true
* @default false
*/
fit: boolean;

/**
* configures the automatic growing of the canvas in case not all words can be fitted onto the screen
* @default { maxTries: 3, scalingFactor: 1.2}
*/
autoGrow: IAutoGrowOptions;

/**
* specifies the random seed that should be used for randomly rotating words if needed
* @default the current chart id
*/
randomRotationSeed: string;
}

declare module 'chart.js' {
Expand Down
2 changes: 1 addition & 1 deletion src/elements/WordElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class WordElement extends Element<IWordElementProps, IWordElementOptions>
/**
* @hidden
*/
static readonly defaultRoutes = {
static readonly defaultRoutes = /* #__PURE__ */ {
color: 'color',
family: 'font.family',
style: 'font.style',
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"noEmit": true,
"paths": {
"@": ["./src"],
"*": ["*", "node_modules/*"],
},
"*": ["*", "node_modules/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "docs/**/*.tsx"],
"include": ["src/**/*.ts", "src/**/*.tsx", "docs/**/*.tsx"]
}
7 changes: 6 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
"$schema": "https://typedoc.org/schema.json",
"entryPoints": ["./src"],
"plugin": ["typedoc-plugin-markdown", "typedoc-vitepress-theme"],
"name": "chartjs-chart-boxplot",
"name": "chartjs-chart-wordcloud",
"out": "./docs/api",
"docsRoot": "./docs/",
"readme": "none",
"sidebar": {
"pretty": true
},
"theme": "default",
"excludeExternals": true,
"excludeInternal": true,
Expand Down
Loading

0 comments on commit b975f5d

Please sign in to comment.