Skip to content

Commit

Permalink
Data Explorer fixes (datopian#63)
Browse files Browse the repository at this point in the history
* [views][xs]: use build files from specific commit so that views lib work without data explorer.

* [dms][s]: update 'dataExplorers' property so that it has views for table, chart and map.
  • Loading branch information
anuveyatsu authored and starsinmypockets committed Aug 30, 2019
1 parent 55a246b commit 71fe155
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions routes/dms.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,17 @@ module.exports = function () {

// Add 'table' views for each tabular resource:
const tabularFormats = ['csv', 'tsv', 'dsv', 'xls', 'xlsx']
let tabularMapView
let chartView, tabularMapView

if (tabularFormats.includes(resource.format)) {
// DataExplorer needs a second view to render a map from tabular data
tabularMapView = Object.assign({}, view)
tabularMapView.specType = "tabularmap"
// Default table view
view.specType = 'table'
// DataExplorer specific view to render a chart from tabular data
chartView = Object.assign({}, view)
chartView.specType = 'simple'
// DataExplorer specific view to render a map from tabular data
tabularMapView = Object.assign({}, view)
tabularMapView.specType = 'tabularmap'
} else if (resource.format.includes('json')) {
// Add 'map' views for each geo resource:
view.specType = 'map'
Expand All @@ -173,7 +177,7 @@ module.exports = function () {

if (chartBuilderFormats.includes(resource.format)) controls = { showChartBuilder: true, showMapBuilder: true }

const views = (tabularMapView) ? [tabularMapView, view] : [view]
const views = (tabularMapView) ? [view, chartView, tabularMapView] : [view]
const dataExplorer = JSON.stringify({resources: [resource], views, controls}).replace(/'/g, "'")

// Add Data Explorer item per resource
Expand Down
2 changes: 1 addition & 1 deletion views/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="icon" type="img/ico" href="/static/img/favicon.ico" sizes="16x16">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
{% if dataset %}
<link rel="stylesheet" media="screen" href="https://raw.githack.com/datopian/datapackage-views-js/master/dist/css/main.css">
<link rel="stylesheet" media="screen" href="https://rawcdn.githack.com/datopian/datapackage-views-js/681e1ff21a0daee03e8e81ad0ddc7c8bf682aee9/dist/css/main.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.css">
{% endif %}
<link rel="stylesheet" media="screen" href="/static/stylesheets/app.css">
Expand Down
2 changes: 1 addition & 1 deletion views/showcase.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,6 @@ <h2 id="readme" class="section-title">Read me</h2>
}
</script>

<script type="text/javascript" src="https://raw.githack.com/datopian/datapackage-views-js/master/dist/js/main.js"></script>
<script type="text/javascript" src="https://rawcdn.githack.com/datopian/datapackage-views-js/681e1ff21a0daee03e8e81ad0ddc7c8bf682aee9/dist/js/main.js"></script>

{% endblock %}

0 comments on commit 71fe155

Please sign in to comment.