Skip to content

Instantly share code, notes, and snippets.

@easternbloc
Last active August 29, 2015 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save easternbloc/02be192de739e0b350af to your computer and use it in GitHub Desktop.
Save easternbloc/02be192de739e0b350af to your computer and use it in GitHub Desktop.
Formatting options

#Formatting data in spotlight

Data in spotlight can be formatted in many different types. This document is intended to outline the main formatting options that can be used in a dashboard and where they are required to be configured.

##Graphs

Most of our graph modules support the format option key.

###Example

  {
   "format": {
    "sigfigs": 3,
    "magnitude": true,
    "type": "number"
   }
  }

##Tables

Data in tables is formatted using the format key specified in the axes.

###Example

  {
    "axes": {
      "y": [
       {
        "format": {"type": integer"},
        "groupId": "paper",
        "label": "Paper form"
       },
       {
        "format": {"type": integer"},
        "groupId": "digital",
        "label": "Digital"
       }
      ],
      "x": {
       "format": {"type": "date"},
       "key": [
        "_start_at",
        "_end_at"
       ],
       "label": "Date"
      }
     }
    }
  }
}

##Types of formatting:

The most common types of formatting are listed with examples below

###Duration

Accepts the options (unit: ['ms', 's', 'm'], pad: [true, false])

{ type: 'duration', unit: 'm' }

###Currency

Accepts the options (symbol: defaults to '£', pence, dps)

{ sigfigs: 3, magnitude: true, type: 'currency' }

###Percent

Accepts the options (dps, normalisation, showSigns)

{ type: 'percent' }

###Integer

Calls number after it does a Math.round on the value.

{ type: 'integer' }

###Number

Accepts the options (commans: [true, false], sigfigs, fixed, dps)

{ sigfigs: 3, magnitude: true, type: 'number' }

###Date

Accepts the options (format: 'D MMMM YYYY')

{ type: 'date' }

###Time

Accepts the options (format: 'h:mma')

{ type: 'time' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment