Need a special offer?Find out if your project fits.
+
All documentation
  • Introduction
  • Connecting to Data Source
    1. Supported data sources
    2. Connecting to other data sources
  • Browser compatibility
  • Documentation for older versions
  • Managing data presentation in CSV

    This guide explains how to customize data presentation and structure using mapping

    With the mapping, you can:

    • Set data types
    • Configure multilevel hierarchies
    • Hide a specific field
    • Specify available aggregations for a field

    For more details, see our mapping guide. You can also migrate from CSV prefixes to the mapping.

    Set data types

    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"
          }
        }
      }
    }

    See a live sample on JSFiddle.

    Refer to mapping properties for the full list of available data types.

    Configure multilevel hierarchies

    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"
          }
        }
      }
    }

    See a live sample on JSFiddle.

    Hide a specific field

    To hide a field from the dataset, set its visible property to false:

    report: {
      dataSource: {
        filename: "data.csv",
        mapping: {
          "Size": {
            visible: false
          }
        }
      }
    }

    See a live sample on JSFiddle.

    Specify available aggregations for a field

    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"]
          }
        }
      }
    }

    See a live sample on JSFiddle.

    More configurations

    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.

    Migrating from CSV prefixes to the MappingObject

    For easy migration from CSV prefixes to the mapping, see the migration table below:

    CSV prefixMapping typeDescription
    +"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.

    What’s next?

    You may be interested in the following articles: