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
1dcf9d65
Commit
1dcf9d65
authored
Apr 11, 2013
by
Zachary Tong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up, commenting
parent
88609fbe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
139 deletions
+74
-139
panels/map2/display/binning.js
+17
-16
panels/map2/display/bullseye.js
+5
-6
panels/map2/display/geopoints.js
+8
-36
panels/map2/module.js
+44
-81
No files found.
panels/map2/display/binning.js
View file @
1dcf9d65
/**
* Hexagonal binning
* Rendered as normally projected svg paths, which mean they *do not*
* clip on spheres appropriately. To fix this, we would need to translate
* the svg path into a geo-path
*/
function
displayBinning
(
scope
,
dimensions
)
{
function
displayBinning
(
scope
,
dimensions
,
projection
,
path
)
{
/**
* Hexbin-specific setup
*/
var
hexbin
=
d3
.
hexbin
()
.
size
(
dimensions
)
.
radius
(
scope
.
panel
.
display
.
binning
.
hexagonSize
);
...
...
@@ -16,10 +17,13 @@ function displayBinning(scope, dimensions, projection, path) {
if
(
scope
.
panel
.
display
.
binning
.
enabled
)
{
//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
/**
* 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
=
50
/
max
;
...
...
@@ -27,12 +31,11 @@ function displayBinning(scope, dimensions, projection, path) {
_
.
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
]));
binPoints
.
push
(
scope
.
projection
([
decoded
.
longitude
,
decoded
.
latitude
]));
})
});
}
else
{
binPoints
=
scope
.
projectedPoints
;
}
...
...
@@ -43,6 +46,8 @@ function displayBinning(scope, dimensions, projection, path) {
//clean up some memory
binPoints
=
[];
}
else
{
//not enabled, so just set an empty array. D3.exit will take care of the rest
binnedPoints
=
[];
binRange
=
0
;
}
...
...
@@ -59,10 +64,6 @@ function displayBinning(scope, dimensions, projection, path) {
.
interpolate
(
d3
.
interpolateLab
);
/**
* D3 Drawing
*/
var
hex
=
scope
.
g
.
selectAll
(
".hexagon"
)
.
data
(
binnedPoints
);
...
...
panels/map2/display/bullseye.js
View file @
1dcf9d65
function
displayBullseye
(
scope
,
projection
,
path
)
{
/**
* Renders bullseyes as geo-json poly gon entities
* Allows for them to clip on spheres correctly
*/
function
displayBullseye
(
scope
,
path
)
{
var
degrees
=
180
/
Math
.
PI
var
circle
=
d3
.
geo
.
circle
();
var
data
=
[];
if
(
scope
.
panel
.
display
.
bullseye
.
enabled
)
{
...
...
@@ -13,11 +14,9 @@ function displayBullseye(scope, projection, path) {
];
}
var
arcs
=
scope
.
g
.
selectAll
(
".arc"
)
.
data
(
data
);
arcs
.
enter
().
append
(
"path"
)
.
datum
(
function
(
d
)
{
return
circle
.
origin
([
d
.
lon
,
d
.
lat
]).
angle
(
1000
/
6371
*
degrees
)();
...
...
panels/map2/display/geopoints.js
View file @
1dcf9d65
/**
* Renders geopoints as geo-json poly gon entities
* Allows for them to clip on spheres correctly
*/
function
displayGeopoints
(
scope
,
path
)
{
/*
var points = {};
var circle = d3.geo.circle();
var degrees = 180 / Math.PI;
if (scope.panel.display.geopoints.enabled) {
//points = scope.points;
var features = _.map(scope.points, function(coords) {
return {
feature: circle.origin(scope.projection([coords[0], coords[1]]))
.angle(scope.panel.display.geopoints.pointSize / 6371 * degrees)()
};
});
console.log("features", features);
points = {
type: "FeatureCollection",
features: features
};
console.log("points", points);
}
console.log("points2", points);
scope.svg.append("path")
.datum(points)
.attr("d", d3.geo.path());
*/
var
points
=
[];
var
circle
=
d3
.
geo
.
circle
();
var
degrees
=
180
/
Math
.
PI
var
points
=
[]
if
(
scope
.
panel
.
display
.
geopoints
.
enabled
)
{
points
=
scope
.
points
;
}
var
circle
=
d3
.
geo
.
circle
();
var
degrees
=
180
/
Math
.
PI
var
geopoints
=
scope
.
g
.
selectAll
(
".geopoint"
)
.
data
(
points
);
...
...
panels/map2/module.js
View file @
1dcf9d65
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