Skip to content

Commit 8d2611a

Browse files
committed
tune readme
1 parent e892f7d commit 8d2611a

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Chart.js Venn and Euler Diagram Chart
1+
# Chart.js Word Clouds
22

33
[![NPM Package][npm-image]][npm-url] [![Github Actions][github-actions-image]][github-actions-url]
44

@@ -28,11 +28,13 @@ or at this [![Open in CodePen][codepen]](https://codepen.io/sgratzl/pen/TODO)
2828
const config = {
2929
type: 'wordCloud',
3030
data: {
31-
labels: [],
31+
// text
32+
labels: ['Hello', 'world', 'normally', 'you', 'want', 'more', 'words', 'than', 'this'],
3233
datasets: [
3334
{
34-
label: 'A',
35-
data: [],
35+
label: 'DS',
36+
// size in pixel
37+
data: [90, 80, 70, 60, 50, 40, 30, 20, 10],
3638
},
3739
],
3840
},

src/controllers/WordCloudController.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('venn', () => {
1616
datasets: [
1717
{
1818
label: '',
19-
data: words.map(() => 10 + Math.random() * 90),
19+
data: words.map((_, i) => 10 + (i / words.length) * 90),
2020
},
2121
],
2222
};

src/controllers/WordCloudController.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ export interface IWordCloudControllerDatasetOptions
185185
extends IControllerDatasetOptions,
186186
ScriptableAndArrayOptions<IWordElementOptions>,
187187
ScriptableAndArrayOptions<ICommonHoverOptions> {
188+
/**
189+
* whether to fit the word cloud to the map, by scaling to the actual bounds
190+
* @default true
191+
*/
188192
fit: boolean;
189193
}
190194

Binary file not shown.

src/elements/WordElement.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
11
import { Element, IFontSpec, IVisualElement, ScriptableAndArrayOptions, toFont } from '@sgratzl/chartjs-esm-facade';
22

33
export interface IWordElementOptions extends IFontSpec {
4+
/**
5+
* rotation of the word
6+
* @default undefined then it will be randomly derived given the other constraints
7+
*/
48
rotate: number;
9+
/**
10+
* number of rotation steps between min and max rotation
11+
* @default 2
12+
*/
513
rotationSteps: number;
14+
/**
15+
* angle in degree for the min rotation
16+
* @default -90
17+
*/
618
minRotation: number;
19+
/**
20+
* angle in degree for the max rotation
21+
* @default 0
22+
*/
723
maxRotation: number;
24+
/**
25+
* padding around each word while doing the layout
26+
* @default 1
27+
*/
828
padding: number;
929
}
1030

1131
export interface IWordElementHoverOptions {
1232
hoverColor: string;
33+
hoverSize: number;
34+
hoverStyle: string;
35+
hoverWeight: string;
1336
}
1437

1538
export interface IWordElementProps {
@@ -34,7 +57,7 @@ export class WordElement extends Element<IWordElementProps, IWordElementOptions>
3457
const v = ctx.dataPoint.y;
3558
return v;
3659
},
37-
hoverWeight: '500',
60+
hoverColor: '#ababab',
3861
} as Partial<ScriptableAndArrayOptions<IWordElementOptions>>;
3962

4063
static readonly defaultRoutes = {

0 commit comments

Comments
 (0)