Skip to content

Instantly share code, notes, and snippets.

@stuartlynn
Last active April 29, 2016 05:50
Show Gist options
  • Select an option

  • Save stuartlynn/dd4dd02b914ad2ae441cf89afd35028d to your computer and use it in GitHub Desktop.

Select an option

Save stuartlynn/dd4dd02b914ad2ae441cf89afd35028d to your computer and use it in GitHub Desktop.
gardens_example
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Deep-Insights.js – Madrid: Airbnb, nightlife, and public transport</title>
<meta name=viewport content="width=device-width initial-scale=1">
<link href="http://cartodb.com/favicon.ico" rel="shortcut icon" />
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<link rel="stylesheet" href="http://libs.cartocdn.com/di.js/v0/themes/css/deep-insights.css" />
<script src=" http://libs.cartocdn.com/di.js/v0/deep-insights.uncompressed.js"></script>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<style type="text/css">
html, body {
position:relative;
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div class="Dashboard-canvas" id="dashboard"></div>
<script>
$.ajax({
url :'https://team.cartodb.com/u/stuartlynn/api/v2/viz/0e5351d0-0dc3-11e6-90ca-0e5db1731f59/viz.json',
jsonp: "callback",
dataType: "jsonp",
success: function(viz){
console.log(viz)
layer_id = '81ae06b8-3412-4ded-a4e3-fe35b18930a4'
viz.user ={
"fullname": "Stuart Lynn",
"avatar_url": "https://s3.amazonaws.com/com.cartodb.users-assets.production/production/piensaenpixel/assets/20150507074635Captura%20de%20pantalla%202015-05-07%20a%20la%28s%29%2009.46.28.png"
};
viz.datasource={
"type": "public_map",
"user_name": "stuartlynn",
"maps_api_template": "https://{user}.cartodb.com",
"stat_tag": '0e5351d0-0dc3-11e6-90ca-0e5db1731f59',
"force_cors": true // This is sometimes set in the editor
},
viz.widgets = [
{
"type": "formula",
"title": "Populatiom ",
"layer_id": layer_id,
"options": {
"column": "hispanic_population",
"operation": "sum"
}
},
{
"type": "formula",
"title": "Parks ",
"layer_id": layer_id,
"options": {
"column": "hispanic_population",
"operation": "count"
}
},
{
"type": "histogram",
"title": "hispanic_population",
"layer_id": layer_id,
"options": {
"column": "hispanic_population",
"bins": 20
}
},
{
"title": "Segment",
"type": "category",
"layer_id": layer_id,
"options": {
"type": "aggregation",
"column": "segment",
"aggregationColumn": "hispanic_population",
"aggregation": "count",
"sync": true
}
},
{
"title": "Growing site type",
"type": "category",
"layer_id": layer_id,
"options": {
"type": "aggregation",
"column": "growing_site_types",
"aggregationColumn": "cartodb_id",
"aggregation": "count",
"sync": true
}
},
{
"title": "Makes food",
"type": "category",
"layer_id": layer_id,
"options": {
"type": "aggregation",
"column": "food_producing",
"aggregationColumn": "hispanic_population",
"aggregation": "count",
"sync": true
}
},
{
"type": "histogram",
"title": "median_income",
"layer_id": layer_id,
"options": {
"column": "median_income",
"bins": 40
}
},
{
"type": "histogram",
"title": "median_age",
"layer_id": layer_id,
"options": {
"column": "median_age",
"bins": 40
}
}]
cartodb.deepInsights.createDashboard('#dashboard', viz)
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment