maidr 3.38.1 → 3.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,14 +17,15 @@ and encourages a multi-modal exploration on visualization.
17
17
  ## Table of Contents
18
18
 
19
19
  1. [Usage](#usage)
20
- 2. [Controls](#controls)
21
- 3. [Braille Generation](#braille-generation)
22
- 4. [API](#api)
23
- 5. [Binders](#binders)
24
- 6. [Papers](#papers)
25
- 7. [License](#license)
26
- 8. [Contact](#contact)
27
- 9. [Acknowledgments](#acknowledgments)
20
+ 2. [Examples](#examples)
21
+ 3. [Controls](#controls)
22
+ 4. [Braille Generation](#braille-generation)
23
+ 5. [API](#api)
24
+ 6. [Binders](#binders)
25
+ 7. [Papers](#papers)
26
+ 8. [License](#license)
27
+ 9. [Contact](#contact)
28
+ 10. [Acknowledgments](#acknowledgments)
28
29
 
29
30
  ## Usage
30
31
 
@@ -40,8 +41,8 @@ To use maidr, follow these steps:
40
41
  <head>
41
42
  <meta charset="UTF-8" />
42
43
  <title>maidr Example</title>
43
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maidr/dist/maidr_style.min.css" />
44
- <script src="https://cdn.jsdelivr.net/npm/maidr/dist/maidr.min.js"></script>
44
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maidr@latest/dist/maidr_style.css" />
45
+ <script src="https://cdn.jsdelivr.net/npm/maidr@latest/dist/maidr.js"></script>
45
46
  </head>
46
47
  <body>
47
48
  <div>
@@ -53,218 +54,347 @@ To use maidr, follow these steps:
53
54
 
54
55
  3. Add your data: Include your data as a JSON schema directly in the HTML file. There should be a single `maidr` object with the following properties, or an array of objects if multiple plots exist on the page. Your JSON schema may look like so: (values for demonstration purposes)
55
56
 
56
- ```javascript
57
+ ```javascript
57
58
  // a single plot
58
- let maidr = {
59
- type: 'box',
60
- id: 'myboxplot',
61
- title: 'Highway Mileage by Car Class.',
62
- axes: {
63
- y: {
64
- label: 'Car Class',
65
- level: [
66
- '2seater',
67
- 'compact',
68
- 'midsize',
69
- 'minivan',
70
- 'pickup',
71
- 'subcompact',
72
- 'suv',
73
- ],
74
- },
75
- x: { label: 'Highway Milage' },
76
- },
77
- selector: '#boxplot1 g[id^="panel"] > g[id^="geom_boxplot.gTree"]',
78
- data: []
79
- };
80
-
81
- // or, multiple plots
82
- maidr = [
83
- {
84
- type: 'box',
85
- id: 'myboxplot',
86
- title: 'Highway Mileage by Car Class.',
87
- axes: {
88
- y: {
89
- label: 'Car Class',
90
- level: [
91
- '2seater',
92
- 'compact',
93
- 'midsize',
94
- 'minivan',
95
- 'pickup',
96
- 'subcompact',
97
- 'suv',
98
- ],
99
- },
100
- x: { label: 'Highway Milage' },
101
- },
102
- selector: '#boxplot1 g[id^="panel"] > g[id^="geom_boxplot.gTree"]',
103
- data: []
104
- },
105
- {
106
- type: 'bar',
107
- id: 'mybarplot',
108
- // etc
109
- }
110
- ];
111
- ```
59
+ <script>
60
+ var maidr = {
61
+ id: "barplot_1",
62
+ subplots: [
63
+ [
64
+ {
65
+ id: "barplot_1", //add the same id to the svg component
66
+ layers: [
67
+ {
68
+ id: "bar_layer1",
69
+ type: "bar",
70
+ title: "Sample Bar plot",
71
+ axes: {
72
+ x: "Category",
73
+ y: "Value"
74
+ },
75
+ data: [
76
+ {
77
+ "x": "A",
78
+ "y": 10
79
+ },
80
+ {
81
+ "x": "B",
82
+ "y": 24
83
+ },
84
+ {
85
+ "x": "C",
86
+ "y": 15
87
+ },
88
+ {
89
+ "x": "D",
90
+ "y": 7
91
+ }
92
+ ]
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ ]
98
+ }
99
+ </script>
100
+ ```
112
101
 
102
+ Or multiple plots:
103
+ ```javascript
104
+ <script>
105
+ var maidr = {
106
+ "id": "multipanel_plot",
107
+ "subplots": [
108
+ [
109
+ {
110
+ "id": "line1",
111
+ "layers": [
112
+ {
113
+ "id": "line_layer",
114
+ "type": "line",
115
+ "title": "Line Plot: Random Data",
116
+ "axes": {
117
+ "x": "X-axis",
118
+ "y": "Values"
119
+ },
120
+ "data": [
121
+ []
122
+ ],
123
+ }
124
+ ]
125
+ }
126
+ ],
127
+ [
128
+ {
129
+ "id": "bar1",
130
+ "layers": [
131
+ {
132
+ "id": "bar1_layer",
133
+ "type": "bar",
134
+ "title": "Bar Plot: Random Values",
135
+ "axes": {
136
+ "x": "Categories",
137
+ "y": "Values"
138
+ },
139
+ "data": []
140
+ }
141
+ ]
142
+ }
143
+ ],
144
+ [
145
+ {
146
+ "id": "bar2",
147
+ "layers": [
148
+ {
149
+ "id": "bar2_layer",
150
+ "type": "bar",
151
+ "title": "Bar Plot 2: Random Values",
152
+ "axes": {
153
+ "x": "Categories",
154
+ "y": "Values"
155
+ },
156
+ "data": []
157
+ }
158
+ ]
159
+ }
160
+ ]
161
+ ]
162
+ }
163
+ </script>
164
+ ```
113
165
  4. Use the following to define the object properties:
114
166
 
115
- - `type`: the type of plot. Currently supported are 'bar,' 'heat,' 'box,' 'scatter,' and 'line.'
167
+ - `type`: the type of plot. Currently supported are 'bar', 'box', 'candlestick', 'dodged_bar', 'heat', 'hist', 'line', 'stacked_normalized_bar', 'point', 'smooth', 'stacked_bar',
116
168
  - `id`: the id that you added as an attribute of your main SVG.
117
169
  - `title`: the title of the plot. (optional)
118
170
  - `axes`: axes info for your plot. `maidr.axes.x.label` and `maidr.axes.y.label` will provide axes labels, and `maidr.axes.x.level` or `maidr.axes.y.level` (x or y, not both) will provide level or tick mark labels.
119
171
  - `data`: the main data for your plot. See below.
120
172
 
121
173
  5. Define your data set using the `maidr.data` property. This comes in different formats depending on a plot type:
174
+ The data property is defined as a list of objects where each object is a record with fields x and y.
175
+
176
+ ```javascript
122
177
 
123
- ```javascript
124
178
  let maidr;
125
179
 
126
180
  // barplot maidr.data structure: a simple array of values
127
181
  maidr = {
128
- data: [929539693, 898871185, 3811953828, 586098530, 24549948],
129
- };
130
-
131
- // heatmap maidr.data structure: a 2D array of values
132
- maidr = {
133
- data: [
134
- [124, 0, 0],
135
- [0, 68, 0],
136
- [44, 56, 52],
137
- ],
182
+ "data": [
183
+ {
184
+ "x": "A",
185
+ "y": 5.982192824845484
186
+ },
187
+ {
188
+ "x": "B",
189
+ "y": 9.309858198175455
190
+ },
191
+ {
192
+ "x": "C",
193
+ "y": 7.3531284491571505
194
+ },
195
+ ]
138
196
  };
139
197
 
140
- // boxplot maidr.data structure: an array of objects with properties lower_outlier, min, q1, q2, q3, max, and upper_outlier
141
- maidr = {
142
- data: [
143
- {
144
- lower_outlier: null,
145
- min: 23,
146
- q1: 24,
147
- q2: 25,
148
- q3: 26,
149
- max: 26,
150
- upper_outlier: null,
151
- },
152
- {
153
- // etc
154
- },
155
- ],
156
- };
198
+ // boxplot maidr.data structure: an array of objects with properties lower_outlier, min, q1, q2, q3, max, and upper_outlier
199
+ maidr = {
200
+ "data": [
201
+ {
202
+ "lowerOutliers": [
203
+ 40.0,
204
+ 50.0
205
+ ],
206
+ "min": 71.35451232573614,
207
+ "q1": 92.62315416457983,
208
+ "q2": 99.64912548800726,
209
+ "q3": 107.6684972253361,
210
+ "max": 118.19391634772752,
211
+ "upperOutliers": [
212
+ 150.0,
213
+ 160.0
214
+ ],
215
+ "fill": "Group 1"
216
+ },
217
+
218
+ ],
219
+
220
+ "orientation": "vert" //vert for vertical box plots, horz for horizontal bar plots
221
+ }
222
+
223
+ //candlestick
224
+ maidr = {
225
+ "data":[
226
+ {
227
+ 'value': '2023-02-16',
228
+ 'open': 151.61,
229
+ 'high': 151.82,
230
+ 'low': 151.59,
231
+ 'close': 151.8,
232
+ 'volume': 0
233
+ },
234
+ ]
235
+ }
236
+
237
+ //dodged_bar
238
+ maidr = {
239
+ "data":[
240
+ [
241
+ {
242
+ "x":"Adelie",
243
+ "fill":"Below",
244
+ "y":70
245
+ }
246
+ ],
247
+ [ {
248
+ "x":"Adelie",
249
+ "fill":"Above",
250
+ "y":90
251
+ }]
252
+ ]
253
+ }
157
254
 
158
- // scatterplot maidr.data: an object containing x and y properties, each with an array of float values
159
- // note that data is an array here as scatterplots are often combine with line plots
255
+ // heatmap maidr.data structure: a 2D array of values
256
+ maidr = {
257
+ "data": {
258
+ "points": [
259
+ [ 60.5, 86.7, 89.3 ],
260
+ [ 18.6, 67.6, 83.9 ],
261
+ [ 18.5, 65.4, 78.7 ],
262
+ ],
263
+ "x": [
264
+ "CoLA",
265
+ "MNLI",
266
+ "MRPC",
267
+ ],
268
+ "y": [
269
+ "BERT",
270
+ "BiLSTM",
271
+ "BiLSTM+Attn",
272
+ ]
273
+ }
274
+ }
275
+
276
+ //histogram
277
+ maidr = {
278
+ "data":[
279
+ {
280
+ "y": 4.0,
281
+ "x": 1.1475,
282
+ "xMin": 1.0,
283
+ "xMax": 1.295,
284
+ "yMin": 0,
285
+ "yMax": 4.0
286
+ }
287
+ ]
288
+ }
289
+
290
+ //line
291
+ maidr = {
292
+ "data":[
293
+ [
294
+ {
295
+ "x": 1.0,
296
+ "y": 2.0
297
+ },
298
+ {
299
+ "x": 2.0,
300
+ "y": 4.0
301
+ },
302
+ ]
303
+ //add multiple arrays for multiline plots
304
+ ]
305
+ }
306
+
307
+ // scatterplot
160
308
  maidr = {
161
309
  data: [
162
310
  {
163
- x: [1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 3.1],
164
- y: [29, 29, 31, 30, 26, 26, 27, 26, 25, 28, 27, 25, 25, 25, 25, 24],
165
- },
166
- // line data could go here
311
+ "x": 1.0,
312
+ "y": 2.0
313
+ },
167
314
  ],
168
315
  };
169
316
 
170
317
  // smooth line maidr.data: an object containing x and y properties, each with an array of float values
171
318
  // note that data is an array here as scatterplots are often combine with line plots
172
319
  maidr = {
173
- data: [
174
- // scatterplot data could go here
175
- {
176
- x: [1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 3.1],
177
- y: [29, 29, 31, 30, 26, 26, 27, 26, 25, 28, 27, 25, 25, 25, 25, 24],
178
- },
179
- ],
180
- };
181
- ```
320
+ "data":[
321
+ [
322
+ {
323
+ "x": 4.7,
324
+ "y": 3.12,
325
+ "svg_x": 404.51,
326
+ "svg_y": 390.012
327
+ },
328
+ ]
329
+ ]
330
+ }
182
331
 
183
- 6. If multiple plots are overlaid on the same SVG, the `type` and `data` properties can be an array instead of a single value. Be sure the order is matched between them. The final JSON schema could look like so:
184
-
185
- ```javascript
186
- const maidr = {
187
- type: ['point', 'smooth'],
188
- id: 'scatter1',
189
- title: 'Highway Mileage by Engine Displacement.',
190
- name: 'Tutorial 4: Scatterplot',
191
- selector: [
192
- 'g[id^="geom_point"] > use',
193
- 'g[id^="geom_smooth.gTree"] > g[id^="GRID.polyline"] > polyline[id^="GRID.polyline"]',
194
- ],
195
- axes: {
196
- x: {
197
- label: 'Engine Displacement',
198
- },
199
- y: {
200
- label: 'Highway Mileage',
201
- },
202
- },
203
- data: [
204
- {
205
- x: [
206
- 1.8,
207
- 1.8,
208
- 2,
209
- 2,
210
- 2.8,
211
- 2.8,
212
- 3.1,
213
- 1.8,
214
- 1.8,
215
- 2,
216
- 2,
217
- 2.8,
218
- 2.8,
219
- 3.1,
220
- 3.1,
221
- 2.8,
222
- ],
223
- y: [29, 29, 31, 30, 26, 26, 27, 26, 25, 28, 27, 25, 25, 25, 25, 24],
224
- },
225
- {
226
- x: [
227
- 1.6,
228
- 1.6684,
229
- 1.7367,
230
- 1.8051,
231
- 1.8734,
232
- 1.9418,
233
- 2.0101,
234
- 2.0785,
235
- 2.1468,
236
- 2.2152,
237
- 2.2835,
238
- 2.3519,
239
- 2.4203,
240
- 2.4886,
241
- 2.557,
242
- 2.6253,
243
- ],
244
- y: [
245
- 33.0929,
246
- 32.5108,
247
- 31.9422,
248
- 31.3885,
249
- 30.8509,
250
- 30.33,
251
- 29.8239,
252
- 29.3334,
253
- 28.8584,
254
- 28.3981,
255
- 27.9519,
256
- 27.5189,
257
- 27.0988,
258
- 26.6958,
259
- 26.3091,
260
- 25.9356,
261
- ],
262
- },
263
- ],
264
- };
265
- ```
332
+ ```
333
+
334
+ 6. If multiple plots are overlaid on the same SVG, provide the data corresponding to every plot in the layers array.
335
+
336
+ ```javascript
337
+ maidr = {
338
+ "id": "multilayer_plot",
339
+ "subplots": [
340
+ [
341
+ {
342
+ "id": "445f4f08-b8a5-4204-8c55-0851eda7daec",
343
+ "layers": [
344
+ {
345
+ "id": "f548e01f-ed13-469c-9e0a-cea420ec8b3f",
346
+ "type": "bar",
347
+ "title": "",
348
+ "axes": {
349
+ "x": "X values",
350
+ "y": "Bar values"
351
+ },
352
+ "data": [
353
+ {
354
+ "x": "0",
355
+ "y": 3.0
356
+ },
357
+ {
358
+ "x": "1",
359
+ "y": 5.0
360
+ },
361
+ ],
362
+ },
363
+ {
364
+ "id": "f022d8e9-4aff-4ab0-9959-904fd07c9bd2",
365
+ "type": "line",
366
+ "title": "Multilayer Plot Example",
367
+ "axes": {
368
+ "x": "X values",
369
+ "y": "Line values"
370
+ },
371
+ "data": [
372
+ [
373
+ {
374
+ "x": 0.0,
375
+ "y": 10.0,
376
+ "fill": "Line Data"
377
+ },
378
+ {
379
+ "x": 1.0,
380
+ "y": 8.0,
381
+ "fill": "Line Data"
382
+ },
383
+ ]
384
+ ],
385
+ }
386
+ ]
387
+ }
388
+ ]
389
+ ]
390
+ }
391
+ ```
392
+
393
+
394
+ ## Examples
395
+ Example plots are demonstrated [here](https://xabilitylab.ischool.illinois.edu/maidr/).
266
396
 
267
- For more information and examples, refer to the example HTML files provided in the repository.
397
+ For more information, refer to the example HTML files provided in the directory docs/examples
268
398
 
269
399
  ## Controls
270
400
 
@@ -276,6 +406,7 @@ To interact with the plots using maidr, follow these steps:
276
406
  4. Press **T** to toggle Text mode.
277
407
  5. Press **S** to toggle Sonification (tones) mode.
278
408
  6. Press **R** to toggle Review mode.
409
+ 7. Hover on the datapoint to
279
410
 
280
411
  Below is a detailed list of keyboard shortcuts for various functions:
281
412
 
@@ -294,6 +425,9 @@ Below is a detailed list of keyboard shortcuts for various functions:
294
425
  | Stop Auto-play | Control | Command |
295
426
  | Auto-play speed up | Period | Period |
296
427
  | Auto-play speed down | Comma | Comma |
428
+ | Move to next navigation mode | Shift + Alt + Up/Down | Shift + Alt + Up/Down |
429
+ | Open Settings | Control + , | Command + , |
430
+ | Open Command Pallette | Control + Shift + p | Command + Shift + p |
297
431
 
298
432
  ### Segmented Bar Controls
299
433