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
fb6dab19
Commit
fb6dab19
authored
Aug 20, 2019
by
Anne Blankert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update layerjson, support layer types in legend
parent
e6ae7109
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
11 deletions
+37
-11
attrinfo.html
public/attrinfo.html
+37
-11
No files found.
public/attrinfo.html
View file @
fb6dab19
...
@@ -175,8 +175,9 @@
...
@@ -175,8 +175,9 @@
//"filter": ['has', attrName]
//"filter": ['has', attrName]
}
}
map
.
addLayer
(
layer
);
map
.
addLayer
(
layer
);
addLegendLine
(
'red'
,
fullTableName
);
addLegendLine
(
'red'
,
fullTableName
,
layerType
);
document
.
querySelector
(
"#layerjson"
).
innerHTML
=
`<pre>
${
JSON
.
stringify
(
layer
,
null
,
2
)}
</pre>`
;
updateLayerJsonDisplay
();
}
}
})
})
map
.
on
(
'mousemove'
,
function
(
e
)
{
map
.
on
(
'mousemove'
,
function
(
e
)
{
...
@@ -185,6 +186,12 @@
...
@@ -185,6 +186,12 @@
});
});
}
}
function
updateLayerJsonDisplay
()
{
const
layerjson
=
map
.
getStyle
().
layers
.
filter
(
l
=>
l
.
id
===
'attrlayer'
)[
0
];
layerjson
.
source
=
map
.
getSource
(
layerjson
.
source
).
serialize
();
document
.
querySelector
(
"#layerjson"
).
innerHTML
=
`<pre>
${
JSON
.
stringify
(
layerjson
,
null
,
2
)}
</pre>`
;
}
function
addCanvas
()
{
function
addCanvas
()
{
const
container
=
document
.
createElement
(
'div'
);
const
container
=
document
.
createElement
(
'div'
);
container
.
classList
.
add
(
'canvascontainer'
);
container
.
classList
.
add
(
'canvascontainer'
);
...
@@ -201,7 +208,7 @@
...
@@ -201,7 +208,7 @@
new
Chart
(
addCanvas
(),
{
new
Chart
(
addCanvas
(),
{
type
:
'doughnut'
,
type
:
'doughnut'
,
data
:
{
data
:
{
labels
:
[
'n
ull'
,
'non-null
'
,],
labels
:
[
'n
o data'
,
'data
'
,],
datasets
:
[{
datasets
:
[{
backgroundColor
:
[
'lightgray'
,
'red'
],
backgroundColor
:
[
'lightgray'
,
'red'
],
borderColor
:
'white'
,
borderColor
:
'white'
,
...
@@ -290,11 +297,29 @@
...
@@ -290,11 +297,29 @@
})
})
}
}
function
addLegendLine
(
color
,
label
)
{
function
addLegendLine
(
color
,
label
,
type
)
{
if
(
!
type
)
{
type
=
'fill'
;
}
const
legend
=
document
.
querySelector
(
'#legend'
);
const
legend
=
document
.
querySelector
(
'#legend'
);
const
svg
=
`<svg width="30" height="15">
let
svg
;
switch
(
type
)
{
case
'fill'
:
svg
=
`<svg width="30" height="15">
<rect width="30" height="15" style="fill:
${
color
}
;fill-opacity:1;stroke-width:1;stroke:#444"></rect>
<rect width="30" height="15" style="fill:
${
color
}
;fill-opacity:1;stroke-width:1;stroke:#444"></rect>
</svg>`
</svg>`
break
;
case
'line'
:
svg
=
`<svg width="30" height="15">
<line x1="0" y1="15" x2="30" y2="0" style="stroke:
${
color
}
;stroke-width:
${
color
.
width
}
;" />
</svg>`
break
;
case
'circle'
:
svg
=
`<svg width="12" height="12">
<circle cx="6" cy="6" r="5" style="fill:
${
color
}
;fill-opacity:1 stroke-width:1;stroke:white" />
</svg>`
}
const
legendLine
=
document
.
createElement
(
'div'
);
const
legendLine
=
document
.
createElement
(
'div'
);
legendLine
.
innerHTML
=
`<div> <span>
${
svg
}
</span> <span>
${
label
}
<span></div>`
legendLine
.
innerHTML
=
`<div> <span>
${
svg
}
</span> <span>
${
label
}
<span></div>`
legend
.
appendChild
(
legendLine
);
legend
.
appendChild
(
legendLine
);
...
@@ -334,6 +359,7 @@
...
@@ -334,6 +359,7 @@
// special case, single classification
// special case, single classification
}
else
{
}
else
{
// classCount > 1
// classCount > 1
const
layerType
=
map
.
getLayer
(
'attrlayer'
).
type
;
const
rowCount
=
globalStats
.
percentiles
.
reduce
((
result
,
percentile
)
=>
result
+
percentile
.
count
,
0
);
const
rowCount
=
globalStats
.
percentiles
.
reduce
((
result
,
percentile
)
=>
result
+
percentile
.
count
,
0
);
let
classValues
=
globalStats
.
values
.
filter
(
value
=>
value
.
value
!==
null
);
let
classValues
=
globalStats
.
values
.
filter
(
value
=>
value
.
value
!==
null
);
if
(
classValues
.
length
>
classCount
)
{
if
(
classValues
.
length
>
classCount
)
{
...
@@ -346,19 +372,19 @@
...
@@ -346,19 +372,19 @@
const
schemes
=
getColorSchemes
(
classCount
,
'qual'
);
const
schemes
=
getColorSchemes
(
classCount
,
'qual'
);
const
mapboxPaint
=
[
const
mapboxPaint
=
[
"match"
,
"match"
,
[
"get"
,
"bicycle"
]
[
"get"
,
`
${
globalStats
.
column
}
`
]
];
];
classValues
.
forEach
((
value
,
index
)
=>
{
classValues
.
forEach
((
value
,
index
)
=>
{
addLegendLine
(
schemes
[
0
].
colors
[
index
],
value
.
value
);
addLegendLine
(
schemes
[
0
].
colors
[
index
],
value
.
value
,
layerType
);
if
(
value
.
value
!==
'other'
)
{
if
(
value
.
value
!==
'other'
)
{
mapboxPaint
.
push
(
value
.
value
);
mapboxPaint
.
push
(
value
.
value
);
mapboxPaint
.
push
(
schemes
[
0
].
colors
[
index
]);
mapboxPaint
.
push
(
schemes
[
0
].
colors
[
index
]);
}
}
});
});
mapboxPaint
.
push
(
schemes
[
0
].
colors
[
classValues
.
length
-
1
]);
mapboxPaint
.
push
(
schemes
[
0
].
colors
[
classValues
.
length
-
1
]);
const
layerType
=
map
.
getLayer
(
'attrlayer'
).
type
;
const
colorprop
=
`
${
layerType
}
-color`
;
const
colorprop
=
`
${
layerType
}
-color`
;
map
.
setPaintProperty
(
'attrlayer'
,
colorprop
,
mapboxPaint
);
map
.
setPaintProperty
(
'attrlayer'
,
colorprop
,
mapboxPaint
);
updateLayerJsonDisplay
();
}
}
}
}
...
@@ -408,7 +434,7 @@
...
@@ -408,7 +434,7 @@
<button
onclick=
"classButton('interval')"
>
equal interval
</button>
<button
onclick=
"classButton('interval')"
>
equal interval
</button>
<button
onclick=
"classButton('quantile')"
>
quantile
</button>
<button
onclick=
"classButton('quantile')"
>
quantile
</button>
<button
onclick=
"classButton('qualitative')"
>
qualitative
</button><br>
<button
onclick=
"classButton('qualitative')"
>
qualitative
</button><br>
<input
type=
"checkbox"
id=
"hidenulls"
name=
"hidenulls"
checked
><label
for=
"hidenulls"
>
Hide n
ull values
</label>
<input
type=
"checkbox"
id=
"hidenulls"
name=
"hidenulls"
checked
><label
for=
"hidenulls"
>
Hide n
o-data
</label>
<div
id=
"legend"
></div>
<div
id=
"legend"
></div>
</div>
</div>
<div
id=
"featureinfo"
></div>
<div
id=
"featureinfo"
></div>
...
...
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