Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fordecyt_2019
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
fordecyt_2019
Commits
c7e76d28
Commit
c7e76d28
authored
Dec 09, 2020
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start adapting from d3 to amcharts
parent
46f6307d
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
277 deletions
+12
-277
cuerpos_basemap.js
public/js/cuerpos_basemap.js
+7
-237
cuerpos_functions.js
public/js/cuerpos_functions.js
+5
-40
No files found.
public/js/cuerpos_basemap.js
View file @
c7e76d28
This diff is collapsed.
Click to expand it.
public/js/cuerpos_functions.js
View file @
c7e76d28
...
@@ -361,41 +361,8 @@ const getMinMax = table => {
...
@@ -361,41 +361,8 @@ const getMinMax = table => {
const
populateMap
=
async
(
mapData
)
=>
{
const
populateMap
=
async
(
mapData
)
=>
{
const
chartData
=
await
getData
();
//const chartData = await getData();
// call amchart here
// Define charts with reusable components
indicators
.
map
(
async
(
indicator
,
index
)
=>
{
// indicatorVars[indicator].chart gives areaChart, perimeterChart, etc.
// First, make all charts with same general options
indicatorVars
[
indicator
].
chart
=
makeIndicatorGraph
()
.
width
(
Math
.
floor
(
$
(
indicatorVars
[
indicator
].
container
)[
0
].
offsetParent
.
offsetWidth
*
0.95
))
.
height
(
Math
.
floor
(
$
(
indicatorVars
[
indicator
].
container
)[
0
].
offsetParent
.
offsetHeight
*
0.95
))
.
lineVariables
([
`
${
indicator
}
0`
])
// d.area is used to draw stuff on y axis
.
displayName
(
"date"
)
// d.date is used to draw stuff on x axis
.
lineAxisLabel
(
"(m)"
)
.
id
(
indicator
)
.
xAxisFormat
(
d3
.
timeFormat
(
"%b '%y"
))
// label x axis as mm 'yy
.
yAxisFormat
(
d3
.
format
(
indicatorsxAxisFormat
[
index
]))
// yAxis label in SI or other
// Then, specify some parameters for each chart
.
tooltipUnits
(
indicatorsUnits
[
index
])
.
tooltipFormat
(
d3
.
format
(
indicatorsxAxisFormat
[
index
]))
// tooltip format in SI or other
.
title
(
indicatorsUnits
[
index
]
==
""
?
indicatorsNames
[
index
]
:
`
${
indicatorsNames
[
index
]}
(
${
indicatorsUnits
[
index
]}
)`
);
// Finally, set chart data with async function calling stuff from DB
indicatorVars
[
indicator
].
chart
.
data
(
chartData
[
indicator
]);
// create chart with passed options
d3
.
select
(
indicatorVars
[
indicator
].
container
)
.
call
(
indicatorVars
[
indicator
].
chart
);
// Reload chart data and force chart update
indicatorVars
[
indicator
].
chartData
=
indicatorVars
[
indicator
].
chart
.
data
();
// get chart data
indicatorVars
[
indicator
].
chart
.
data
(
indicatorVars
[
indicator
].
chartData
);
// set chart data
// Highlight plot title according to selected option
let
option
=
$
(
"#indicatorSelect"
).
val
();
// option selected from dropdrown
d3
.
select
(
indicatorVars
[
option
].
container
).
select
(
"svg text.title"
).
classed
(
"active"
,
true
);
});
let
map
=
mapData
.
map
,
let
map
=
mapData
.
map
,
minIndicators
=
mapData
.
minIndicators
,
minIndicators
=
mapData
.
minIndicators
,
...
@@ -413,8 +380,6 @@ const populateMap = async (mapData) => {
...
@@ -413,8 +380,6 @@ const populateMap = async (mapData) => {
});
});
let
cuencaBufferMask
=
omnivore
.
topojson
(
"data/buffer_cuenca.topojson"
,
null
,
cuencaLayer
);
let
cuencaBufferMask
=
omnivore
.
topojson
(
"data/buffer_cuenca.topojson"
,
null
,
cuencaLayer
);
cuencaBufferMask
.
addTo
(
map
);
cuencaBufferMask
.
addTo
(
map
);
//map.createPane("wb-Tiles");
//map.getPane("wb-Tiles").style.zIndex = 450;
// create mvt layers
// create mvt layers
userFiles
.
forEach
(
f
=>
{
userFiles
.
forEach
(
f
=>
{
...
@@ -579,7 +544,7 @@ const updateMap = (mapData) => {
...
@@ -579,7 +544,7 @@ const updateMap = (mapData) => {
//.then(legend.addTo(map)); // add legend control -> it updates
//.then(legend.addTo(map)); // add legend control -> it updates
});
});
// Update charts
// Update charts
updateCharts
();
//
updateCharts();
}
}
const
updateCharts
=
async
()
=>
{
const
updateCharts
=
async
()
=>
{
...
@@ -722,10 +687,10 @@ L.TimeDimension.Layer.Tile = L.TimeDimension.Layer.extend({
...
@@ -722,10 +687,10 @@ L.TimeDimension.Layer.Tile = L.TimeDimension.Layer.extend({
title
.
html
(
`<h2>Cobertura de agua en la cuenca del río Grijalva en
${
month
}
de
${
year
}
</h2>`
);
title
.
html
(
`<h2>Cobertura de agua en la cuenca del río Grijalva en
${
month
}
de
${
year
}
</h2>`
);
// Update graphs only on timeload event
// Update graphs only on timeload event
indicators
.
forEach
(
indicator
=>
{
/*
indicators.forEach( indicator => {
indicatorVars[indicator].chartData = indicatorVars[indicator].chart.data(); // get chart data
indicatorVars[indicator].chartData = indicatorVars[indicator].chart.data(); // get chart data
indicatorVars[indicator].chart.data(indicatorVars[indicator].chartData); // set chart data
indicatorVars[indicator].chart.data(indicatorVars[indicator].chartData); // set chart data
});
});
*/
//console.time("process");
//console.time("process");
//console.log("data for", monthYear);
//console.log("data for", monthYear);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment