You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+149-86
Original file line number
Diff line number
Diff line change
@@ -27,57 +27,71 @@ four new types: `boxplot`, `horizontalBoxplot`, `violin`, and `horizontalViolin`
27
27
28
28
## Config
29
29
30
-
// TODO
30
+
The config can be done on a per dataset `.data.datasets[0].minStats` or for all datasets under the controllers name. e.g., `.options.boxplot.datasets.minStats`.
31
+
32
+
```ts
33
+
interfaceIBaseOptions {
34
+
/**
35
+
* statistic measure that should be used for computing the minimal data limit
36
+
* @default'min'
37
+
*/
38
+
minStats:'min'|'q1'|'whiskerMin';
39
+
40
+
/**
41
+
* statistic measure that should be used for computing the maximal data limit
42
+
* @default'max'
43
+
*/
44
+
maxStats:'max'|'q3'|'whiskerMax';
45
+
46
+
/**
47
+
* from the R doc: this determines how far the plot ‘whiskers’ extend out from
48
+
* the box. If coef is positive, the whiskers extend to the most extreme data
49
+
* point which is no more than coef times the length of the box away from the
50
+
* box. A value of zero causes the whiskers to extend to the data extremes
51
+
* @default1.5
52
+
*/
53
+
coef:number;
54
+
55
+
/**
56
+
* the method to compute the quantiles.
57
+
*
58
+
* 7, 'quantiles': the type-7 method as used by R 'quantiles' method.
59
+
* 'hinges' and 'fivenum': the method used by R 'boxplot.stats' method.
60
+
* 'linear': the interpolation method 'linear' as used by 'numpy.percentile' function
61
+
* 'lower': the interpolation method 'lower' as used by 'numpy.percentile' function
62
+
* 'higher': the interpolation method 'higher' as used by 'numpy.percentile' function
63
+
* 'nearest': the interpolation method 'nearest' as used by 'numpy.percentile' function
64
+
* 'midpoint': the interpolation method 'midpoint' as used by 'numpy.percentile' function
The boxplot element is called `boxandwhiskers`. The basic options are from the `rectangle` element. The violin element is called `violin` also based on the `rectangle` element.
88
102
89
-
```typescript
103
+
```ts
90
104
interfaceIBaseStyling {
91
105
/**
92
106
* @defaultsee rectangle
@@ -103,18 +117,27 @@ interface IBaseStyling {
103
117
borderColor:string;
104
118
105
119
/**
106
-
* @defaultnull takes the current borderColor
120
+
* @default1
107
121
* @scriptable
108
122
* @indexable
109
123
*/
110
-
medianColor:string;
124
+
borderWidth:number;
111
125
112
126
/**
113
-
* @default1
114
-
* @scriptable
115
-
* @indexable
127
+
* item style used to render outliers
128
+
* @defaultcircle
116
129
*/
117
-
borderWidth:number;
130
+
outlierStyle:
131
+
|'circle'
132
+
|'triangle'
133
+
|'rect'
134
+
|'rectRounded'
135
+
|'rectRot'
136
+
|'cross'
137
+
|'crossRot'
138
+
|'star'
139
+
|'line'
140
+
|'dash';
118
141
119
142
/**
120
143
* radius used to render outliers
@@ -132,20 +155,17 @@ interface IBaseStyling {
132
155
outlierBackgroundColor:string;
133
156
134
157
/**
135
-
* to fill color below the median line of the box
136
-
* @defaulttransparent
158
+
* @defaultsee rectangle.borderColor
137
159
* @scriptable
138
160
* @indexable
139
161
*/
140
-
lowerBackgroundColor:string;
141
-
162
+
outlierBorderColor:string;
142
163
/**
143
-
* radius used to render items
144
-
* @default0 so disabled
164
+
* @default1
145
165
* @scriptable
146
166
* @indexable
147
167
*/
148
-
itemRadius:number;
168
+
outlierBorderWidth:number;
149
169
150
170
/**
151
171
* item style used to render items
@@ -163,25 +183,41 @@ interface IBaseStyling {
163
183
|'line'
164
184
|'dash';
165
185
186
+
/**
187
+
* radius used to render items
188
+
* @default0 so disabled
189
+
* @scriptable
190
+
* @indexable
191
+
*/
192
+
itemRadius:number;
193
+
166
194
/**
167
195
* background color for items
168
-
* @defaultsee rectanglebackgroundColor
196
+
* @defaultsee rectangle.backgroundColor
169
197
* @scriptable
170
198
* @indexable
171
199
*/
172
200
itemBackgroundColor:string;
173
201
174
202
/**
175
203
* border color for items
176
-
* @defaultsee rectangle backgroundColor
204
+
* @defaultsee rectangle.borderColor
177
205
* @scriptable
178
206
* @indexable
179
207
*/
180
208
itemBorderColor:string;
181
209
210
+
/**
211
+
* border width for items
212
+
* @default0
213
+
* @scriptable
214
+
* @indexable
215
+
*/
216
+
itemBorderColor:number;
217
+
182
218
/**
183
219
* padding that is added around the bounding box when computing a mouse hit
184
-
* @default1
220
+
* @default2
185
221
* @scriptable
186
222
* @indexable
187
223
*/
@@ -197,23 +233,33 @@ interface IBaseStyling {
197
233
}
198
234
199
235
interfaceIBoxPlotStylingextendsIBaseStyling {
200
-
// no extra styling options
201
-
}
236
+
/**
237
+
* separate color for the median line
238
+
* @default'transparent' takes the current borderColor
239
+
* @scriptable
240
+
* @indexable
241
+
*/
242
+
medianColor:string;
202
243
203
-
interfaceIViolinStylingextendsIBaseStyling {
204
244
/**
205
-
* number of sample points of the underlying KDE for creating the violin plot
206
-
* @default100
245
+
* color the lower half (median-q3) of the box in a different color
246
+
* @default'transparent' takes the current borderColor
Both types support that the data is given as an array of numbers `number[]`. The statistics will be automatically computed. In addition, specific summary data structures are supported:
In order to simplify the customization of the tooltips,
260
-
// TODO
261
-
262
-
```js
263
-
arr = {
264
-
options: {
265
-
tooltips: {
266
-
callbacks: {
267
-
// TODO
268
-
},
269
-
},
270
-
},
271
-
};
305
+
In order to simplify the customization of the tooltips the tooltip item given to the tooltip callbacks was improved. The default `toString()` behavior should be fine in most cases. The tooltip item has the following structure:
306
+
307
+
```ts
308
+
interfaceITooltipItem {
309
+
label:string; // original
310
+
value: {
311
+
raw:IBoxPlotItem|IViolinItem;
312
+
/**
313
+
* in case an outlier is hovered this will contains its index
314
+
* @default-1
315
+
*/
316
+
hoveredOutlierRadius:number;
317
+
/**
318
+
* toString function with a proper default implementation, which is used implicitly
319
+
*/
320
+
toString():string;
321
+
322
+
min:string;
323
+
median:string;
324
+
max:string;
325
+
items?:string[];
326
+
327
+
//... the formatted version of different attributes IBoxPlotItem or ViolinItem
328
+
};
329
+
}
272
330
```
273
331
274
332
### ESM and Tree Shaking
275
333
276
-
The ESM build of the library supports three shaking but having no side effects. As a consequence the chart.js library won't be automatically manipulated nor new controllers automatically registered. One has to manually import and register them.
334
+
The ESM build of the library supports tree shaking thus having no side effects. As a consequence the chart.js library won't be automatically manipulated nor new controllers automatically registered. One has to manually import and register them.
277
335
278
336
```js
279
337
importChartfrom'chart.js';
@@ -282,6 +340,11 @@ import { BoxPlot } from '@sgratzl/chartjs-chart-boxplot';
282
340
// register controller in chart.js and ensure the defaults are set
0 commit comments