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
e1f783a4
Commit
e1f783a4
authored
Aug 22, 2019
by
Anne Blankert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto update legend/map, fix for log10(0)
parent
c095554f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
attrinfo.html
public/attrinfo.html
+6
-3
ticks.js
public/ticks.js
+1
-1
No files found.
public/attrinfo.html
View file @
e1f783a4
...
...
@@ -78,6 +78,7 @@
document
.
querySelector
(
'#columnname'
).
innerHTML
=
`Attribute:
${
attrName
}
(
${
attrType
}
)`
;
document
.
querySelector
(
'#back'
).
innerHTML
=
`<a href="tableinfo.html?table=
${
fullTableName
}
&geom_column=
${
geomColumn
}
">Back to layer info</a>`
;
document
.
querySelectorAll
(
'[name="colorscheme"]'
).
forEach
(
radio
=>
radio
.
onchange
=
updateLegendColorSchemes
);
document
.
querySelectorAll
(
'[name="classtype"]'
).
forEach
(
radio
=>
radio
.
onchange
=
applyLegendToMap
);
document
.
querySelector
(
'#classcount'
).
onchange
=
classCountChanged
;
initMap
();
...
...
@@ -402,6 +403,7 @@
schemeDiv
.
querySelectorAll
(
'div'
).
forEach
(
div
=>
div
.
classList
.
remove
(
'selected'
));
schemeDiv
.
querySelectorAll
(
'div'
).
forEach
((
div
,
index
)
=>
{
if
(
index
===
schemeIndex
)
{
div
.
classList
.
add
(
'selected'
)}});
selectedColorScheme
=
schemeIndex
;
applyLegendToMap
();
}
function
classCountChanged
()
{
...
...
@@ -432,9 +434,10 @@
ramp
.
onclick
=
()
=>
selectColorScheme
(
schemeIndex
);
schemeDiv
.
appendChild
(
ramp
);
})
applyLegendToMap
();
}
function
classButton
()
{
function
applyLegendToMap
()
{
let
classType
=
document
.
querySelector
(
'input[name="classtype"]:checked'
).
value
;
if
(
prepareLegend
())
{
let
classCount
=
Number
(
document
.
querySelector
(
'#classcount'
).
value
);
...
...
@@ -448,6 +451,8 @@
let
schemeType
=
document
.
querySelector
(
'input[name="colorscheme"]:checked'
).
value
;
switch
(
classType
)
{
case
'mostfrequent'
:
const
schemes
=
getColorSchemes
(
classCount
,
schemeType
);
classCount
=
schemes
[
0
].
colors
.
length
;
let
classValues
=
globalStats
.
values
.
filter
(
value
=>
value
.
value
!==
null
);
const
needsSlice
=
classValues
.
length
>
classCount
;
if
(
needsSlice
)
{
...
...
@@ -458,7 +463,6 @@
count
:
rowCount
-
classValuesRowCount
})
}
const
schemes
=
getColorSchemes
(
classCount
,
schemeType
);
if
(
globalStats
.
datatype
===
'numeric'
)
{
mapboxPaint
=
[
"match"
,
...
...
@@ -615,7 +619,6 @@
<input
type=
"radio"
name=
"colorscheme"
id=
"diverting"
value=
"div"
><label
for=
"diverting"
>
diverting
</label>
<input
type=
"radio"
name=
"colorscheme"
id=
"qualitative"
value=
"qual"
checked
><label
for=
"qualitative"
>
qualitative
</label><br>
<input
type=
"checkbox"
id=
"hidenulls"
name=
"hidenulls"
checked
><label
for=
"hidenulls"
>
Hide no-data
</label><br>
<button
onclick=
"classButton()"
>
update legend
</button><br>
<div
id=
"colorschemes"
></div>
</div>
</div>
...
...
public/ticks.js
View file @
e1f783a4
...
...
@@ -5,7 +5,7 @@ function roundToPrecision(number, precision, direction) {
direction
=
-
direction
;
}
let
roundFunc
=
(
direction
<
0
?
Math
.
floor
:
direction
===
0
?
Math
.
round
:
Math
.
ceil
);
let
exponent
=
Math
.
floor
(
Math
.
log10
(
number
));
let
exponent
=
(
number
===
0
)?
1
:
Math
.
floor
(
Math
.
log10
(
number
));
let
decimals
=
(
exponent
<
precision
)?
precision
-
exponent
:
0
;
let
fraction
=
number
/
Math
.
pow
(
10
,
exponent
);
return
Number
((
Math
.
pow
(
10
,
exponent
)
*
roundFunc
(
fraction
*
Math
.
pow
(
10
,
precision
))
/
Math
.
pow
(
10
,
precision
)
*
(
negative
?
-
1
:
1
)).
toFixed
(
decimals
));
...
...
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