Skip to content

Commit be2d92d

Browse files
committed
[update] adding totals moved to working with data
1 parent c093a43 commit be2d92d

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

docs/guides/configuration.md

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -358,51 +358,9 @@ const widget = new pivot.Pivot("#pivot", {
358358
});
359359
~~~
360360

361-
### Adding columns and rows with total values
362-
363-
To enable generating the rightmost column with total values, apply the [`tableShape`](/api/config/tableshape-property) property and set the value of the `totalColumn` parameter to **true**.
364-
365-
To enable generating the footer with total, apply the [`tableShape`](/api/config/tableshape-property)property and set the value of the `totalRow` parameter to **true**.
366-
367-
Example:
368-
369-
~~~jsx {2-5}
370-
const widget = new pivot.Pivot("#pivot", {
371-
tableShape: {
372-
totalRow: true,
373-
totalColumn: true,
374-
},
375-
fields,
376-
data,
377-
config: {
378-
rows: ["studio"],
379-
columns: ["type"],
380-
values: [
381-
{
382-
field: "score",
383-
method: "max",
384-
},
385-
{
386-
field: "episodes",
387-
method: "count",
388-
},
389-
{
390-
field: "rank",
391-
method: "min",
392-
},
393-
{
394-
field: "members",
395-
method: "sum",
396-
},
397-
],
398-
},
399-
});
400-
~~~
401-
402361
### Setting date format
403362

404-
tbd
405-
363+
tbd!
406364
Pivot uses the following characters for setting the date format:
407365

408366
| Character | Definition |Example |
@@ -429,6 +387,10 @@ Pivot uses the following characters for setting the date format:
429387

430388
To present the 20th of June, 2024 with the exact time as *2024-09-20 16:47:08.128*, specify "%Y-%m-%d-%H:%i:%s.%u".
431389

390+
You can set the date format using the Pivot locale.
391+
392+
393+
432394
### Working with filters
433395

434396
The widget allows you to set various filters for fields depending on the type of data. It's possible to specify filters both via the Pivot interface after initialization or through the corresponding API using the [`config`](/api/config/config-property) property.

docs/guides/working-with-data.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ widget.api.intercept("add-field", (ev) => {
312312

313313
To add a custom method, use the [`methods`](/api/config/methods-property) property by setting the `key` parameter value to the method name and the `value` parameter should be a function that defines how a method should process data. The function should take an array of numerical values as an input and return a single numerical value.
314314

315-
The example below shows how to calculate the count of unique and average values for the date type. The **countUnique** function takes an array of numbers (values) as an input and calculates the exact count of unique values using the **reduce** method. The **countunique_date** sub-property has a handler with a function that get the unique values from an array of the date values. The **average_date** sub-property has a handler that calculates the average values from an array of the date values.
315+
The example below shows how to calculate the count of unique and average values for the date type. The **countUnique** function takes an array of numbers (values) as an input and calculates the exact count of unique values using the **reduce** method. The **countunique_date** sub-property has a handler with a function that gets the unique values from an array of the date values. The **average_date** sub-property has a handler that calculates the average values from an array of the date values.
316316

317317
~~~jsx {}
318318
function countUnique(values, converter) {
@@ -460,6 +460,46 @@ const widget = new pivot.Pivot("#pivot", {
460460
});
461461
~~~
462462

463+
## Adding columns and rows with total values
464+
465+
To enable generating the rightmost column with total values, apply the [`tableShape`](/api/config/tableshape-property) property and set the value of the `totalColumn` parameter to **true**.
466+
467+
To enable generating the footer with totals, apply the [`tableShape`](/api/config/tableshape-property)property and set the value of the `totalRow` parameter to **true**.
468+
469+
Example:
470+
471+
~~~jsx {2-5}
472+
const widget = new pivot.Pivot("#pivot", {
473+
tableShape: {
474+
totalRow: true,
475+
totalColumn: true,
476+
},
477+
fields,
478+
data,
479+
config: {
480+
rows: ["studio"],
481+
columns: ["type"],
482+
values: [
483+
{
484+
field: "score",
485+
method: "max",
486+
},
487+
{
488+
field: "episodes",
489+
method: "count",
490+
},
491+
{
492+
field: "rank",
493+
method: "min",
494+
},
495+
{
496+
field: "members",
497+
method: "sum",
498+
},
499+
],
500+
},
501+
});
502+
~~~
463503

464504
## Example
465505

0 commit comments

Comments
 (0)