Commit 1f060ebd authored by Rodrigo Tapia-McClung's avatar Rodrigo Tapia-McClung

Update bar chart title on area hover

parent 82e4c682
......@@ -587,7 +587,6 @@ const makeCharts = () => {
// RADAR CHART
// async queries for each date that has been loaded
const queries = userFiles.map(async (mes, i) => {
//let query = `${baseUrl}/query/${mes}?columns=sum(areacpo)/10000 value1,sum(perimcpo) value2, sum(dimfrcpo) value3`;
let query = `${baseUrl}/query/${mes}?columns=sum(areacpo)/10000 area`;
const queryData = await d3.json(query);
queryData[0].date = new Date(userDates[i]);
......@@ -600,7 +599,6 @@ const makeCharts = () => {
// wait for all queries to complete and then set chart data
Promise.all(queries).then( data => {
radarData.sort((a, b) => (a.date > b.date) ? 1 : -1);
// TODO: maybe make this a function so it can be used to update chart when changing dates
let radarChartData = [];
monthArray.forEach( (month, index) => {
let element = {};
......@@ -633,7 +631,6 @@ const makeCharts = () => {
Promise.all(queries_ls).then( data => {
// unnest andd flatten data object for further processing
let rawData = data.map( d => Object.values(d)[0] ).flat();
// TODO: maybe make this a function so it can be used to update chart when changing dates
let merged = [].concat.apply([], rawData);
let aguaPermanente = merged.filter(d => d.descrip == "Agua permanente" );
let aguaTemporal = merged.filter(d => d.descrip == "Áreas temporalmente inundadas" );
......@@ -708,6 +705,11 @@ const updateBarChartOnHover = (filterDate, data) => {
if (popBarsChart) {
popBarsChart.data = cart_pb1;
popBarsChart.invalidateRawData();
// set barChart title when hovering on different bars
let ye = new Intl.DateTimeFormat('es', { year: 'numeric' }).format(filterDate);
let mo = new Intl.DateTimeFormat('es', { month: 'short' }).format(filterDate);
popBarsChart.titles.values[0].text = `Conteo por tipo de cuerpo en ${mo} ${ye}`;
// TODO: update barChart when changing dates on timeDimension?
}
}
......
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