Using the BC Data Catalogue’s APIs to create data visualizations using D3.js



The BC Data Catalogue (Catalogue) lists more than 3,000 publicly accessible datasets, applications and APIs, including nearly 1,500 datasets licensed under the Open Government License – BC .

The Catalogue is powered by open source software called CKAN (Comprehensive Knowledge Archive Network) and has been adopted by governments around the world.

The BC Data Catalogue has an API which allows users to query .csv datasets that have been uploaded to the Catalogue.  Datasets with an API are distinguished by the green button on the resource page. An example of this is the Property Transfer Tax provincial monthly resource. https://catalogue.data.gov.bc.ca/dataset/property-transfer-tax-data-2016/resource/099288eb-4a09-43eb-8dc2-72586808f70f

 

Clicking on the Data API button results in some code snippets with examples on how to query the dataset. For the demo visualization below, we’re interested in the JavaScript example.

 

D3.js is a JavaScript data visualization library that can be used to create a wide variety of graphs and maps. Here’s an example of an interactive visualization built with D3 that uses the catalogue’s API to access data from the 2016 and 2017 Property Transfer Tax datasets. https://qa.data.gov.bc.ca/extra/vis6/

The code is available on GitHub

https://github.com/bcgov/data-fp-features/tree/master/extra/vis6

Since this graph is sourcing the data from the API, anytime the dataset is updated (e.g. monthly for this dataset) the graph will automatically show those updates – no code changes are required.

 

This is just one example of leveraging the Catalogue’s API. We hope users will come up with innovative ways to create their own visualizations.

Leave a Reply

Your email address will not be published. Required fields are marked *