Skip to content

Commit f89edc5

Browse files
committed
[update] headerShape.cellStyle updated, number formatting upd
1 parent c7a97bd commit f89edc5

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

docs/api/config/headershape-property.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ description: You can learn about the headerShape config in the documentation of
1616
headerShape?: {
1717
collapsible?: boolean,
1818
vertical?: boolean,
19-
template?: (label: string, field: string, subLabel?: string) => string
19+
template?: (label: string, field: string, subLabel?: string) => string,
20+
cellStyle?: (
21+
field: string,
22+
value: any,
23+
area: "rows"|"columns"|"values",
24+
method?: string,
25+
isTotal?: boolean)
26+
=> string,
2027
};
2128
~~~
2229

@@ -28,7 +35,7 @@ headerShape?: {
2835
- `field` (string) - (required) a string representing the field name the cell corresponds to. For the header of the tree column the field is ""
2936
- `value` (string | number | date) - (required) the value of a cell
3037
- `area` - (required) a string indicating the area of the table where a cell resides ("rows", "columns" or "values" area)
31-
- `method` string - (optional) a string that can represent the operation performed for a field from the "values` area (e.g., "sum", "count", etc.) or the name of a predicate set for a field from the "columns" area
38+
- `method` (string) - (optional) a string that can represent the operation performed for a field from the "values` area (e.g., "sum", "count", etc.) or the name of a predicate set for a field from the "columns" area
3239
- `isTotal` - (optional) defines whether a cell belongs to a total column
3340
- `template` - (optional) defines the format of text in headers. By default, for the fields applied as rows the value of the `label` parameter is displayed and for the fields applied as values the label and method are shown (e.g., *Oil(count)*). The function takes the field id, label and the method or predicate id (if any) and returns the processed value. The default template is as follows:
3441
~~~js
@@ -58,7 +65,7 @@ const table = new pivot.Pivot("#root", {
5865
},
5966
headerShape: {
6067
vertical: true,
61-
template: (label, field, subLabel) => field + (subLabel ? ` (${subLabel})` : "")
68+
template: (label, field, subLabel) => field + (subLabel ? ` (${subLabel})` : ""),
6269
}
6370
});
6471
~~~

docs/api/config/tableshape-property.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ tableShape?: {
3939
left?: boolean,
4040
right?: boolean,
4141
},
42-
cellStyle?: (field: string, value: any, area: string, method?: string, isTotal?: string) => string,
42+
cellStyle?: (
43+
field: string,
44+
value: any,
45+
area: "rows"|"columns"|"values",
46+
method?: string,
47+
isTotal?: "row"|"column"|"both")
48+
=> string,
4349
};
4450
~~~
4551

docs/guides/localization.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,15 @@ To present the 20th of June, 2024 with the exact time as *2024-09-20 16:47:08.12
267267

268268
## Number formatting
269269

270-
By default, all fields with the *number* type are localized according to the locale (the value in the `lang` field of the locale). The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) object enables language-sensitive number formatting. In case you need to set a custom format to a specific field, use the `format` parameter of the [`fields`](/api/config/fields-property) property. By default, the format for numeric values limits fraction digits to 3 and applies group separation for the integer part. The `format` parameter allows you to display numeric values without group separation (for example, years):
270+
By default, all fields with the number type are localized according to the locale (the value in the `lang` field of the locale). Pivot uses [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) specification. By default the fraction digits are limited to 3 and group separation is applied for the integer part.
271+
In case you do not need to format specific fields with numeric values or need to set a custom format, use the the `format` parameter of the [`fields`](/api/config/fields-property) property. It can be either *false* to cancel formatting or an object with format settings (refer to [Custom number formatting](/guides/custom-formatting/#custom-number-formatting)).
271272

272-
~~~js
273+
~~~jsx
273274
const fields = [
274275
{ id: "year", label: "Year", type: "number", format: false},
275276
];
276277
~~~
277278

278-
For more information, refer to [Custom number formatting](/guides/custom-formatting/#custom-number-formatting).
279-
280-
:::info
281-
In case you need to disable formatting of some fields, set the `format` parameter of the [`fields`](/api/config/fields-property) property to *false*.
282-
:::
283-
284279
## Example
285280

286281
In this snippet you can see how to switch between several locales:

docs/guides/stylization.md

+10
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ const widget = new pivot.Pivot("#pivot", {
155155
});
156156
~~~
157157

158+
It's also possible to customize the style of total columns and total rows via the `wx-total` class:
159+
160+
~~~html
161+
<style>
162+
.wx-cell.wx-total {
163+
background: #fafafb;
164+
font-weight: var(--wx-header-font-weight);
165+
}
166+
</style>
167+
~~~
158168

159169
## Marking cells
160170

0 commit comments

Comments
 (0)