Setting data types
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 data 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"
}
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"
}
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 > 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
“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"
}
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"
}
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.
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.