How to :: add source from the code mode

Important

This is only available from the code mode

Overview

Source will appear at the bottom of your story and help the user understand where the data is coming from.

It’s important to add it!

Configuration

You can configure a regular string as a source with the source key in the slide config block.

{
  level: 3
  title: "Volume Report"
  source: "Datasource: ERP Magellan"
  chartOptions: {}
}

Or you can configure a dynamic source with a data query, using one of the story’s dataset. For example when you want to use the source to display the date of the data:

{
  level: 3
  title: "Volume Report"
  datasets:
    my_source_dataset:
      query:[
        $match:
          domain: "mydata"
      ,
        $sort: { 'Date': -1}
      ,
        $limit: 1
      ]
    my_chart_dataset: {}
  source:
    datasets: ['my_source_dataset']
    value: 'Last update: <$= my_source_dataset.Date $>' # We assume there is a `Date` entry in the retrieved data row
  chartOptions:{}
}

Notes:

  • For now you can only configure the dynamic source in the studio by using the code mode.
  • You don’t have to configure a specific dataset for your source. You can just use the one from your chart.
  • If there is more than one row returned by your dataset query, the first row will be used.
  • If you have filters on your story, the dynamic source will change depending on what filter value is selected.
  • You can use multiple datasets’ data in your source. Just declare the datasets you want to use in the datasets option. For example :
{
  level: 3
  title: "Volume Report"
  datasets:
    first_dataset:
      query: domain: 'first_dataset'
    second_dataset:
      query: domain: 'second_dataset'
  source:
    datasets: ['first_dataset', 'second_dataset']
    value: 'Last update: <$= first_dataset.Date $> from  <$= second_dataset.Survey_Company $> '
  chartOptions:{}
}