Commit 0fbf175e authored by Rodrigo Tapia-McClung's avatar Rodrigo Tapia-McClung

Fix chart divs, names, and containers + radar chart legend

parent 1f060ebd
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<i class="fa fa-spinner2 fa-spin fa-5x loadSpinner"></i><br> <i class="fa fa-spinner2 fa-spin fa-5x loadSpinner"></i><br>
<span class="loadText">Cargando datos...<br> <span class="loadText">Cargando datos...<br>
<span id="wb-fileLoad"></span> <span id="wb-fileLoad"></span>
<span id="basemap-fileLoad"></span> <span id="basemap-fileLoad"></span>
</span> </span>
</div> </div>
</div> </div>
...@@ -72,19 +72,27 @@ ...@@ -72,19 +72,27 @@
<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" id="radial_chart"> <div class="col-6 border-right">
<div id="radial_chart2"></div> <div class="row h-100">
<div id="radarChart"></div>
</div>
</div> </div>
<div class="col-6" id="linesChart"> <div class="col-6">
<div id="linesChart2"></div> <div class="row h-100">
<div id="lineChart"></div>
</div>
</div> </div>
</div> </div>
<div class="row h-50"> <div class="row h-50">
<div class="col-6 border-right" id="stackedAreaChart"> <div class="col-6 border-right">
<div id="dlccpo-graph2"></div> <div class="row h-100">
<div id="areaChart"></div>
</div>
</div> </div>
<div class="col-6" id="dimfrcpo-graph"> <div class="col-6">
<div id="dimfrcpo-graph2"></div> <div class="row h-100">
<div id="barChart"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -146,7 +146,7 @@ const makeBarSeries = (chart, field, name) => { ...@@ -146,7 +146,7 @@ const makeBarSeries = (chart, field, name) => {
} }
const makeRadarChart = (data, months, years) => { const makeRadarChart = (data, months, years) => {
let radarChart = am4core.create("radial_chart", am4charts.RadarChart); let radarChart = am4core.create("radarChart", am4charts.RadarChart);
let radarTitle = radarChart.titles.create(); let radarTitle = radarChart.titles.create();
radarTitle.text = "Superficie total por año"; radarTitle.text = "Superficie total por año";
...@@ -196,13 +196,15 @@ const makeRadarChart = (data, months, years) => { ...@@ -196,13 +196,15 @@ const makeRadarChart = (data, months, years) => {
makeRadarRange(radarCategoryAxis, "septiembre", "diciembre", radarRangeColors[3], 3); makeRadarRange(radarCategoryAxis, "septiembre", "diciembre", radarRangeColors[3], 3);
makeRadarRange(radarCategoryAxis, "diciembre", "diciembre", radarRangeColors[0], 1); makeRadarRange(radarCategoryAxis, "diciembre", "diciembre", radarRangeColors[0], 1);
radarChart.cursor = new am4charts.RadarCursor(); radarChart.cursor = new am4charts.RadarCursor(); //FIXME: cursors are offset
// add line legend // add line legend
radarChart.legend = new am4charts.Legend(); radarChart.legend = new am4charts.Legend();
//radarChart.legend.fontSize = 10; //radarChart.legend.fontSize = 10;
radarChart.legend.fontSize = 9; radarChart.legend.fontSize = 9;
radarChart.legend.labels.template.fill = am4core.color(mainTextColor); radarChart.legend.labels.template.fill = am4core.color(mainTextColor);
radarChart.legend.itemContainers.template.paddingTop = 0;
radarChart.legend.itemContainers.template.paddingBottom = 0;
let legenddata = [{ name: "Estiaje", fill: am4core.color("#595952") }, let legenddata = [{ name: "Estiaje", fill: am4core.color("#595952") },
{ name: "Tropical", fill: am4core.color("#838278") }, { name: "Tropical", fill: am4core.color("#838278") },
...@@ -218,11 +220,15 @@ const makeRadarChart = (data, months, years) => { ...@@ -218,11 +220,15 @@ const makeRadarChart = (data, months, years) => {
let markerTemplate = radarChart.legend.markers.template; let markerTemplate = radarChart.legend.markers.template;
markerTemplate.width = 20; markerTemplate.width = 20;
markerTemplate.height = 20; markerTemplate.height = 20;
radarChart.legend.itemContainers.template.paddingTop = 0;
radarChart.legend.itemContainers.template.paddingRight = -10;
radarChart.legend.itemContainers.template.paddingLeft = -10;
} }
const makeLineChart = (data) => { const makeLineChart = (data) => {
let lineChart = am4core.create("linesChart", am4charts.XYChart); let lineChart = am4core.create("lineChart", am4charts.XYChart);
let lineTitle = lineChart.titles.create(); let lineTitle = lineChart.titles.create();
lineTitle.text = "Superficie por tipo de cuerpo"; lineTitle.text = "Superficie por tipo de cuerpo";
lineTitle.fontSize = 10; lineTitle.fontSize = 10;
...@@ -259,7 +265,7 @@ const makeLineChart = (data) => { ...@@ -259,7 +265,7 @@ const makeLineChart = (data) => {
} }
const makeAreaChart = (data) => { const makeAreaChart = (data) => {
let areaChart = am4core.create("stackedAreaChart", am4charts.XYChart); let areaChart = am4core.create("areaChart", am4charts.XYChart);
let areaTitle = areaChart.titles.create(); let areaTitle = areaChart.titles.create();
areaTitle.text = "Superficie acumulada"; areaTitle.text = "Superficie acumulada";
...@@ -330,7 +336,7 @@ const makeAreaChart = (data) => { ...@@ -330,7 +336,7 @@ const makeAreaChart = (data) => {
} }
const makeBarChart = (data) => { const makeBarChart = (data) => {
let barChart = am4core.create("dimfrcpo-graph", am4charts.XYChart); let barChart = am4core.create("barChart", am4charts.XYChart);
let barTitle = barChart.titles.create(); let barTitle = barChart.titles.create();
barTitle.text = "Conteo por tipo de cuerpo"; barTitle.text = "Conteo por tipo de cuerpo";
......
...@@ -684,7 +684,7 @@ const makeCharts = () => { ...@@ -684,7 +684,7 @@ const makeCharts = () => {
// end bars // end bars
} }
const updateBarChartOnHover = (filterDate, data) => { const updateBarChartOnHover = (filterDate, data) => {
let popBarsChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "dimfrcpo-graph"); let popBarsChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "barChart");
let areclass = data.filter(d => d.date.valueOf() == filterDate.valueOf()); let areclass = data.filter(d => d.date.valueOf() == filterDate.valueOf());
let elementpb = {}, let elementpb = {},
cart_pb = []; cart_pb = [];
...@@ -717,7 +717,7 @@ const updateCharts = () => { ...@@ -717,7 +717,7 @@ const updateCharts = () => {
yearList = [... new Set(userDates.map( date => new Date(date).getFullYear() ))]; yearList = [... new Set(userDates.map( date => new Date(date).getFullYear() ))];
// update radar chart // update radar chart
let radarChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "radial_chart"); let radarChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "radarChart");
const queries = userDates.map( async (date, i) => { const queries = userDates.map( async (date, i) => {
// check what month has not been queried before and query it // check what month has not been queried before and query it
...@@ -758,8 +758,8 @@ const updateCharts = () => { ...@@ -758,8 +758,8 @@ const updateCharts = () => {
}); });
// update line + area chart // update line + area chart
let linesChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "linesChart"), let lineChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "lineChart"),
stackedAreaChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "stackedAreaChart"); areaChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "areaChart");
// extract months as values for which there is data already queried // extract months as values for which there is data already queried
let chartMonths = lineAreaData.map( d => parseInt(Object.keys(d)[0]) ); let chartMonths = lineAreaData.map( d => parseInt(Object.keys(d)[0]) );
...@@ -804,7 +804,7 @@ const updateCharts = () => { ...@@ -804,7 +804,7 @@ const updateCharts = () => {
}); });
// update charts ranges // update charts ranges
let lineDateAxis = linesChart.xAxes.values[0]; let lineDateAxis = lineChart.xAxes.values[0];
lineDateAxis.axisRanges.clear(); lineDateAxis.axisRanges.clear();
makeDateRange(lineDateAxis, 0, 2, "#E1DBC8"); makeDateRange(lineDateAxis, 0, 2, "#E1DBC8");
makeDateRange(lineDateAxis, 2, 2, "#595952"); makeDateRange(lineDateAxis, 2, 2, "#595952");
...@@ -812,7 +812,7 @@ const updateCharts = () => { ...@@ -812,7 +812,7 @@ const updateCharts = () => {
makeDateRange(lineDateAxis, 8, 3, "#B1AE9F"); makeDateRange(lineDateAxis, 8, 3, "#B1AE9F");
makeDateRange(lineDateAxis, 11, 1, "#E1DBC8"); makeDateRange(lineDateAxis, 11, 1, "#E1DBC8");
let areaDateAxis = stackedAreaChart.xAxes.values[0]; let areaDateAxis = areaChart.xAxes.values[0];
areaDateAxis.axisRanges.clear(); areaDateAxis.axisRanges.clear();
makeDateRange(areaDateAxis, 0, 2, "#E1DBC8"); makeDateRange(areaDateAxis, 0, 2, "#E1DBC8");
makeDateRange(areaDateAxis, 2, 2, "#595952"); makeDateRange(areaDateAxis, 2, 2, "#595952");
...@@ -822,15 +822,15 @@ const updateCharts = () => { ...@@ -822,15 +822,15 @@ const updateCharts = () => {
// updte chart data // updte chart data
chartData.sort((a, b) => (a.date > b.date) ? 1 : -1); chartData.sort((a, b) => (a.date > b.date) ? 1 : -1);
linesChart.data = chartData; lineChart.data = chartData;
linesChart.invalidateRawData(); lineChart.invalidateRawData();
stackedAreaChart.data = chartData; areaChart.data = chartData;
stackedAreaChart.invalidateRawData(); areaChart.invalidateRawData();
}); });
// update bar chart // update bar chart
let barChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "dimfrcpo-graph"); let barChart = am4core.registry.baseSprites.find(c => c.htmlContainer.id === "barChart");
previouslyQueriedMonths.sort((a, b) => (a > b) ? 1 : -1); previouslyQueriedMonths.sort((a, b) => (a > b) ? 1 : -1);
// TODO: how to use this previouslyQueriedMonths varr for all charts? // TODO: how to use this previouslyQueriedMonths varr for all charts?
// If it is set in one chart, it may affect all others. // If it is set in one chart, it may affect all others.
......
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