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: docs/guides/configuration.md
+98-17Lines changed: 98 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -22,19 +22,30 @@ You can configure the *Pivot* appearance and functionality via the corresponding
22
22
23
23
All instructions about working with data see here: [Working with data](guides/working-with-data)
24
24
25
-
## Datatable
26
-
27
25
You can configure and/or customize the following elements of the Pivot table:
28
26
29
27
- columns and rows
30
28
- headers and footers
31
29
- cells
32
30
- the table sizes
33
31
34
-
###Resizing the table
32
+
## Resizing the table
35
33
36
34
You can change the size of the table rows and columns, header and footer using the [`tableShape`](/api/config/tableshape-property) property.
37
35
36
+
The next sizes are applied by default:
37
+
38
+
~~~jsx
39
+
constsizes= {
40
+
rowHeight:34,
41
+
headerHeight:30,
42
+
footerHeight:30,
43
+
colWidth:150,
44
+
};
45
+
~~~
46
+
47
+
Example:
48
+
38
49
~~~jsx
39
50
constwidget=newpivot.Pivot("#pivot", {
40
51
fields,
@@ -66,7 +77,7 @@ const widget = new pivot.Pivot("#pivot", {
66
77
67
78
To set the width of specific column(s), apply the `width` parameter of the [columnShape property](/api/config/columnshape-property).
68
79
69
-
###Autosizing columns to content
80
+
## Autosizing columns to content
70
81
71
82
The widget allows setting the minimum width value for all columns as well as enable sizing for the header, data only or combined auto sizing. To configure all these autosizing settings, you should apply the `autoWidth` parameter of the [`columnShape`](/api/config/columnshape-property) property.
72
83
@@ -114,7 +125,81 @@ const pivotWidget = new pivot.Pivot("#pivot", {
114
125
});
115
126
~~~
116
127
117
-
### Making columns collapsible
128
+
## Applying templates to cells
129
+
130
+
To set a template to cells, use the `templates` parameter of the [`tableShape`](/api/properties/tableshape-property) property. It's an object where each key is a field id and the value is a function that returns a string. All columns based on the specified field will have the related template applied.
131
+
132
+
In the example below we apply the template to the *score* values to display 2 digits after the decimal point for these values and we add the "€" sign to the *price* values.
133
+
134
+
~~~jsx {1-4,8}
135
+
consttemplates= {
136
+
price: (v) => (v ?"€"+ v : v),
137
+
score: (v) => (v ?parseFloat(v).toFixed(2) : v)
138
+
};
139
+
140
+
constwidget=newpivot.Pivot("#pivot", {
141
+
tableShape: {
142
+
templates,
143
+
},
144
+
fields,
145
+
data,
146
+
config: {
147
+
rows: ["studio", "genre"],
148
+
columns: [],
149
+
values: [
150
+
{
151
+
field:"title",
152
+
method:"count",
153
+
},
154
+
{
155
+
field:"score",
156
+
method:"max",
157
+
},
158
+
{
159
+
field:"price",
160
+
method:"count",
161
+
},
162
+
],
163
+
},
164
+
});
165
+
~~~
166
+
167
+
## Applying templates to headers
168
+
169
+
To define the format of text in headers, apply the `template` parameter of the [`headerShape`](/api/config/headershape-property) property. The parameter is the function that takes the field id, label and sublabel (the name of a method if any is applied) and returns the processed value (the default template is as follows: *template: (label, id, subLabel) => label + (subLabel ? `(${subLabel})` : "")*). By default, for the fields applied as values the label and method are shown (e.g., *Oil(count)*).
170
+
If no other template is applied to columns, the value of the `label` parameter is displayed. If any [`predicate`](/config/predicates-property) template is applied, it will override the template of the `headerShape` property.
171
+
172
+
Example:
173
+
174
+
In the example below for the **values** fields the header will display the method name (subLabel) and the label:
175
+
176
+
~~~jsx {19-22}
177
+
constpivotWidget=newpivot.Pivot("#pivot", {
178
+
fields,
179
+
data,
180
+
config: {
181
+
rows: ["studio", "genre"],
182
+
columns: [],
183
+
values: [
184
+
{
185
+
field:"title",
186
+
method:"count",
187
+
},
188
+
{
189
+
field:"score",
190
+
method:"max",
191
+
},
192
+
],
193
+
},
194
+
195
+
headerShape: {
196
+
vertical:true,
197
+
template: (label, id, subLabel) => id + (subLabel ?` (${subLabel})`:""),
198
+
},
199
+
});
200
+
~~~
201
+
202
+
## Making columns collapsible
118
203
119
204
It's possible to collapse/expand columns that are under one header. To make columns collapsible, use the value of the `collapsible` parameter of the [`headerShape`](/api/config/headershape-property) property by setting it to **true**.
120
205
@@ -142,7 +227,7 @@ const widget = new pivot.Pivot("#pivot", {
142
227
});
143
228
~~~
144
229
145
-
###Freezing columns
230
+
## Freezing columns
146
231
147
232
The widget allows freezing columns on the left side, which makes the left-most columns static and visible while scrolling. To freeze columns, apply the **split** parameter of the [`tableShape`](/api/config/tableshape-property) property by setting the value of the `left` property to **true**.
The sorting functionality is enabled by default. A user can click the column's header to sort data. To disable/enable sorting, apply the `sort` parameter of the [`columnShape`](/api/config/columnshape-property) property. In the example below we disable sorting.
218
303
@@ -242,7 +327,7 @@ const pivotWidget = new pivot.Pivot("#pivot", {
242
327
243
328
For more information about sorting data, refer to [Sorting data](/guides/working-with-data#sorting-data).
244
329
245
-
###Enabling the tree mode
330
+
## Enabling the tree mode
246
331
247
332
The widget allows presenting data in a hierarchical format with expandable rows. To switch to the tree mode, apply the `tree` parameter of the [`tableShape`](/api/config/tableshape-property) property by setting its value to **true** (default is **false**).
248
333
To specify the parent row, put its name first in the `rows` array of the [`config`](/api/config/config-property) property.
@@ -282,7 +367,7 @@ const widget = new pivot.Pivot("#pivot", {
282
367
});
283
368
~~~
284
369
285
-
###Expanding/collapsing all rows
370
+
## Expanding/collapsing all rows
286
371
287
372
To expand/collapse all rows, the **tree** mode should be enabled via the [`tableShape`](/api/config/tableshape-property) property and you should use the [`render-table`](/api/events/render-table-event) event that allows changing configuration settings, namely, making data rows expanded or collapsed (via the `row.open` parameter of the `config` object).
To change text orientation from default horizontal to vertical, use the [`headerShape`](/api/config/headershape-propeprty) property and set its `vertical` parameter to **true**.
355
440
@@ -387,15 +472,11 @@ const widget = new pivot.Pivot("#pivot", {
387
472
});
388
473
~~~
389
474
475
+
## Controlling visibility of Configuration panel
390
476
477
+
The Configuration panel is displayed by default. The widget provides the default functionality that allows controlling the visibility of the Configuration panel with the button click. It's made possible via the [`configPanel`](api/config/configPanel) property or [`show-config-panel`](/api/events/show-config-panel-event) event.
391
478
392
-
## Configuration panel
393
-
394
-
### Default settings
395
-
396
-
The configuration panel is displayed by default. The widget provides the default functionality that allows controlling the visibility of the Configuration panel with the button click. It's made possible via the [`configPanel`](api/config/configPanel) property or [`show-config-panel`](/api/events/show-config-panel-event) event.
397
-
398
-
### Hiding configuration panel
479
+
### Hiding Configuration panel
399
480
400
481
To hide the panel, set the value of the [`configPanel`](api/config/configPanel) property to **false**.
Copy file name to clipboardExpand all lines: docs/guides/localization.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ description: You can learn about the localization in the documentation of the DH
6
6
7
7
# Localization
8
8
9
+
TBD
10
+
9
11
You can localize all labels in the interface of JavaScript Pivot. For this purpose you need to create a new locale or modify a built-in one and apply it to Pivot.
Copy file name to clipboardExpand all lines: docs/guides/working-with-data.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ This page describes how to aggregate data in Pivot. For the instructions about l
10
10
11
11
## Defining fields
12
12
13
-
Use the [`fields`](/api/config/fields-property) property to add fields to the Pivot table.
13
+
Use the [`fields`](/api/config/fields-property) property to add fields to the Pivot table. To add a new field, you should add a new object to the `fields` array.
14
14
15
15
Example:
16
16
@@ -60,7 +60,7 @@ const widget = new pivot.Pivot("#pivot", {
60
60
61
61
The widget API allows configuring the sorting settings that are applied applied to all areas (values, columns and rows) during aggregation. The sorting in UI is enabled by clicking the column header.
62
62
63
-
To set default sorting values, apply the **sort** parameter of the [`fields`](/api/properties/fields-property) property. It accepts either the "asc" or "desc" value, or a custom sorting function.
63
+
To set default sorting values, apply the **sort** parameter of the [`fields`](/api/config/fields-property) property. It accepts either the "asc" or "desc" value, or a custom sorting function.
64
64
65
65
In the example below we add clickable field labels and the sorting functionality that is enabled with the icon click:
0 commit comments