From d6f24c3c9a6abdca13e829de0e0ef219fbdd525e Mon Sep 17 00:00:00 2001 From: tbshag2 Date: Mon, 17 Jun 2024 13:32:11 +0300 Subject: [PATCH] [update] working with data updated, id changed to field --- docs/api/config/predicates-property.md | 16 +++++------ docs/guides/configuration.md | 4 +-- docs/guides/customization.md | 10 +++---- docs/guides/localization.md | 2 +- docs/guides/stylization.md | 4 +-- docs/guides/working-with-data.md | 40 ++++++++++---------------- 6 files changed, 32 insertions(+), 44 deletions(-) diff --git a/docs/api/config/predicates-property.md b/docs/api/config/predicates-property.md index 5758173..71ad493 100644 --- a/docs/api/config/predicates-property.md +++ b/docs/api/config/predicates-property.md @@ -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" }, }; ~~~ diff --git a/docs/guides/configuration.md b/docs/guides/configuration.md index fee552f..ed4230c 100644 --- a/docs/guides/configuration.md +++ b/docs/guides/configuration.md @@ -90,11 +90,11 @@ const pivotWidget = new pivot.Pivot("#pivot", { columns: [], values: [ { - id: "title", + field: "title", method: "count", }, { - id: "score", + field: "score", method: "max", }, ], diff --git a/docs/guides/customization.md b/docs/guides/customization.md index b61295e..a7f2ef2 100644 --- a/docs/guides/customization.md +++ b/docs/guides/customization.md @@ -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", }, ], @@ -63,11 +63,11 @@ const pivotWidget = new pivot.Pivot("#pivot", { columns: [], values: [ { - id: "title", + field: "title", method: "count", }, { - id: "score", + field: "score", method: "max", }, ], diff --git a/docs/guides/localization.md b/docs/guides/localization.md index 0a9d2f7..133f824 100644 --- a/docs/guides/localization.md +++ b/docs/guides/localization.md @@ -156,4 +156,4 @@ new pivot.Pivot({ In this snippet you can see how to switch between several locales: - + diff --git a/docs/guides/stylization.md b/docs/guides/stylization.md index 32d630b..69f0cbe 100644 --- a/docs/guides/stylization.md +++ b/docs/guides/stylization.md @@ -118,11 +118,11 @@ const pivotWidget = new pivot.Pivot("#pivot", { columns: [], values: [ { - id: "title", + field: "title", method: "count", }, { - id: "score", + field: "score", method: "max", }, ], diff --git a/docs/guides/working-with-data.md b/docs/guides/working-with-data.md index fcdbfa2..079add4 100644 --- a/docs/guides/working-with-data.md +++ b/docs/guides/working-with-data.md @@ -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 = {