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
In the example below for the **values** fields the header will display the label, the method name (subLabel) and converts the result to lowercase (e.g., *profit (sum)*):
Copy file name to clipboardExpand all lines: docs/api/config/tableshape-property.md
+23-18Lines changed: 23 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,37 +79,42 @@ By default, `tableShape` is undefined, implying that no total row, no total colu
79
79
80
80
## Example
81
81
82
-
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.
82
+
In the example below we apply the template to the *state* cells to show the combined name of a state (the full name and abbreviation).
83
83
84
-
~~~jsx {5-8}
85
-
consttemplates= { price: (v) => (v ?"€"+ v : v),
86
-
score: (v) => (v ?parseFloat(v).toFixed(2) : v) };
84
+
~~~jsx {10-15}
85
+
conststates= {
86
+
"California":"CA",
87
+
"Colorado":"CO",
88
+
"Connecticut":"CT",
89
+
"Florida":"FL",
90
+
// other values,
91
+
};
87
92
88
93
consttable=newpivot.Pivot("#root", {
89
94
tableShape: {
90
-
tree:true,
91
-
templates
95
+
templates: {
96
+
// set a template to customize values of "state" cells
97
+
state:v=> v+` (${states[v]})`,
98
+
}
92
99
},
93
100
fields,
94
101
data,
95
102
config: {
96
-
rows: ["studio", "genre"],
103
+
rows: ["state", "product_type"],
97
104
columns: [],
98
105
values: [
99
106
{
100
-
field:"title",
101
-
method:"count"
107
+
field:"profit",
108
+
method:"sum"
102
109
},
103
110
{
104
-
field:"score",
105
-
method:"max"
111
+
field:"sales",
112
+
method:"sum"
106
113
},
107
-
{
108
-
field:"price",
109
-
method:"count"
110
-
}
111
-
]
112
-
}
114
+
// other values
115
+
],
116
+
},
117
+
fields,
113
118
});
114
119
~~~
115
120
@@ -119,7 +124,7 @@ const table = new pivot.Pivot("#root", {
Copy file name to clipboardExpand all lines: docs/guides/configuration.md
+43-43Lines changed: 43 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,38 +133,42 @@ const table = new pivot.Pivot("#root", {
133
133
134
134
To set a template to cells, use the `templates` parameter of the [`tableShape`](/api/config/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.
135
135
136
-
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.
137
-
138
-
~~~jsx {1-4,8}
139
-
consttemplates= {
140
-
price: (v) => (v ?"€"+ v : v),
141
-
score: (v) => (v ?parseFloat(v).toFixed(2) : v)
136
+
In the example below we apply the template to the *state* cells to show the combined name of a state (the full name and abbreviation).
137
+
138
+
~~~jsx {10-15}
139
+
conststates= {
140
+
"California":"CA",
141
+
"Colorado":"CO",
142
+
"Connecticut":"CT",
143
+
"Florida":"FL",
144
+
// other values,
142
145
};
143
146
144
147
consttable=newpivot.Pivot("#root", {
145
148
tableShape: {
146
-
templates
149
+
templates: {
150
+
// set a template to customize values of "state" cells
151
+
state:v=> v+` (${states[v]})`,
152
+
}
147
153
},
148
154
fields,
149
155
data,
150
156
config: {
151
-
rows: ["studio", "genre"],
157
+
rows: ["state", "product_type"],
152
158
columns: [],
153
159
values: [
154
160
{
155
-
field:"title",
156
-
method:"count"
161
+
field:"profit",
162
+
method:"sum"
157
163
},
158
164
{
159
-
field:"score",
160
-
method:"max"
165
+
field:"sales",
166
+
method:"sum"
161
167
},
162
-
{
163
-
field:"price",
164
-
method:"count"
165
-
}
166
-
]
167
-
}
168
+
// other values
169
+
],
170
+
},
171
+
fields,
168
172
});
169
173
~~~
170
174
@@ -221,31 +225,31 @@ To define the format of text in headers, apply the `template` parameter of the [
221
225
A 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)*).
222
226
If no other template is applied to columns, the value of the `label` parameter is displayed. If any [`predicates`](/api/config/predicates-property) template is applied, it will override the template of the `headerShape` property.
223
227
224
-
In the example below for the **values** fields the header will display the method name (subLabel) and the label:
228
+
In the example below for the **values** fields the header will display the label, the method name (subLabel) and converts the result to lowercase (e.g., *profit (sum)*):
You can block toggling the visibility of the Configuration panel on the button click via the [`api.intercept()`](/api/internal/intercept-method) method (by listening to the [`show-config-panel`](/api/events/show-config-panel-event) event and returning *false*).
670
674
671
-
### Example
675
+
Example:
672
676
673
677
~~~jsx {20-22}
674
678
const table = new pivot.Pivot("#root", {
@@ -706,15 +710,11 @@ In the Configuration panel it's possible to perform the next operations with fie
706
710
- [update-field](/api/events/update-value-event)
707
711
- [move-field](/api/events/move-field-event)
708
712
709
-
## Example
710
-
711
-
In this snippet you can see how to apply templates to the Pivot cells:
0 commit comments