Skip to content

Commit

Permalink
[update] working with data updated, id changed to field
Browse files Browse the repository at this point in the history
  • Loading branch information
tbshag2 committed Jun 17, 2024
1 parent e78aad9 commit d6f24c3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 44 deletions.
16 changes: 7 additions & 9 deletions docs/api/config/predicates-property.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ The following default predicates are applied in case no predicate is specified v

~~~jsx
const defaultPredicates = {
$empty: {
label: (v: any, type: any) => `raw ${type}`,
type: ["number", "date", "text"],
},
year: { label: "year", type: "date" },
month: { label: "month", type: "date" },
day: { label: "day", type: "date" },
hour: { label: "hour", type: "date" },
minute: { label: "minute", type: "date" },
year: { label: "Year", type: "date" },
quarter: { label: "Quarter", type: "date" },
month: { label: "Month", type: "date" },
week: { label: "Week", type: "date" },
day: { label: "Day", type: "date" },
hour: { label: "Hour", type: "date" },
minute: { label: "Minute", type: "date" },
};
~~~

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ const pivotWidget = new pivot.Pivot("#pivot", {
columns: [],
values: [
{
id: "title",
field: "title",
method: "count",
},
{
id: "score",
field: "score",
method: "max",
},
],
Expand Down
10 changes: 5 additions & 5 deletions docs/guides/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const widget = new pivot.Pivot("#pivot", {
columns: [],
values: [
{
id: "title",
field: "title",
method: "count",
},
{
id: "score",
field: "score",
method: "max",
},
{
id: "price",
field: "price",
method: "count",
},
],
Expand All @@ -63,11 +63,11 @@ const pivotWidget = new pivot.Pivot("#pivot", {
columns: [],
values: [
{
id: "title",
field: "title",
method: "count",
},
{
id: "score",
field: "score",
method: "max",
},
],
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ new pivot.Pivot({

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

<iframe src="https://snippet.dhtmlx.com/aj5zmxpv" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
<iframe src="https://snippet.dhtmlx.com/aj5zmxpv?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
4 changes: 2 additions & 2 deletions docs/guides/stylization.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ const pivotWidget = new pivot.Pivot("#pivot", {
columns: [],
values: [
{
id: "title",
field: "title",
method: "count",
},
{
id: "score",
field: "score",
method: "max",
},
],
Expand Down
40 changes: 15 additions & 25 deletions docs/guides/working-with-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -636,40 +636,30 @@ const widget = new pivot.Pivot("#pivot", {
## Processing data with predicates

Predicates or data modifiers allow you to process data in the required way before this data is used as rows or columns.
For example, you can pre-process the date format before applying and displaying data.
For example, you can pre-process the date format before applying and displaying data. The following predicates are applied by default:

To add a predicate, you should specify the parameters of the [`predicates`](/api/config/predicates-property) property:
~~~jsx
const defaultPredicates = {
year: { label: "Year", type: "date" },
quarter: { label: "Quarter", type: "date" },
month: { label: "Month", type: "date" },
week: { label: "Week", type: "date" },
day: { label: "Day", type: "date" },
hour: { label: "Hour", type: "date" },
minute: { label: "Minute", type: "date" },
};
~~~

To add a custom predicate, you should specify the parameters of the [`predicates`](/api/config/predicates-property) property:
- Add keys that are predicate IDs
- Add values that are objects with predicate configuration:
- add a label that will be displayed in GUI in the drop-down among data modifiers options for a row/column
- for the custom predicate, add the `handler` function that defines how data should be processed; the function takes a single argument as the value to be processed and returns the processed value.
- if you want the data to be displayed in the way other than the `handler` function returns, add the template that defines how data should be displayed (optional)
- add the `filter` function if necessary
- if necessary, add the `filter` function to specify how data should be filtered for the field

You should also add the predicate id as the value of the `method` parameter for the row/column where this predicate should be applied.

The following default predicates are applied:

~~~jsx
const predicates = {
$empty: {
label: (v: any, type: any) => `(${type})`,
type: ["number", "date", "text"],
},
year: { label: "year", type: "date" },
month: { label: "month", type: "date" },
day: { label: "day", type: "date" },
hour: { label: "hour", type: "date" },
minute: { label: "minute", type: "date" },
};
~~~


TBD!!!
:::note
If no custom predicate is set, for the **date** type the default *$empty* template is applied where the value of the `dateToString` parameter of the [`tableShape`](/api/properties/tableshape-property) property is taken and depends on the current locale.
:::

~~~jsx
// custom predicate
const predicates = {
Expand Down

0 comments on commit d6f24c3

Please sign in to comment.