Commit 743e090f authored by Rodrigo Tapia-McClung's avatar Rodrigo Tapia-McClung

OD table placeholder, update layout, clean up code

parent adc64ce7
...@@ -29,15 +29,8 @@ ...@@ -29,15 +29,8 @@
<p class="lead">Consulta el crecimiento de los aglomerados urbanos del Corredor Metropolitano Centro Pa&iacute;s resultado del an&aacute;lisis de im&aacute;genes &oacute;pticas de Sentinel-2 y conoce los indicadores que caracterizan su evoluci&oacute;n econ&oacute;mica <p class="lead">Consulta el crecimiento de los aglomerados urbanos del Corredor Metropolitano Centro Pa&iacute;s resultado del an&aacute;lisis de im&aacute;genes &oacute;pticas de Sentinel-2 y conoce los indicadores que caracterizan su evoluci&oacute;n econ&oacute;mica
en las &uacute;ltimas d&eacute;cadas.</p> en las &uacute;ltimas d&eacute;cadas.</p>
<hr class="my-4"> <hr class="my-4">
<!--<p>Escoge las fechas para las que quieres explorar el crecimiento urbano y algunos indicadores.</p>-->
<div class="container"> <div class="container">
<div class="row justify-content-center"> <div class="row justify-content-center">
<!--<div class="col-4 text-center">
<input type="text" name="date-initial" id="date-initial" readonly="readonly" size="12" placeholder="Fecha inicial" data-calendar="false" />
</div>
<div class="col-4 text-center">
<input type="text" name="date-final" id="date-final" readonly="readonly" size="12" placeholder="Fecha final" data-calendar="true" />
</div>-->
<div class="col-4 text-center"> <div class="col-4 text-center">
<button type="button" class="btn btn-primary btn-lg" id="showFlows">Ver flujos</button> <button type="button" class="btn btn-primary btn-lg" id="showFlows">Ver flujos</button>
</div> </div>
...@@ -50,10 +43,8 @@ ...@@ -50,10 +43,8 @@
</div> </div>
<div class="d-flex flex-column" id="mainContainer"> <div class="d-flex flex-column" id="mainContainer">
<!--<header class="page-header py-2">-->
<header class="navbar navbar-expand navbar-dark flex-column flex-md-row bd-navbar"> <header class="navbar navbar-expand navbar-dark flex-column flex-md-row bd-navbar">
<a class="navbar-brand mr-0 mr-md-2" href="." aria-label="Regresar"><i class="fas fa-arrow-left"></i></a> <a class="navbar-brand mr-0 mr-md-2" href="." aria-label="Regresar"><i class="fas fa-arrow-left"></i></a>
<!--<div class="container text-center">-->
<div class="navbar-nav mx-auto"> <div class="navbar-nav mx-auto">
<div class="row align-items-center text-center" id="title"> <div class="row align-items-center text-center" id="title">
<h2>Crecimiento urbano en la regi&oacute;n metropolitana centro pa&iacute;s</h2> <h2>Crecimiento urbano en la regi&oacute;n metropolitana centro pa&iacute;s</h2>
...@@ -65,8 +56,6 @@ ...@@ -65,8 +56,6 @@
<div class="container-fluid d-flex flex-fill"> <div class="container-fluid d-flex flex-fill">
<div class="row d-flex flex-fill"> <div class="row d-flex flex-fill">
<div class="col-md-6" id="mexmap"> <div class="col-md-6" id="mexmap">
<!-- <div class="col-md-10" id="mexmap"> -->
<div id="datePickers"></div>
<div class="picker"> <div class="picker">
<select id="indicatorSelect"></select> <select id="indicatorSelect"></select>
</div> </div>
...@@ -83,17 +72,26 @@ ...@@ -83,17 +72,26 @@
<div class="col-md-6" id="story"> <div class="col-md-6" id="story">
<div class="loader"></div> <div class="loader"></div>
<div class="row h-50 border-bottom"> <div class="row h-50 border-bottom">
<!--<div class="col-6 border-right">-->
<div class="col"> <div class="col">
<div id="amchartdiv"></div> <div class="row h-100">
<div id="odChart"></div>
</div>
</div> </div>
<!--<div class="col-6">
<div id="df-graph"></div>
</div>-->
</div> </div>
<div class="row h-50"> <div class="row h-50">
<div class="col-6 border-right" id="prueba"> <div class="col-6 border-right">
<div id="tablediv"> <div class="row h-100">
<div id="chordChart"></div>
</div>
</div>
<div class="col-6 align-self-center" id="odTableRow">
<div class="row h-100 justify-content-center">
<div class="card text-center" id="odCard">
<div class="card-body">
<p class="card-text">Haz clic en un nodo del mapa para mostrar sus datos</p>
</div>
</div>
<table class="table table-dark table-striped table-fixed" id="tblViajes"> <table class="table table-dark table-striped table-fixed" id="tblViajes">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
...@@ -106,11 +104,6 @@ ...@@ -106,11 +104,6 @@
</table> </table>
</div> </div>
</div> </div>
<div class="col-6">
<div class="row h-100" id="prueba2">
<div id="perimeter-graph"></div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -243,10 +243,11 @@ span.frac > span { ...@@ -243,10 +243,11 @@ span.frac > span {
} }
#tblViajes { #tblViajes {
display: none;
font: 12px sans-serif; font: 12px sans-serif;
} }
.table-fixed thead { /*.table-fixed thead {
width: 100%; width: 100%;
} }
...@@ -268,15 +269,12 @@ span.frac > span { ...@@ -268,15 +269,12 @@ span.frac > span {
/* Graphs */ /* Graphs */
#amchartdiv {
width: 100%;
height: 100%;
}
.amcharttooltip { .amcharttooltip {
font: 12px sans-serif; font: 12px sans-serif;
} }
.active { .active {
text-decoration: underline; text-decoration: underline;
font-weight: 600; font-weight: 600;
......
...@@ -1030,12 +1030,12 @@ const createFlowLayer = (geojson, type, addOnCreate) => { ...@@ -1030,12 +1030,12 @@ const createFlowLayer = (geojson, type, addOnCreate) => {
// if layer is to be added on creation, add click funcionality and populate chart // if layer is to be added on creation, add click funcionality and populate chart
if (addOnCreate) { if (addOnCreate) {
flowMapLayer.addTo(map).on('click', odClick); flowMapLayer.addTo(map).on('click', odClick);
let amchart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "amchartdiv"); let odChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "odChart");
amchart.data = newData; odChart.data = newData;
let amchart2 = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "prueba2"); let chordChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "chordChart");
amchart2.data = newData; chordChart.data = newData;
amchart2.data = amchart2.data.filter(function(e) { return e.flowCount > 0 }); chordChart.data = chordChart.data.filter(function(e) { return e.flowCount > 0 });
} }
flowMapsArray.push(flowMapLayer); flowMapsArray.push(flowMapLayer);
resolve(flowMapsArray); resolve(flowMapsArray);
...@@ -1158,6 +1158,9 @@ const makeBaseMap = () => { ...@@ -1158,6 +1158,9 @@ const makeBaseMap = () => {
} }
}); });
layer._resetCanvas(); layer._resetCanvas();
$("#odTableRow").addClass("align-self-center");
$("#odCard").show();
$("#tblViajes").hide();
$("#tblViajes tbody").html(""); $("#tblViajes tbody").html("");
} }
}); });
......
...@@ -19,7 +19,7 @@ am4core.ready(function() { ...@@ -19,7 +19,7 @@ am4core.ready(function() {
am4core.options.autoSetClassName = true; am4core.options.autoSetClassName = true;
// Themes end // Themes end
var chart = am4core.create("amchartdiv", am4charts.XYChart); var chart = am4core.create("odChart", am4charts.XYChart);
chart.maskBullets = false; chart.maskBullets = false;
var title = chart.titles.create(); var title = chart.titles.create();
...@@ -250,9 +250,7 @@ am4core.ready(function() { ...@@ -250,9 +250,7 @@ am4core.ready(function() {
am4core.useTheme(am4themes_animated); am4core.useTheme(am4themes_animated);
// Themes end // Themes end
var cd_chart = am4core.create("chordChart", am4charts.ChordDiagram);
var cd_chart = am4core.create("prueba2", am4charts.ChordDiagram);
var cd_title = cd_chart.titles.create(); var cd_title = cd_chart.titles.create();
//cd_title.text = "Viajes de ocupados desde centros de mercado"; //cd_title.text = "Viajes de ocupados desde centros de mercado";
...@@ -262,23 +260,17 @@ am4core.ready(function() { ...@@ -262,23 +260,17 @@ am4core.ready(function() {
cd_title.marginBottom = 20; cd_title.marginBottom = 20;
cd_title.paddingLeft = 10; cd_title.paddingLeft = 10;
cd_chart.events.on("beforedatavalidated", function(ev) { cd_chart.events.on("beforedatavalidated", function(ev) {
let option = $("#indicatorSelect").val(); //let option = $("#indicatorSelect").val();
let optionTitle = $("#indicatorSelect option:selected").text(); let optionTitle = $("#indicatorSelect option:selected").text();
cd_title.text = "[bold]Conectividad origen -destino entre \n" + optionTitle.toLowerCase(); cd_title.text = "[bold]Conectividad origen - destino entre \n" + optionTitle.toLowerCase();
//var data = ev.target.data; //var data = ev.target.data;
//let data = data.filter(function(e) { return e.flowCount > 0 }); //let data = data.filter(function(e) { return e.flowCount > 0 });
//console.log(data); //console.log(data);
}); });
cd_chart.dataFields.fromName = "xVar"; cd_chart.dataFields.fromName = "xVar";
cd_chart.dataFields.toName = "yVar"; cd_chart.dataFields.toName = "yVar";
cd_chart.dataFields.value = "flowCount"; cd_chart.dataFields.value = "flowCount";
...@@ -296,10 +288,8 @@ am4core.ready(function() { ...@@ -296,10 +288,8 @@ am4core.ready(function() {
bullet.locationX = 0.5; bullet.locationX = 0.5;
// create animations // create animations
//cd_chart.events.once("over", function() {
nodeTemplate.events.on("ready", function() {
cd_chart.events.on("over", function() {
// nodeTemplate.events.on("ready", function() {
for (var i = 0; i < cd_chart.links.length; i++) { for (var i = 0; i < cd_chart.links.length; i++) {
var link = cd_chart.links.getIndex(i); var link = cd_chart.links.getIndex(i);
var bullet = link.bullets.getIndex(0); var bullet = link.bullets.getIndex(0);
...@@ -325,5 +315,4 @@ am4core.ready(function() { ...@@ -325,5 +315,4 @@ am4core.ready(function() {
cd_chart.responsive.enabled = true; cd_chart.responsive.enabled = true;
}); // end am4core.ready() }); // end am4core.ready()
\ No newline at end of file
...@@ -431,6 +431,9 @@ const odClick = (e) => { ...@@ -431,6 +431,9 @@ const odClick = (e) => {
// style viajes thousands with #,### // style viajes thousands with #,###
origins += `<tr><td>${dest.properties.muni_origen}</td><td>${dest.properties.muni_destino}</td><td>${dest.properties.viajes.toLocaleString()}</td></tr>`; origins += `<tr><td>${dest.properties.muni_origen}</td><td>${dest.properties.muni_destino}</td><td>${dest.properties.viajes.toLocaleString()}</td></tr>`;
}); });
$("#odCard").hide();
$("#odTableRow").removeClass("align-self-center");
$("#tblViajes").show();
$("#tblViajes tbody").html(origins); $("#tblViajes tbody").html(origins);
if (e.sharedDestinationFeatures.length) { if (e.sharedDestinationFeatures.length) {
...@@ -814,24 +817,23 @@ $("#indicatorSelect").on("change", function() { ...@@ -814,24 +817,23 @@ $("#indicatorSelect").on("change", function() {
layer.off("click", odClick); layer.off("click", odClick);
map.removeLayer(layer); map.removeLayer(layer);
} }
});
// on select, update chart data $("#odTableRow").addClass("align-self-center");
let amchart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "amchartdiv") $("#odCard").show();
amchart.data = odData[option]; $("#tblViajes").hide();
$("#tblViajes tbody").html("");
});
// on select, update chart data
let odChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "odChart")
odChart.data = odData[option];
let amchart2 = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "prueba2") let chordChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "chordChart")
amchart2.data = odData[option]; chordChart.data = odData[option];
amchart2.data = amchart2.data.filter(function(e) { return e.flowCount > 0 }); chordChart.data = chordChart.data.filter(function(e) { return e.flowCount > 0 });
//console.log(amchart2.data.filter(function(e) { return e.flowCount > 0 })) //console.log(amchart2.data.filter(function(e) { return e.flowCount > 0 }))
/* let amchart1 = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "prueba")
amchart1.data = odData[option];
amchart1.data = amchart1.data.filter(function(e) { return e.flowCount > 0 });*/
styleTiles(option, minIndicators, maxIndicators) styleTiles(option, minIndicators, maxIndicators)
.then(legend.addTo(map)); // add legend control -> it updates .then(legend.addTo(map)); // add legend control -> it updates
// FIXME: re-adding control updates its contents... why? // FIXME: re-adding control updates its contents... why?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment