The MappingObject allows defining field data types, captions, and multilevel hierarchies; grouping fields under separate dimensions, and setting other view configurations of hierarchies.
The MappingObject is available for all data sources. It presents a powerful way to neatly separate a data source from its presentation. Find more details about the MappingObject in this tutorial with examples.
mapping: {
<uniqueName>: FieldMappingObject | FieldMappingObject[],
aggregations: AggregationsObject
}| Property/Type | Description |
|---|---|
| <uniqueName> FieldMappingObject | FieldMappingObject[] | Allows setting the mapping for a specific field from the dataset. <uniqueName> is the field’s unique name.Specify the mapping as the FieldMappingObject to set it for a certain field Live example. For "json" and "csv" data source types, it is possible to create several fields from a certain field. It can be done by specifying the mapping as an array of FieldMappingObjects, where each object is a new field. Learn more in our guide. |
| aggregations AggregationsObject | optional Available aggregation functions for all fields of a certain type
Live example. Only for "json" and "csv" data source types.See the list of supported aggregations. To learn more about defining aggregations for fields of a certain type, refer to our guide. Note Available aggregations for a certain field can be defined in the <uniqueName>.aggregations property. |
Here is an example of a mapping for a CSV data source:
dataSource: {
filename: "data.csv",
mapping: {
"Order ID": {
type: "string"
},
"Month": {
type: "month"
},
"Company Name": {
type: "string"
},
"Region": {
type: "string",
hierarchy: "Geography"
},
"State": {
type: "string",
parent: "Region",
hierarchy: "Geography"
},
"City": {
type: "string",
parent: "State",
hierarchy: "Geography"
},
// Mapping for other fields
},
}
Live example