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
28bb4d5a
Commit
28bb4d5a
authored
Aug 21, 2019
by
Anne Blankert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve equal interval, classtype radio buttons
parent
85680389
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
41 deletions
+39
-41
attrinfo.html
public/attrinfo.html
+19
-12
ticks.js
public/ticks.js
+20
-29
No files found.
public/attrinfo.html
View file @
28bb4d5a
...
@@ -372,7 +372,8 @@
...
@@ -372,7 +372,8 @@
}
}
function
classButton
(
classType
)
{
function
classButton
()
{
let
classType
=
document
.
querySelector
(
'input[name="classtype"]:checked'
).
value
;
if
(
prepareLegend
())
{
if
(
prepareLegend
())
{
let
classCount
=
Number
(
document
.
querySelector
(
'#classcount'
).
value
);
let
classCount
=
Number
(
document
.
querySelector
(
'#classcount'
).
value
);
if
(
classCount
===
1
)
{
if
(
classCount
===
1
)
{
...
@@ -458,18 +459,18 @@
...
@@ -458,18 +459,18 @@
if
(
typeof
min
===
"number"
)
{
if
(
typeof
min
===
"number"
)
{
const
intervalSchemes
=
getColorSchemes
(
classCount
,
'seq'
);
const
intervalSchemes
=
getColorSchemes
(
classCount
,
'seq'
);
classCount
=
intervalSchemes
[
0
].
colors
.
length
;
classCount
=
intervalSchemes
[
0
].
colors
.
length
;
let
classTicks
=
getClassTicks
(
min
,
max
,
classCount
);
let
classTicks
=
get
Interval
ClassTicks
(
min
,
max
,
classCount
);
mapboxPaint
=
[
"case"
]
mapboxPaint
=
[
"case"
]
;
for
(
let
index
=
0
,
from
=
classTicks
.
min
;
from
<
classTicks
.
max
;
from
+=
classTicks
.
tickWidth
,
index
++
)
{
classTicks
.
classes
.
forEach
((
classStart
,
index
)
=>
{
let
legendFrom
=
(
from
).
toFixed
(
classTicks
.
decimals
)
;
let
legendFrom
=
classStart
;
let
legendTo
=
(
index
===
classCount
-
1
?
classTicks
.
max
:
from
+
classTicks
.
tickWidth
).
toFixed
(
classTicks
.
decimals
);
let
legendTo
=
(
index
===
classCount
-
1
?
classTicks
.
max
:
classTicks
.
classes
[
index
+
1
]
);
if
(
globalStats
.
datatype
===
'int4'
||
globalStats
.
datatype
===
'int8'
)
{
if
(
globalStats
.
datatype
===
'int4'
||
globalStats
.
datatype
===
'int8'
)
{
legendFrom
=
Math
.
floor
(
legendFrom
);
legendFrom
=
Math
.
floor
(
legendFrom
);
legendTo
=
Math
.
floor
(
legendTo
);
legendTo
=
Math
.
floor
(
legendTo
);
}
}
addLegendLine
(
intervalSchemes
[
0
].
colors
[
index
],
`
${(
legendFrom
)}
-
${
legendTo
}
`
,
layerType
);
addLegendLine
(
intervalSchemes
[
0
].
colors
[
index
],
`
${(
legendFrom
)}
-
${
legendTo
}
`
,
layerType
);
mapboxPaint
.
push
([
"<"
,
[
"get"
,
globalStats
.
column
],
from
+
classTicks
.
tickWidth
],
intervalSchemes
[
0
].
colors
[
index
]);
mapboxPaint
.
push
([
"<"
,
[
"get"
,
globalStats
.
column
],
legendTo
],
intervalSchemes
[
0
].
colors
[
index
]);
}
}
)
mapboxPaint
.
push
(
intervalSchemes
[
0
].
colors
[
classCount
-
1
])
mapboxPaint
.
push
(
intervalSchemes
[
0
].
colors
[
classCount
-
1
])
}
}
break
;
break
;
...
@@ -526,10 +527,16 @@
...
@@ -526,10 +527,16 @@
<option
value=
"11"
>
11
</option>
<option
value=
"11"
>
11
</option>
<option
value=
"12"
>
12
</option>
<option
value=
"12"
>
12
</option>
</select><label
for=
"numclasses"
>
number of classes
</label><br>
</select><label
for=
"numclasses"
>
number of classes
</label><br>
<button
onclick=
"classButton('interval')"
>
equal interval
</button>
Classification methods:
<br>
<button
onclick=
"classButton('quantile')"
>
quantile
</button>
<input
type=
"radio"
name=
"classtype"
id=
"interval"
value=
"interval"
><label
for=
"interval"
>
equal interval
</label>
<button
onclick=
"classButton('mostfrequent')"
>
most frequent
</button><br>
<input
type=
"radio"
name=
"classtype"
id=
"quantile"
value=
"quantile"
checked
><label
for=
"quantile"
>
quantile
</label>
<input
type=
"checkbox"
id=
"hidenulls"
name=
"hidenulls"
checked
><label
for=
"hidenulls"
>
Hide no-data
</label>
<input
type=
"radio"
name=
"classtype"
id=
"mostfrequent"
value=
"mostfrequent"
><label
for=
"mostfrequent"
>
most frequent
</label><br>
Color schemes:
<br>
<input
type=
"radio"
name=
"colorscheme"
id=
"seqential"
value=
"seq"
><label
for=
"sequential"
>
sequential
</label>
<input
type=
"radio"
name=
"colorscheme"
id=
"diverting"
value=
"div"
><label
for=
"diverting"
>
diverting
</label>
<input
type=
"radio"
name=
"colorscheme"
id=
"diverting"
value=
"qual"
><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>
</div>
</div>
</div>
<div
id=
"featureinfo"
></div>
<div
id=
"featureinfo"
></div>
...
...
public/ticks.js
View file @
28bb4d5a
function
niceNumbers
(
range
,
round
)
{
function
roundToPrecision
(
number
,
precision
,
direction
)
{
const
exponent
=
Math
.
floor
(
Math
.
log10
(
range
));
let
negative
=
(
number
<
0
);
const
fraction
=
range
/
Math
.
pow
(
10
,
exponent
);
if
(
negative
)
{
let
niceFraction
;
number
=
-
number
;
if
(
round
)
{
direction
=
-
direction
;
if
(
fraction
<
1.5
)
niceFraction
=
1
;
else
if
(
fraction
<
3
)
niceFraction
=
2
;
else
if
(
fraction
<
7
)
niceFraction
=
5
;
else
niceFraction
=
10
;
}
else
{
niceFraction
=
Math
.
ceil
(
fraction
);
}
}
return
niceFraction
*
Math
.
pow
(
10
,
exponent
);
let
roundFunc
=
(
direction
<
0
?
Math
.
floor
:
direction
===
0
?
Math
.
round
:
Math
.
ceil
);
let
exponent
=
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
));
}
}
function
getClassTicks
(
min
,
max
,
maxTicks
)
{
function
getIntervalClassTicks
(
min
,
max
,
classCount
)
{
const
range
=
niceNumbers
(
max
-
min
,
false
);
let
niceMin
=
roundToPrecision
(
min
,
2
,
-
1
);
let
decimals
=
0
;
let
niceMax
=
roundToPrecision
(
max
,
2
,
1
);
let
tickSpacing
;
let
interval
=
(
niceMax
-
niceMin
)
/
classCount
;
if
(
range
===
0
)
{
let
result
=
[];
tickSpacing
=
1
;
for
(
let
i
=
0
;
i
<
classCount
;
i
++
)
{
}
else
{
result
.
push
(
roundToPrecision
(
niceMin
+
i
*
interval
,
2
,
-
1
))
tickSpacing
=
range
/
maxTicks
;
let
exponent
=
Math
.
floor
(
Math
.
log10
(
tickSpacing
));
tickSpacing
=
(
Math
.
ceil
(
100
*
(
tickSpacing
/
Math
.
pow
(
10
,
exponent
)))
/
100
)
*
Math
.
pow
(
10
,
exponent
);
if
(
exponent
<
2
)
{
decimals
=
2
-
exponent
;
}
}
}
return
{
return
{
min
:
Math
.
floor
(
min
/
tickSpacing
)
*
tickSpacing
,
min
:
niceMin
,
max
:
Math
.
ceil
(
max
/
tickSpacing
)
*
tickSpacing
,
max
:
niceMax
,
tickWidth
:
tickSpacing
,
classes
:
result
decimals
:
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