This guide explains how to customize data presentation and structure using mapping.
With the mapping, you can:
For more details, see our mapping guide. You can also migrate from CSV prefixes to the mapping.
To set data types for a CSV data source, specify the mapping as follows:
report: { dataSource: { filename: "data.csv", mapping: { "Date": { type: "date string" }, "Evaporation": { type: "string" }, "Rainfall": { type: "number" } } } }
Refer to mapping properties for the full list of available data types.
To create multilevel hierarchies from non-hierarchical data, use hierarchy and parent properties in the mapping:
report: { dataSource: { filename: "data.csv", mapping: { "Region": { hierarchy: "Geography" }, "State": { parent: "Region", hierarchy: "Geography" }, "City": { parent: "State", hierarchy: "Geography" } } } }
To hide a field from the dataset, set its visible property to false
:
report: { dataSource: { filename: "data.csv", mapping: { "Size": { visible: false } } } }
To define which aggregations are available for a field, specify its mapping like this:
report: { dataSource: { filename: "data/data.csv", mapping: { "Price": { aggregations: ["max", "min"] } } } }
Learn more about mapping’s features from this guide: Mapping.
Note If you are using column prefixes to set data types in CSV, you can migrate from CSV prefixes to the mapping.
For easy migration from CSV prefixes to the mapping, see the migration table below:
CSV prefix | Mapping type | Description |
---|---|---|
+ | "string" | The field is a dimension. |
- | "number" | The field is a value. |
m+ | "month" | The field stores months. |
w+ | "weekday" | The field stores days of the week. |
d+ | "date" | The field stores a date. The field of this type is split into 3 different fields: Year, Month, and Day. |
D+ | "year/month/day" | The field stores a date. It’s displayed as a multilevel hierarchy with the following levels: Year > Month > Day. |
D4+ | "year/quarter/month/day" | The field is a date. It’s displayed as a multilevel hierarchy with the following levels: Year > Quarter > Month > Day. |
ds+ | "date string" | The field stores a date. It can be formatted using the datePattern option (default is "dd/MM/yyyy" ). |
t+ | "time" | The field stores time. |
dt+ | "datetime" | The field stores a date. It can be formatted using the dateTimePattern option (default is "dd/MM/yyyy HH:mm:ss" ). |
id+ | "id" | The field is an id. The field of this type can be used for editing data. It’s not shown in the Field List. |
You may be interested in the following articles: