Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4f3f29b8
Commit
4f3f29b8
authored
Apr 08, 2013
by
Zachary Tong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
f18b90a9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
panels/map2/display/binning.js
+76
-0
panels/map2/display/geopoints.js
+12
-0
panels/map2/module.js
+0
-0
No files found.
panels/map2/display/binning.js
0 → 100644
View file @
4f3f29b8
function
displayBinning
()
{
/**
* Hexbin-specific setup
*/
var
hexbin
=
d3
.
hexbin
()
.
size
([
width
,
height
])
.
radius
(
scope
.
panel
.
display
.
binning
.
hexagonSize
);
var
binPoints
=
[];
//primary field is just binning raw counts
//secondary field is binning some metric like mean/median/total. Hexbins doesn't support that,
//so we cheat a little and just add more points to compensate.
//However, we don't want to add a million points, so normalize against the largest value
if
(
scope
.
panel
.
display
.
binning
.
areaEncodingField
===
'secondary'
)
{
var
max
=
Math
.
max
.
apply
(
Math
,
_
.
map
(
scope
.
data
,
function
(
k
,
v
){
return
k
;})),
scale
=
10
/
max
;
_
.
map
(
scope
.
data
,
function
(
k
,
v
)
{
var
decoded
=
geohash
.
decode
(
v
);
return
_
.
map
(
_
.
range
(
0
,
k
*
scale
),
function
(
a
,
b
)
{
binPoints
.
push
(
projection
([
decoded
.
longitude
,
decoded
.
latitude
]));
})
});
}
else
{
binPoints
=
points
;
}
//bin and sort the points, so we can set the various ranges appropriately
var
binnedPoints
=
hexbin
(
binPoints
).
sort
(
function
(
a
,
b
)
{
return
b
.
length
-
a
.
length
;
});;
//clean up some memory
binPoints
=
[];
var
radius
=
d3
.
scale
.
sqrt
()
.
domain
([
0
,
binnedPoints
[
0
].
length
])
.
range
([
0
,
scope
.
panel
.
display
.
binning
.
hexagonSize
]);
var
color
=
d3
.
scale
.
linear
()
.
domain
([
0
,
binnedPoints
[
0
].
length
])
.
range
([
"white"
,
"steelblue"
])
.
interpolate
(
d3
.
interpolateLab
);
/**
* D3 Drawing
*/
g
.
selectAll
(
".hexagon"
)
.
data
(
binnedPoints
)
.
enter
().
append
(
"path"
)
.
attr
(
"d"
,
function
(
d
)
{
if
(
scope
.
panel
.
display
.
binning
.
areaEncoding
===
false
)
{
return
hexbin
.
hexagon
();
}
else
{
return
hexbin
.
hexagon
(
radius
(
d
.
length
));
}
})
.
attr
(
"class"
,
"hexagon"
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
d
.
x
+
","
+
d
.
y
+
")"
;
})
.
style
(
"fill"
,
function
(
d
)
{
if
(
scope
.
panel
.
display
.
binning
.
colorEncoding
===
false
)
{
return
color
(
binnedPoints
[
0
].
length
/
2
);
}
else
{
return
color
(
d
.
length
);
}
})
.
attr
(
"opacity"
,
scope
.
panel
.
display
.
binning
.
hexagonAlpha
);
}
\ No newline at end of file
panels/map2/display/geopoints.js
0 → 100644
View file @
4f3f29b8
function
displayGeopoints
()
{
g
.
selectAll
(
"circles.points"
)
.
data
(
points
)
.
enter
()
.
append
(
"circle"
)
.
attr
(
"r"
,
scope
.
panel
.
display
.
geopoints
.
pointSize
)
.
attr
(
"opacity"
,
scope
.
panel
.
display
.
geopoints
.
pointAlpha
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
d
[
0
]
+
","
+
d
[
1
]
+
")"
;
});
}
\ No newline at end of file
panels/map2/module.js
View file @
4f3f29b8
This diff is collapsed.
Click to expand it.
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