Back to homepage

Setting data types (Vue)

By default, WebDataRocks can auto-detect basic data types such as strings, numbers, and dates, but you can use all available data types to enrich your visualization. To set types explicitly, use the metadata object in JSON or data type prefixes in CSV.

After setting field data types, see the guides about connecting to the JSON or connecting to the CSV data.

Available data types

The following data types are available in WebDataRocks:

Number

This field type is used to store numbers.

Available aggregations: all.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "number":

"Price": {
"type": "number"
}

Read how to specify number fields in JSON data.

CSV

Add the - data type prefix to the field name.

Here is an example of CSV data with the Quantity number (-) field:

-Quantity, Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify number fields in CSV data.

String

This field type is used to store strings.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "string":

"Product": {
"type": "string"
}

Read how to specify string fields in JSON data.

CSV

Add the + data type prefix to the field name.

Here is an example of CSV data with the Product string (+) field:

Quantity, +Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify string fields in CSV data.

Date

WebDataRocks offers a wide range of date types. Review the options in this section to select the most suitable one.

 Read how to specify date fields in JSON or CSV data.

Year, Month, Day subfields

The date is divided into 3 string subfields: Year, Month, Day.

This is the default format for all date fields unless a different type is specified in the metadata object or prefixes.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date":

"Date": {
"type": "date"
}

See the example.

CSV

Add the d+ data type prefix to the field name:

d+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

Year > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/month/day":

"Date": {
"type": "year/month/day"
}

See the example.

CSV

Add the D+ data type prefix to the field name:

D+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

Year > Quarter > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Quarter > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/quarter/month/day":

"Date": {
"type": "year/quarter/month/day"
}

CSV

Add the D4+ data type prefix to the field name:

D4+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

“dd/MM/yyyy” format

The date is displayed as a string in the "dd/MM/yyyy" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the datePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date string":

"Date": {
"type": "date string"
}

CSV

Add the ds+ data type prefix to the field name:

ds+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

“dd/MM/yyyy HH:mm:ss” format

The date is displayed as a string in the "dd/MM/yyyy HH:mm:ss" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the dateTimePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "datetime":

"Date": {
"type": "datetime"
}

See the example.

CSV

Add the dt+ data type prefix to the field name:

dt+Invoice Date, Price, Country
2018-05-15T18:30:00, 329, France
2018-05-16T06:20:00, 139, Italy
2018-05-17T13:45:00, 429, Spain
2018-05-12T04:50:00, 559, Japan

Time

This field type is used to store time intervals, such as duration.

Available aggregations: Min, Max, Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "time":

"Duration": {
"type": "time"
}

See the example.

Read how to specify time fields in JSON data.

CSV

Add the t+ data type prefix to the field name.

Here is an example of CSV data with the Duration time (t+) field:

t+Duration, Movie, ReleaseYears
7020, Blade Runner, 1980-1990
5220, The Lion King, 1990-2000
7560, Jurassic Park, 1990-2000
9120, The Dark Knight, 2000-2010

Read how to specify time fields in CSV data.

Month

Fields of this type store months. Natural sorting is applied to the field members: from January to December.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "month":

"Month": {
"type": "month"
}

Read how to specify month fields in JSON data.

CSV

Add the m+ data type prefix to the field name.

Here is an example of CSV data with the Month month (m+) field:

m+Month, Price, Country
Apr, 329, France
Feb, 139, Italy
Jan, 429, Spain
Dec, 559, Japan

Read how to specify month fields in CSV data.

Weekday

Fields of this type store the days of the week. Natural sorting is applied to the field members: from Sunday to Monday.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "weekday":

"Week Day": {
"type": "weekday"
}

Read how to specify weekday fields in JSON data.

CSV

Add the w+ data type prefix to the field name.

Here is an example of CSV data with the Week Day weekday (w+) field:

w+Week Day, Quantity, Country
Tuesday, 3, France
Wednesday, 4, Italy
Thursday, 2, Spain
Saturday, 2, Japan

Read how to specify weekday fields in CSV data.

Level (only for JSON)

This field type means that a field is a level of a multilevel hierarchy.

To mark the field as a hierarchy level, set the type property of the field’s metadata object to "level".

Available aggregations: none.

See the example.

Hidden (only for JSON)

This field type is used to hide fields from the report.

To mark the field as hidden, set the type property of the field’s metadata object to "hidden".

Available aggregations: none.

Note. Another way to hide fields from the report is to exclude them from the metadata object.

Automatic type detection

If you exclude the field’s type in JSON metadata object or CSV prefixes, the component detects the data type based on the field’s first value. The following data types can be auto-detected:

See the example of automatic type detection in JSON.

The results of the automatic detection may be unexpected when:

  • The first field value is null. In this case, the field type cannot be detected automatically.
  • The first field value is formatted differently from other values. For example, the first value is a number while the others are strings.
  • Field values are not formatted correctly. For example, a number was specified in hexadecimal form instead of decimal.
  • Field values may be confused with values of other types. For example, time values are processed as numbers if the "time" type is not explicitly specified.

See also

By default, WebDataRocks can auto-detect basic data types such as strings, numbers, and dates, but you can use all available data types to enrich your visualization. To set types explicitly, use the metadata object in JSON or data type prefixes in CSV.

After setting field data types, see the guides about connecting to the JSON or connecting to the CSV data.

Available data types

The following data types are available in WebDataRocks:

Number

This field type is used to store numbers.

Available aggregations: all.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "number":

"Price": {
"type": "number"
}

Read how to specify number fields in JSON data.

CSV

Add the - data type prefix to the field name.

Here is an example of CSV data with the Quantity number (-) field:

-Quantity, Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify number fields in CSV data.

String

This field type is used to store strings.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "string":

"Product": {
"type": "string"
}

Read how to specify string fields in JSON data.

CSV

Add the + data type prefix to the field name.

Here is an example of CSV data with the Product string (+) field:

Quantity, +Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify string fields in CSV data.

Date

WebDataRocks offers a wide range of date types. Review the options in this section to select the most suitable one.

 Read how to specify date fields in JSON or CSV data.

Year, Month, Day subfields

The date is divided into 3 string subfields: Year, Month, Day.

This is the default format for all date fields unless a different type is specified in the metadata object or prefixes.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date":

"Date": {
"type": "date"
}

See the example.

CSV

Add the d+ data type prefix to the field name:

d+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

Year > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/month/day":

"Date": {
"type": "year/month/day"
}

See the example.

CSV

Add the D+ data type prefix to the field name:

D+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

Year > Quarter > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Quarter > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/quarter/month/day":

"Date": {
"type": "year/quarter/month/day"
}

CSV

Add the D4+ data type prefix to the field name:

D4+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

“dd/MM/yyyy” format

The date is displayed as a string in the "dd/MM/yyyy" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the datePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date string":

"Date": {
"type": "date string"
}

CSV

Add the ds+ data type prefix to the field name:

ds+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

“dd/MM/yyyy HH:mm:ss” format

The date is displayed as a string in the "dd/MM/yyyy HH:mm:ss" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the dateTimePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "datetime":

"Date": {
"type": "datetime"
}

See the example.

CSV

Add the dt+ data type prefix to the field name:

dt+Invoice Date, Price, Country
2018-05-15T18:30:00, 329, France
2018-05-16T06:20:00, 139, Italy
2018-05-17T13:45:00, 429, Spain
2018-05-12T04:50:00, 559, Japan

Time

This field type is used to store time intervals, such as duration.

Available aggregations: Min, Max, Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "time":

"Duration": {
"type": "time"
}

See the example.

Read how to specify time fields in JSON data.

CSV

Add the t+ data type prefix to the field name.

Here is an example of CSV data with the Duration time (t+) field:

t+Duration, Movie, ReleaseYears
7020, Blade Runner, 1980-1990
5220, The Lion King, 1990-2000
7560, Jurassic Park, 1990-2000
9120, The Dark Knight, 2000-2010

Read how to specify time fields in CSV data.

Month

Fields of this type store months. Natural sorting is applied to the field members: from January to December.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "month":

"Month": {
"type": "month"
}

Read how to specify month fields in JSON data.

CSV

Add the m+ data type prefix to the field name.

Here is an example of CSV data with the Month month (m+) field:

m+Month, Price, Country
Apr, 329, France
Feb, 139, Italy
Jan, 429, Spain
Dec, 559, Japan

Read how to specify month fields in CSV data.

Weekday

Fields of this type store the days of the week. Natural sorting is applied to the field members: from Sunday to Monday.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "weekday":

"Week Day": {
"type": "weekday"
}

Read how to specify weekday fields in JSON data.

CSV

Add the w+ data type prefix to the field name.

Here is an example of CSV data with the Week Day weekday (w+) field:

w+Week Day, Quantity, Country
Tuesday, 3, France
Wednesday, 4, Italy
Thursday, 2, Spain
Saturday, 2, Japan

Read how to specify weekday fields in CSV data.

Level (only for JSON)

This field type means that a field is a level of a multilevel hierarchy.

To mark the field as a hierarchy level, set the type property of the field’s metadata object to "level".

Available aggregations: none.

See the example.

Hidden (only for JSON)

This field type is used to hide fields from the report.

To mark the field as hidden, set the type property of the field’s metadata object to "hidden".

Available aggregations: none.

Note. Another way to hide fields from the report is to exclude them from the metadata object.

Automatic type detection

If you exclude the field’s type in JSON metadata object or CSV prefixes, the component detects the data type based on the field’s first value. The following data types can be auto-detected:

See the example of automatic type detection in JSON.

The results of the automatic detection may be unexpected when:

  • The first field value is null. In this case, the field type cannot be detected automatically.
  • The first field value is formatted differently from other values. For example, the first value is a number while the others are strings.
  • Field values are not formatted correctly. For example, a number was specified in hexadecimal form instead of decimal.
  • Field values may be confused with values of other types. For example, time values are processed as numbers if the "time" type is not explicitly specified.

See also

By default, WebDataRocks can auto-detect basic data types such as strings, numbers, and dates, but you can use all available data types to enrich your visualization. To set types explicitly, use the metadata object in JSON or data type prefixes in CSV.

After setting field data types, see the guides about connecting to the JSON or connecting to the CSV data.

Available data types

The following data types are available in WebDataRocks:

Number

This field type is used to store numbers.

Available aggregations: all.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "number":

"Price": {
"type": "number"
}

Read how to specify number fields in JSON data.

CSV

Add the - data type prefix to the field name.

Here is an example of CSV data with the Quantity number (-) field:

-Quantity, Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify number fields in CSV data.

String

This field type is used to store strings.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "string":

"Product": {
"type": "string"
}

Read how to specify string fields in JSON data.

CSV

Add the + data type prefix to the field name.

Here is an example of CSV data with the Product string (+) field:

Quantity, +Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify string fields in CSV data.

Date

WebDataRocks offers a wide range of date types. Review the options in this section to select the most suitable one.

 Read how to specify date fields in JSON or CSV data.

Year, Month, Day subfields

The date is divided into 3 string subfields: Year, Month, Day.

This is the default format for all date fields unless a different type is specified in the metadata object or prefixes.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date":

"Date": {
"type": "date"
}

See the example.

CSV

Add the d+ data type prefix to the field name:

d+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

Year > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/month/day":

"Date": {
"type": "year/month/day"
}

See the example.

CSV

Add the D+ data type prefix to the field name:

D+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

Year > Quarter > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Quarter > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/quarter/month/day":

"Date": {
"type": "year/quarter/month/day"
}

CSV

Add the D4+ data type prefix to the field name:

D4+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

“dd/MM/yyyy” format

The date is displayed as a string in the "dd/MM/yyyy" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the datePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date string":

"Date": {
"type": "date string"
}

CSV

Add the ds+ data type prefix to the field name:

ds+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

“dd/MM/yyyy HH:mm:ss” format

The date is displayed as a string in the "dd/MM/yyyy HH:mm:ss" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the dateTimePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "datetime":

"Date": {
"type": "datetime"
}

See the example.

CSV

Add the dt+ data type prefix to the field name:

dt+Invoice Date, Price, Country
2018-05-15T18:30:00, 329, France
2018-05-16T06:20:00, 139, Italy
2018-05-17T13:45:00, 429, Spain
2018-05-12T04:50:00, 559, Japan

Time

This field type is used to store time intervals, such as duration.

Available aggregations: Min, Max, Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "time":

"Duration": {
"type": "time"
}

See the example.

Read how to specify time fields in JSON data.

CSV

Add the t+ data type prefix to the field name.

Here is an example of CSV data with the Duration time (t+) field:

t+Duration, Movie, ReleaseYears
7020, Blade Runner, 1980-1990
5220, The Lion King, 1990-2000
7560, Jurassic Park, 1990-2000
9120, The Dark Knight, 2000-2010

Read how to specify time fields in CSV data.

Month

Fields of this type store months. Natural sorting is applied to the field members: from January to December.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "month":

"Month": {
"type": "month"
}

Read how to specify month fields in JSON data.

CSV

Add the m+ data type prefix to the field name.

Here is an example of CSV data with the Month month (m+) field:

m+Month, Price, Country
Apr, 329, France
Feb, 139, Italy
Jan, 429, Spain
Dec, 559, Japan

Read how to specify month fields in CSV data.

Weekday

Fields of this type store the days of the week. Natural sorting is applied to the field members: from Sunday to Monday.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "weekday":

"Week Day": {
"type": "weekday"
}

Read how to specify weekday fields in JSON data.

CSV

Add the w+ data type prefix to the field name.

Here is an example of CSV data with the Week Day weekday (w+) field:

w+Week Day, Quantity, Country
Tuesday, 3, France
Wednesday, 4, Italy
Thursday, 2, Spain
Saturday, 2, Japan

Read how to specify weekday fields in CSV data.

Level (only for JSON)

This field type means that a field is a level of a multilevel hierarchy.

To mark the field as a hierarchy level, set the type property of the field’s metadata object to "level".

Available aggregations: none.

See the example.

Hidden (only for JSON)

This field type is used to hide fields from the report.

To mark the field as hidden, set the type property of the field’s metadata object to "hidden".

Available aggregations: none.

Note. Another way to hide fields from the report is to exclude them from the metadata object.

Automatic type detection

If you exclude the field’s type in JSON metadata object or CSV prefixes, the component detects the data type based on the field’s first value. The following data types can be auto-detected:

See the example of automatic type detection in JSON.

The results of the automatic detection may be unexpected when:

  • The first field value is null. In this case, the field type cannot be detected automatically.
  • The first field value is formatted differently from other values. For example, the first value is a number while the others are strings.
  • Field values are not formatted correctly. For example, a number was specified in hexadecimal form instead of decimal.
  • Field values may be confused with values of other types. For example, time values are processed as numbers if the "time" type is not explicitly specified.

See also

By default, WebDataRocks can auto-detect basic data types such as strings, numbers, and dates, but you can use all available data types to enrich your visualization. To set types explicitly, use the metadata object in JSON or data type prefixes in CSV.

After setting field data types, see the guides about connecting to the JSON or connecting to the CSV data.

Available data types

The following data types are available in WebDataRocks:

Number

This field type is used to store numbers.

Available aggregations: all.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "number":

"Price": {
"type": "number"
}

Read how to specify number fields in JSON data.

CSV

Add the - data type prefix to the field name.

Here is an example of CSV data with the Quantity number (-) field:

-Quantity, Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify number fields in CSV data.

String

This field type is used to store strings.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "string":

"Product": {
"type": "string"
}

Read how to specify string fields in JSON data.

CSV

Add the + data type prefix to the field name.

Here is an example of CSV data with the Product string (+) field:

Quantity, +Product
3, Cars
4, Bikes
2, Components
2, Bikes

Read how to specify string fields in CSV data.

Date

WebDataRocks offers a wide range of date types. Review the options in this section to select the most suitable one.

 Read how to specify date fields in JSON or CSV data.

Year, Month, Day subfields

The date is divided into 3 string subfields: Year, Month, Day.

This is the default format for all date fields unless a different type is specified in the metadata object or prefixes.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date":

"Date": {
"type": "date"
}

See the example.

CSV

Add the d+ data type prefix to the field name:

d+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

Year > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/month/day":

"Date": {
"type": "year/month/day"
}

See the example.

CSV

Add the D+ data type prefix to the field name:

D+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

Year > Quarter > Month > Day multilevel hierarchy

The date is represented as a multilevel hierarchy: Year > Quarter > Month > Day.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "year/quarter/month/day":

"Date": {
"type": "year/quarter/month/day"
}

CSV

Add the D4+ data type prefix to the field name:

D4+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

See the example.

“dd/MM/yyyy” format

The date is displayed as a string in the "dd/MM/yyyy" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the datePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "date string":

"Date": {
"type": "date string"
}

CSV

Add the ds+ data type prefix to the field name:

ds+Invoice Date, Quantity, Country
2018-05-15, 3, France
2018-05-16, 4, Italy
2018-05-17, 2, Spain
2018-05-12, 2, Japan

“dd/MM/yyyy HH:mm:ss” format

The date is displayed as a string in the "dd/MM/yyyy HH:mm:ss" format.

Available aggregations: Min, Max, Count, Distinct Count.

The format can be changed using the dateTimePattern option.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "datetime":

"Date": {
"type": "datetime"
}

See the example.

CSV

Add the dt+ data type prefix to the field name:

dt+Invoice Date, Price, Country
2018-05-15T18:30:00, 329, France
2018-05-16T06:20:00, 139, Italy
2018-05-17T13:45:00, 429, Spain
2018-05-12T04:50:00, 559, Japan

Time

This field type is used to store time intervals, such as duration.

Available aggregations: Min, Max, Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "time":

"Duration": {
"type": "time"
}

See the example.

Read how to specify time fields in JSON data.

CSV

Add the t+ data type prefix to the field name.

Here is an example of CSV data with the Duration time (t+) field:

t+Duration, Movie, ReleaseYears
7020, Blade Runner, 1980-1990
5220, The Lion King, 1990-2000
7560, Jurassic Park, 1990-2000
9120, The Dark Knight, 2000-2010

Read how to specify time fields in CSV data.

Month

Fields of this type store months. Natural sorting is applied to the field members: from January to December.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "month":

"Month": {
"type": "month"
}

Read how to specify month fields in JSON data.

CSV

Add the m+ data type prefix to the field name.

Here is an example of CSV data with the Month month (m+) field:

m+Month, Price, Country
Apr, 329, France
Feb, 139, Italy
Jan, 429, Spain
Dec, 559, Japan

Read how to specify month fields in CSV data.

Weekday

Fields of this type store the days of the week. Natural sorting is applied to the field members: from Sunday to Monday.

Available aggregations: Count, Distinct Count.

See how to set this type for a field in your data source:

JSON

Set the type property of the field’s metadata object to "weekday":

"Week Day": {
"type": "weekday"
}

Read how to specify weekday fields in JSON data.

CSV

Add the w+ data type prefix to the field name.

Here is an example of CSV data with the Week Day weekday (w+) field:

w+Week Day, Quantity, Country
Tuesday, 3, France
Wednesday, 4, Italy
Thursday, 2, Spain
Saturday, 2, Japan

Read how to specify weekday fields in CSV data.

Level (only for JSON)

This field type means that a field is a level of a multilevel hierarchy.

To mark the field as a hierarchy level, set the type property of the field’s metadata object to "level".

Available aggregations: none.

See the example.

Hidden (only for JSON)

This field type is used to hide fields from the report.

To mark the field as hidden, set the type property of the field’s metadata object to "hidden".

Available aggregations: none.

Note. Another way to hide fields from the report is to exclude them from the metadata object.

Automatic type detection

If you exclude the field’s type in JSON metadata object or CSV prefixes, the component detects the data type based on the field’s first value. The following data types can be auto-detected:

See the example of automatic type detection in JSON.

The results of the automatic detection may be unexpected when:

  • The first field value is null. In this case, the field type cannot be detected automatically.
  • The first field value is formatted differently from other values. For example, the first value is a number while the others are strings.
  • Field values are not formatted correctly. For example, a number was specified in hexadecimal form instead of decimal.
  • Field values may be confused with values of other types. For example, time values are processed as numbers if the "time" type is not explicitly specified.

See also

You can hide the spreadsheet headers with column and row numbers, which are displayed by default on the grid.

To hide column and row numbers

Set the grid.showHeaders property to false in the Options Object.

There are several ways to apply this setting, depending on whether the pivot table is configured during report initialization or at runtime:

On initialization

This approach is useful when you want spreadsheet headers to be hidden by default: 

report = {
options: {
grid: {
     showHeaders: false
    }
  }
};

At runtime

You can toggle the visibility of spreadsheet headers at runtime by using the setOptions() API call:

this.pivot.webdatarocks.setOptions({ grid: { showHeaders: false }});
this.pivot.webdatarocks.refresh();

Example

You can hide the spreadsheet headers with column and row numbers, which are displayed by default on the grid.

To hide column and row numbers

Set the grid.showHeaders property to false in the Options Object.

There are several ways to apply this setting, depending on whether the pivot table is configured during report initialization or at runtime:

On initialization

This approach is useful when you want spreadsheet headers to be hidden by default: 

const report = {
options: {
grid: {
     showHeaders: false
    }
  }
};

At runtime

You can toggle the visibility of spreadsheet headers at runtime by using the setOptions() API call:

this.$refs.pivot.webdatarocks.setOptions({ grid: { showHeaders: false }});
this.$refs.pivot.webdatarocks.refresh();

Example

You can hide the spreadsheet headers with column and row numbers, which are displayed by default on the grid.

To hide column and row numbers

Set the grid.showHeaders property to false in the Options Object.

There are several ways to apply this setting, depending on whether the pivot table is configured during report initialization or at runtime:

On initialization

This approach is useful when you want spreadsheet headers to be hidden by default: 

const report = {
options: {
grid: {
     showHeaders: false
    }
  }
};

At runtime

You can toggle the visibility of spreadsheet headers at runtime by using the setOptions() API call:

pivotRef.current?.webdatarocks.setOptions({ grid: { showHeaders: false }});
pivotRef.current?.webdatarocks.refresh();

Example

You can hide the spreadsheet headers with column and row numbers, which are displayed by default on the grid.

To hide column and row numbers

Set the grid.showHeaders property to false in the Options Object.

There are several ways to apply this setting, depending on whether the pivot table is configured during report initialization or at runtime:

On initialization

This approach is useful when you want spreadsheet headers to be hidden by default: 

report: {
options: {
grid: {
     showHeaders: false
    }
  }
}

At runtime

You can toggle the visibility of spreadsheet headers at runtime by using the setOptions() API call:

webdatarocks.setOptions({ grid: { showHeaders: false }});
webdatarocks.refresh();

Example

Open a live demo.

This tutorial explains how to connect WebDataRocks to a third-party charting library, such as Chart.js, ApexCharts, ECharts, or D3.js.

WebDataRocks can be integrated with charting libraries using the getData() API call, which returns data displayed on the grid. Then, you need to preprocess the data to a format required by your charting library and pass it to the chart.

In this tutorial, we will integrate with Chart.js, but the steps are similar for other libraries.

Note that if you are integrating with amCharts, Highcharts, FusionCharts, or Google Charts, use our ready-to-use connectors that will automatically process the data. Check out the list of available tutorials.

Step 1. Add WebDataRocks to your project

Step 1.1. Complete the integration guide. Your code of the component with WebDatarocks should look similar to the following:

<script setup>
import { Pivot } from "@webdatarocks/vue-webdatarocks";
import "@webdatarocks/webdatarocks/webdatarocks.css";
</script>

<template>
<div>
<Pivot
toolbar
/>
</div>
</template>

Step 1.2. Create a report for WebDataRocks — connect to the data source and define which fields should be displayed in rows, columns, and measures:

<script setup>
import { Pivot } from "@webdatarocks/vue-webdatarocks";
import "@webdatarocks/webdatarocks/webdatarocks.css";

const report = {
dataSource: {
filename: "https://cdn.webdatarocks.com/data/data.csv",
},
slice: {
rows: [
{
uniqueName: "Country",
},
],
columns: [
{
uniqueName: "Measures",
},
],
measures: [
{
uniqueName: "Price",
aggregation: "sum",
},
],
},
};
</script>

<template>
<div>
<Pivot
toolbar
v-bind:report="report"
/>
</div>
</template>

The fields you’ve specified in the report will be shown on the chart.

Step 2. Get a reference to the WebDataRocks instance

Some of WebDataRocks methods and events are needed to create a chart. Using a reference to the WebDataRocks instance, we can access WebDataRocks API.

Get the reference as follows:

<script setup>
// ...
import { ref } from "vue";

const pivotRef = ref(null);

// ...
</script>

<template>
<div>
<Pivot
ref="pivotRef"
toolbar
v-bind:report="report"
/>
</template>

Now it’s possible to interact with the component through pivotRef.value.webdatarocks.

Step 3. Add a charting library

Note that this tutorial integrates WebDataRocks with Chart.js. The following steps may vary depending on your charting library.

Step 3.1. Install the npm package with your charting library. For example:

npm install vue-chartjs

Step 3.2. Import the charting library into your component:

import { PolarArea } from "vue-chartjs";
import {
Chart as ChartJS,
RadialLinearScale,
ArcElement,
Tooltip,
Legend,
} from "chart.js";

ChartJS.register(RadialLinearScale, ArcElement, Tooltip, Legend);

Step 3.3. Add a container for your chart in the template of the component:

<PolarArea/>

Step 3.4. Create a reference to store the chart data:

const chartData = ref({
labels: [],
datasets: [
{
data: [],
},
],
});

We will pass the data from the component to chartData in step 4.3.

Step 3.5. Pass the chart data to the chart container:

<PolarArea v-bind:data="chartData" />

Step 4. Integrate WebDataRocks with the charting library

In this step, we will use the getData() API call. This method was added especially for integration with third-part charting libraries; using it, you can request data from WebDataRocks and pass it to a charting library.

Step 4.1. If we call the getData() method before WebDataRocks is fully loaded, it will return an empty result. To know when WebDataRocks is ready to provide data for the chart, handle the reportcomplete event:

<script setup>
// ...

function reportComplete () {
// Unsubscribing from reportcomplete
// We need it only to track the initialization of WebDataRocks
pivotRef.value.webdatarocks.off("reportcomplete");
createChart();
}
</script>

<template>
<div>
<Pivot
ref="pivotRef"
toolbar
v-bind:report="report"
v-bind:reportcomplete="reportComplete"
/>
<PolarArea v-bind:data="chartData" />
</div>
</template>

Step 4.2. Implement the createChart() function using the getData() API call:

function createChart() {
if (pivotRef.value) {
pivotRef.value.webdatarocks.getData(
{},
// Function called when data for the chart is ready
drawChart,
// Function called on report changes (filtering, sorting, etc.)
drawChart
);
};
};

Step 4.3. Implement the drawChart() function specified in the previous step. This function will initialize the chart, set all the configurations specific to this chart type, and fill it with the data provided by WebDataRocks:

function drawChart(rawData) {
const { labels, values } = prepareData(rawData); // This function will be implemented in step 5

// Configuring the chart and filling it with data
chartData.value = {
labels: labels,
datasets: [
{
data: values,
backgroundColor: [
"rgba(255, 99, 132, 0.5)",
"rgba(54, 162, 235, 0.5)",
"rgba(255, 206, 86, 0.5)",
"rgba(75, 192, 192, 0.5)",
"rgba(153, 102, 255, 0.5)",
"rgba(255, 159, 64, 0.5)",
],
},
],
};
};

Step 5. Prepare the data

getData() API call returns an object (e.g., rawData) that contains the data from the grid and its metadata. The metadata includes a number of fields in rows and columns in the slice, an array of format objects, etc. Read more about the getData() response.

Here is an example of the rawData.data array returned by getData(). This data is based on the slice that was defined in the step 1.2:

data: [
{ v0: 6221870 }, // Grand total
{ r0: "Australia", v0: 1372281 },
{ r0: "France", v0: 1117794 },
{ r0: "Germany", v0: 1070453 },
{ r0: "Canada", v0: 1034112 },
{ r0: "United States", v0: 847331 },
{ r0: "United Kingdom", v0: 779899 }
]

This raw data now must be transformed to match the data format required by your charting library, in our case — Chart.js. Let’s create a function that will preprocess the data, for example, prepareData().

We are passing data to the data.labels and data.datasets properties, where data.labels contains field members and data.datasets contains values. Read more in the Chart.js documentation.

The prepareData() function for Chart.js will look similar to the following:

const prepareData = (rawData) => {
const labels = rawData.data.filter((rec) => rec.r0 && rec.v0).map((rec) => rec.r0);
const values = rawData.data.filter((rec) => rec.r0 && rec.v0).map((rec) => rec.v0);

return { labels, values };
};

prepareData() must return an object with the data that can be used by your charting library. The example shows the returned object for Chart.js:

{ 
labels: ["Australia", "France", "Germany", "Canada", "United States", "United Kingdom"],
values: [1372281, 1117794, 1070453, 1034112, 847331, 779899]
}

Step 6. Run the project

Run your project with the following command:

npm run dev

Open http://localhost:5173/ in the browser to see how the pivot table looks in combination with Chart.js.

Try filtering the data, changing measures, and adjusting aggregation functions — the chart will be updated at once.

Check out the full code

After completing this tutorial, the full code of the integration should look as follows:

<script setup>
import { Pivot } from "@webdatarocks/vue-webdatarocks";
import "@webdatarocks/webdatarocks/webdatarocks.css";
import { ref } from "vue";

import { PolarArea } from "vue-chartjs";
import {
Chart as ChartJS,
RadialLinearScale,
ArcElement,
Tooltip,
Legend,
} from "chart.js";

ChartJS.register(RadialLinearScale, ArcElement, Tooltip, Legend);

const pivotRef = ref(null);

const chartData = ref({
labels: [],
datasets: [
{
data: [],
},
],
});

const report = {
dataSource: {
filename: "https://cdn.webdatarocks.com/data/data.csv",
},
slice: {
rows: [
{
uniqueName: "Country",
},
],
columns: [
{
uniqueName: "Measures",
},
],
measures: [
{
uniqueName: "Price",
aggregation: "sum",
},
],
},
};

function reportComplete () {
// Unsubscribing from reportcomplete
// We need it only to track the initialization of WebDataRocks
pivotRef.value.webdatarocks.off("reportcomplete");
createChart();
};

function createChart() {
if (pivotRef.value) {
pivotRef.value.webdatarocks.getData(
{},
drawChart,
drawChart
);
};
};

function drawChart(rawData) {
const { labels, values } = prepareDataFunction(rawData);

chartData.value = {
labels: labels,
datasets: [
{
data: values,
backgroundColor: [
"rgba(255, 99, 132, 0.5)",
"rgba(54, 162, 235, 0.5)",
"rgba(255, 206, 86, 0.5)",
"rgba(75, 192, 192, 0.5)",
"rgba(153, 102, 255, 0.5)",
"rgba(255, 159, 64, 0.5)",
],
},
],
};
};

const prepareDataFunction = (rawData) => {
const labels = rawData.data.filter((rec) => rec.r0 && rec.v0).map((rec) => rec.r0);
const values = rawData.data.filter((rec) => rec.r0 && rec.v0).map((rec) => rec.v0);

return { labels, values };
};
</script>

<template>
<div>
<Pivot
ref="pivotRef"
toolbar
v-bind:report="report"
v-bind:reportcomplete="reportComplete"
/>
<PolarArea v-bind:data="chartData" />
</div>
</template>

See also

This tutorial explains how to connect WebDataRocks to a third-party charting library, such as Chart.js, ApexCharts, ECharts, or D3.js.

WebDataRocks can be integrated with charting libraries using the getData() API call, which returns data displayed on the grid. Then, you need to preprocess the data to a format required by your charting library and pass it to the chart.

In this tutorial, we will integrate with Chart.js, but the steps are similar for other libraries.

Note that if you are integrating with amCharts, Highcharts, FusionCharts, or Google Charts, use our ready-to-use connectors that will automatically process the data. Check out the list of available tutorials.

Step 1. Add WebDataRocks to your project

Step 1.1. Complete the integration guide. Your code of the component with WebDatarocks should look similar to the following:

    import { Component } from "@angular/core";
    import { WebdatarocksPivotModule } from "@webdatarocks/ngx-webdatarocks";
    
    @Component({
      selector: "app-root",
      standalone: true,
      imports: [WebdatarocksPivotModule],
      templateUrl: "./app.component.html",
      styleUrls: ["./app.component.css"]
    })
    export class AppComponent {
    }
    <app-wbr-pivot
     [toolbar]="true">
    </app-wbr-pivot>

    Step 1.2. Create a report for WebDataRocks — connect to the data source and define which fields should be displayed in rows, columns, and measures:

      import { Component } from "@angular/core";
      import { WebdatarocksPivotModule } from "@webdatarocks/ngx-webdatarocks";
      
      @Component({
        selector: "app-root",
        standalone: true,
        imports: [WebdatarocksPivotModule],
        templateUrl: "./app.component.html",
        styleUrls: ["./app.component.css"]
      })
      export class AppComponent {
        report = {
          dataSource: {
            filename: "https://cdn.webdatarocks.com/data/data.csv",
          },
          slice: {
            rows: [
              {
                uniqueName: "Country",
              },
            ],
            columns: [
              {
                uniqueName: "Measures",
              },
            ],
            measures: [
              {
                uniqueName: "Price",
                aggregation: "sum",
              },
            ],
          },
        };
      }
      <app-wbr-pivot
       [toolbar]="true"
       [report]="report">
      </app-wbr-pivot>

      The fields you’ve specified in the report will be shown on the chart.

      Step 2. Get a reference to the WebDataRocks instance

      Some of WebDataRocks methods and events are needed to create a chart. Using a reference to the WebDataRocks instance, we can access WebDataRocks API.

      Import WebdatarocksComponent and get a reference to the <app-wbr-pivot> instance using a template variable and the @ViewChild decorator:

        import { Component, ViewChild } from "@angular/core";
        import { WebdatarocksPivotModule, WebdatarocksComponent } from "@webdatarocks/ngx-webdatarocks";
        
        @Component({
          selector: "app-root",
          standalone: true,
          imports: [WebdatarocksPivotModule],
          templateUrl: "./app.component.html",
          styleUrls: ["./app.component.css"]
        })
        export class AppComponent {
          @ViewChild("pivot") pivotRef!: WebdatarocksComponent;
        
          // ...
        }
        <app-wbr-pivot #pivot
         [toolbar]="true"
         [report]="report">
        </app-wbr-pivot>

        Now it’s possible to interact with the component through this.pivotRef.webdatarocks.

        Note. If you are using the legacy @webdatarocks/ng-webdatarocks wrapper, import WebdatarocksComponent from it.

        Step 3. Add a charting library

        Note that this tutorial integrates WebDataRocks with Chart.js. The following steps may vary depending on your charting library.

        Step 3.1. Install your charting library. For Chart.js, run the following commands in the console:

        npm install chart.js

        Step 3.2. Import your charting library into the component:

          import { Chart, ChartConfiguration, registerables } from 'chart.js';
          
          Chart.register(...registerables);

          Step 3.3. Add a <canvas> tag for your chart in the HTML template of the component:

            <app-wbr-pivot
              #pivot
              [toolbar]="true"
              [report]="report">
            </app-wbr-pivot>
            
            <canvas></canvas>

            Step 3.4. Get a reference to the <canvas> instance using a template variable and the @ViewChild decorator:

              import { Component, ViewChild, ElementRef } from "@angular/core";
              // ...
              
              @Component({
                selector: "app-root",
                standalone: true,
                imports: [WebdatarocksPivotModule],
                templateUrl: "./app.component.html",
                styleUrls: ["./app.component.css"],
              })
              export class AppComponent {
                @ViewChild("pivot") pivotRef!: WebdatarocksComponent;
                @ViewChild('chartCanvas') chartCanvas!: ElementRef;
              
                // ...
              }
              <canvas #chartCanvas></canvas>

              Step 3.5. Create a variable that will store a chart:

                chart!: Chart<"polarArea">;

                Step 4. Integrate WebDataRocks with the charting library

                In this step, we will use the getData() API call. This method was added especially for integration with third-part charting libraries; using it, you can request data from WebDataRocks and pass it to a charting library.

                Step 4.1. If we call the getData() method before WebDataRocks is fully loaded, it will return an empty result. To know when WebDataRocks is ready to provide data for the chart, handle the reportcomplete event:

                  onReportComplete() {
                    // Unsubscribing from reportcomplete
                    // We need it only to track the initialization of WebDataRocks
                    this.pivotRef.webDataRocks.off("reportComplete");
                    this.createChart();
                  };
                  <app-wbr-pivot
                    #pivot
                    [toolbar]="true"
                    [report]="report"
                    (reportcomplete)="onReportComplete()">
                  </app-wbr-pivot>

                  Step 4.2. Implement the createChart() function using the getData() API call:

                    createChart() {
                      this.pivotRef.webDataRocks.getData(
                        {}, 
                        // Function called when data for the chart is ready
                        this.drawChart.bind(this),
                        // Function called on report changes (filtering, sorting, etc.) 
                        this.drawChart.bind(this),
                      );
                    };

                    Step 4.3. Implement the drawChart() function specified in the previous step. This function will initialize the chart, set all the configurations specific to this chart type, and fill it with the data provided by WebDataRocks:

                      drawChart(rawData: any) {
                        const { labels, values } = this.prepareData(rawData); // This function will be implemented in step 5
                      
                        // Configuring the chart and filling it with data
                        const chartConfig: ChartConfiguration<'polarArea'> = {
                          type: 'polarArea',
                          data: {
                            labels: labels,
                            datasets: [
                              {
                                data: values,
                              },
                            ],
                          },
                        };
                      
                        if (this.chart) {
                          this.chart.destroy();
                        };
                      
                        // Creating a new chart instance
                        this.chart = new Chart(this.chartCanvas.nativeElement, chartConfig);
                      };

                      Step 5. Prepare the data

                      getData() API call returns an object (e.g., rawData) that contains the data from the grid and its metadata. The metadata includes a number of fields in rows and columns in the slice, an array of format objects, etc. Read more about the getData() response.

                      Here is an example of the rawData.data array returned by getData(). This data is based on the slice that was defined in the step 1.2:

                      data: [
                      { v0: 6221870 }, // Grand total
                      { r0: "Australia", v0: 1372281 },
                      { r0: "France", v0: 1117794 },
                      { r0: "Germany", v0: 1070453 },
                      { r0: "Canada", v0: 1034112 },
                      { r0: "United States", v0: 847331 },
                      { r0: "United Kingdom", v0: 779899 }
                      ]

                      This raw data now must be transformed to match the data format required by your charting library, in our case — Chart.js. Let’s create a function that will preprocess the data, for example, prepareData().

                      We are passing data to the data.labels and data.datasets properties, where data.labels contains field members and data.datasets contains values. Read more in the Chart.js documentation.

                      The prepareData() function for Chart.js will look similar to the following:

                        prepareData(rawData: any): { labels: string[]; values: number[] } {
                          const labels = rawData.data.filter((rec: any) => rec.r0 && rec.v0).map((rec: any) => rec.r0);
                          const values = rawData.data.filter((rec: any) => rec.r0 && rec.v0).map((rec: any) => rec.v0);
                        
                          return { labels, values };
                        };

                        prepareData() must return an object with the data that can be used by your charting library. The example shows the returned object for Chart.js:

                        { 
                        labels: ["Australia", "France", "Germany", "Canada", "United States", "United Kingdom"],
                        values: [1372281, 1117794, 1070453, 1034112, 847331, 779899]
                        }

                        Step 6. Run the project

                        Run your project with the following command:

                        ng serve --open

                        Open http://localhost:4200/ in the browser to see how the pivot table looks in combination with amCharts.

                        Try filtering the data, changing measures, and adjusting aggregation functions — the chart will be updated at once.

                        Check out the full code

                        After completing this tutorial, the full code of the integration should look as follows:

                          import { Component, ViewChild, ElementRef } from '@angular/core';
                          import { WebdatarocksPivotModule, WebdatarocksComponent } from "@webdatarocks/ngx-webdatarocks";
                          
                          import { Chart, ChartConfiguration, registerables } from 'chart.js';
                          
                          Chart.register(...registerables);
                          
                          @Component({
                            selector: 'app-root',
                            standalone: true,
                            imports: [WebdatarocksPivotModule],
                            templateUrl: './app.component.html',
                            styleUrl: './app.component.css'
                          })
                          export class AppComponent {
                            @ViewChild("pivot") pivotRef!: WebdatarocksComponent;
                            @ViewChild('chartCanvas') chartCanvas!: ElementRef;
                          
                            chart!: Chart<"polarArea">;
                          
                            report = {
                              dataSource: {
                                filename: "https://cdn.webdatarocks.com/data/data.csv",
                              },
                              slice: {
                                rows: [
                                  {
                                    uniqueName: "Country",
                                  },
                                ],
                                columns: [
                                  {
                                    uniqueName: "Measures",
                                  },
                                ],
                                measures: [
                                  {
                                    uniqueName: "Price",
                                    aggregation: "sum",
                                  },
                                ],
                              },
                            };
                            
                            onReportComplete() {
                              this.pivotRef.webDataRocks.off("reportComplete");
                              this.createChart();
                            };
                          
                            createChart() {
                              this.pivotRef.webDataRocks.getData(
                                {}, 
                                this.drawChart.bind(this),
                                this.drawChart.bind(this),
                              );
                            };
                          
                            drawChart(rawData: any) {
                              const { labels, values } = this.prepareData(rawData);
                          
                              const chartConfig: ChartConfiguration<'polarArea'> = {
                                type: 'polarArea',
                                data: {
                                  labels: labels,
                                  datasets: [
                                    {
                                      data: values,
                                    },
                                  ],
                                },
                              };
                          
                              if (this.chart) {
                                this.chart.destroy();
                              };
                          
                              this.chart = new Chart(this.chartCanvas.nativeElement, chartConfig);
                            };
                          
                            prepareData(rawData: any): { labels: string[]; values: number[] } {
                              const labels = rawData.data.filter((rec: any) => rec.r0 && rec.v0).map((rec: any) => rec.r0);
                              const values = rawData.data.filter((rec: any) => rec.r0 && rec.v0).map((rec: any) => rec.v0)
                              return { labels, values };
                            };
                          
                          }
                          <app-wbr-pivot #pivot
                           [toolbar]="true"
                           [report]="report"
                           (reportcomplete)="onReportComplete()">
                          </app-wbr-pivot>
                          <canvas #chartCanvas></canvas>

                          See also

                          Move up