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
* Update docs
Grammar and style: "TypeScript", add articles, etc.
Add docs covering the `Array[]` version of data. Please review and let me know if I've made any mistakes.
Fix an apparent mistake in the `parsing: false` description of category axes: I believe it's trying to say that _strings_ would be a mistake.
* Reword based on feedback and further testing
Copy file name to clipboardExpand all lines: docs/general/data-structures.md
+25-8Lines changed: 25 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
The `data` property of a dataset can be passed in various formats. By default, that `data` is parsed using the associated chart type and scales.
4
4
5
-
If the `labels` property of the main `data` property is used, it has to contain the same amount of elements as the dataset with the most values. These labels are used to label the index axis (default x axes). The values for the labels have to be provided in an array.
6
-
The provided labels can be of the type string or number to be rendered correctly. In case you want multiline labels you can provide an array with each line as one entry in the array.
5
+
If the `labels` property of the main `data` property is used, it has to contain the same amount of elements as the dataset with the most values. These labels are used to label the index axis (default `x` axis). The values for the labels have to be provided in an array.
6
+
The provided labels can be of the type string or number to be rendered correctly. If you want multiline labels, you can provide an array with each line as one entry in the array.
7
7
8
8
## Primitive[]
9
9
@@ -19,7 +19,22 @@ const cfg = {
19
19
}
20
20
```
21
21
22
-
When the `data` is an array of numbers, values from `labels` array at the same index are used for the index axis (`x` for vertical, `y` for horizontal charts).
22
+
When `data` is an array of numbers, values from the `labels` array at the same index are used for the index axis (`x` for vertical, `y` for horizontal charts).
23
+
24
+
## Array[]
25
+
26
+
```javascript
27
+
constcfg= {
28
+
type:'line',
29
+
data: {
30
+
datasets: [{
31
+
data: [[10, 20], [15, null], [20, 10]]
32
+
}]
33
+
}
34
+
}
35
+
```
36
+
37
+
When `data` is an array of arrays (or what TypeScript would call tuples), the first element of each tuple is the index (`x` for vertical, `y` for horizontal charts) and the second element is the value (`y` by default).
23
38
24
39
## Object[]
25
40
@@ -58,7 +73,9 @@ const cfg = {
58
73
59
74
This is also the internal format used for parsed data. In this mode, parsing can be disabled by specifying `parsing: false` at chart options or dataset. If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
60
75
61
-
The values provided must be parsable by the associated scales or in the internal format of the associated scales. A common mistake would be to provide integers for the `category` scale, which uses integers as an internal format, where each integer represents an index in the labels array. `null` can be used for skipped values.
76
+
The values provided must be parsable by the associated scales or in the internal format of the associated scales. For example, the `category` scale uses integers as an internal format, where each integer represents an index in the labels array; but, if parsing is enabled, it can also parse string labels.
77
+
78
+
`null` can be used for skipped values.
62
79
63
80
## Object[] using custom properties
64
81
@@ -117,7 +134,7 @@ const cfg = {
117
134
```
118
135
119
136
:::warning
120
-
When using object notation in a radar chart, you still need a labels array with labels for the chart to show correctly.
137
+
When using object notation in a radar chart, you still need a `labels` array with labels for the chart to show correctly.
121
138
:::
122
139
123
140
## Object
@@ -136,7 +153,7 @@ const cfg = {
136
153
}
137
154
```
138
155
139
-
In this mode, property name is used for `index` scale and value for `value` scale. For vertical charts, index scale is `x` and value scale is `y`.
156
+
In this mode, the property name is used for the `index` scale and value for the `value` scale. For vertical charts, the index scale is `x` and value scale is `y`.
140
157
141
158
## Dataset Configuration
142
159
@@ -180,9 +197,9 @@ const cfg = {
180
197
};
181
198
```
182
199
183
-
## Typescript
200
+
## TypeScript
184
201
185
-
When using typescript, if you want to use a data structure that is not the default data structure, you will need to pass it to the type interface when instantiating the data variable.
202
+
When using TypeScript, if you want to use a data structure that is not the default data structure, you will need to pass it to the type interface when instantiating the data variable.
0 commit comments