Analytics

Charts

After using SQL to gather, structure and analyze all of the necessary data for your analysis, you can build visualizations on top of that data. Mode offers a number of options for building visualizations, including built-in Charts and Tables.

You can use this resource to either get a single Chart or list of all Charts for a given Report’s Query in your Mode Workspace.

Chart object

Properties

view

required

object

view_version

required

integer

view_vegas

required

object

token

required

string

created_at

required

string

updated_at

required

string

color_palette_token

string

switch_view_token

string

_links

required

object

All resource responses contain a set of links that describe other related resources or actions that you can take on this resource. A link is comprised of two main pieces: its name (which describes its relationship to this resource) and its href (the URL of the related action or resource). All resources have at least a _self link which is the URL that will return a representation of this resource.

  • color_palette
  • creator
  • preview
  • report_run_viz_web
  • report_viz_web
  • self
{
  "view": {
    "bar": {...},
    "bigNumber": {...},
    "line": {
      "label": "ORDERED_COHORT_TYPE",
      "x": "TIME_ID",
      "y": [
        "Responses"
      ],
      "aggregate": "sum",
      "yminFromData": 1,
      "ymaxFromData": 592,
      "yminTotal": 1,
      "ymaxTotal": 592
    },
    "linePlusBar": {...},
    "scatter": {...},
    "pie": {...},
    "area": {...},
    "pivotTable": {...},
    "selectedChart": "line",
    "chartTitle": "NPS scores"
  },
  "view_version": 2,
  "view_vegas": {
    "title": "NPS scores",
    "chartType": "line",
    "encoding": {...},
    "format": {...},
    "colors": {...}
  },
  "token": "81e633e0bab6",
  "created_at": "2019-12-20T23:18:10.048Z",
  "color_palette_token": "e7826e782faa",
  "_links": {
    "self": {
      "href": "/api/organization/reports/1fdc4c3fc111/queries/24fa53340a03/charts/81e633e0bab6"
    },
    "color_palette": {
      "href": "/api/organization/color_palettes/e7826e782faa"
    },
    "report_viz_web": {
      "href": "/organization/reports/1fdc4c3fc111/viz/81e633e0bab6"
    },
    "report_run_viz_web": {
      "templated": true,
      "href": "/organization/reports/1fdc4c3fc111/runs/{token}/viz/81e633e0bab6"
    },
    "creator": {
      "href": "/api/courtney_eriksson"
    }
  },
  "_forms": {...}
}

Get a chart

To retrieve information about a single Chart, send a GET request including the chart token to the Report Query’s charts resource.

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

query

required
string Query token

chart

required
string Chart token
Responses

200

Chart response

401

Unauthorized

404

Chart not found

GET /{account}/reports/{report}/queries/{query}/charts/{chart}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts/{chart}'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts/{chart}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts/{chart}', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts/{chart}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

List Charts for a Query

To return a list of all Charts for a given Query, send a GET request to the Report Query’s charts resource.

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

query

required
string Query token
Responses

200

Chart collection response

401

Unauthorized

404

Report not found

GET /{account}/reports/{report}/queries/{query}/charts

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://app.mode.com/api/{workspace}/reports/{report}/queries/{query}/charts',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});