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
915a0e37
Commit
915a0e37
authored
Apr 18, 2013
by
Zachary Tong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move directive-level variables out of scope
parent
67d5a457
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
67 deletions
+68
-67
panels/parallelcoordinates/module.js
+68
-67
No files found.
panels/parallelcoordinates/module.js
View file @
915a0e37
...
...
@@ -148,6 +148,9 @@ angular.module('kibana.parallelcoordinates', [])
restrict
:
'A'
,
link
:
function
(
scope
,
elem
,
attrs
)
{
//used to store a variety of directive-level variables
var
directive
=
{};
scope
.
initializing
=
false
;
...
...
@@ -155,7 +158,7 @@ angular.module('kibana.parallelcoordinates', [])
* Initialize the panels if new, or render existing panels
*/
scope
.
init_or_render
=
function
()
{
if
(
typeof
scop
e
.
svg
===
'undefined'
)
{
if
(
typeof
directiv
e
.
svg
===
'undefined'
)
{
//prevent duplicate initialization steps, if render is called again
//before the svg is setup
...
...
@@ -189,9 +192,9 @@ angular.module('kibana.parallelcoordinates', [])
*/
function
init_panel
()
{
scop
e
.
m
=
[
80
,
100
,
80
,
100
];
scope
.
w
=
$
(
elem
[
0
]).
width
()
-
scope
.
m
[
1
]
-
scop
e
.
m
[
3
];
scope
.
h
=
$
(
elem
[
0
]).
height
()
-
scope
.
m
[
0
]
-
scop
e
.
m
[
2
];
directiv
e
.
m
=
[
80
,
100
,
80
,
100
];
directive
.
w
=
$
(
elem
[
0
]).
width
()
-
directive
.
m
[
1
]
-
directiv
e
.
m
[
3
];
directive
.
h
=
$
(
elem
[
0
]).
height
()
-
directive
.
m
[
0
]
-
directiv
e
.
m
[
2
];
scope
.
initializing
=
true
;
...
...
@@ -200,22 +203,22 @@ angular.module('kibana.parallelcoordinates', [])
scripts
.
wait
(
function
()
{
directive
.
x
=
d3
.
scale
.
ordinal
().
domain
(
scope
.
panel
.
fields
).
rangePoints
([
0
,
directive
.
w
]);
directive
.
y
=
{};
scope
.
x
=
d3
.
scale
.
ordinal
().
domain
(
scope
.
panel
.
fields
).
rangePoints
([
0
,
scope
.
w
]);
scope
.
y
=
{};
scope
.
line
=
d3
.
svg
.
line
().
interpolate
(
'cardinal'
);
scope
.
axis
=
d3
.
svg
.
axis
().
orient
(
"left"
);
directive
.
line
=
d3
.
svg
.
line
().
interpolate
(
'cardinal'
);
directive
.
axis
=
d3
.
svg
.
axis
().
orient
(
"left"
);
scope
.
svg
=
d3
.
select
(
elem
[
0
]).
append
(
"svg"
)
var
viewbox
=
"0 0 "
+
(
directive
.
w
+
directive
.
m
[
1
]
+
directive
.
m
[
3
])
+
" "
+
(
directive
.
h
+
directive
.
m
[
0
]
+
directive
.
m
[
2
]);
directive
.
svg
=
d3
.
select
(
elem
[
0
]).
append
(
"svg"
)
.
attr
(
"width"
,
"100%"
)
.
attr
(
"height"
,
"100%"
)
.
attr
(
"viewbox"
,
"0 0 "
+
(
scope
.
w
+
scope
.
m
[
1
]
+
scope
.
m
[
3
])
+
" "
+
(
scope
.
h
+
scope
.
m
[
0
]
+
scope
.
m
[
2
])
)
.
attr
(
"viewbox"
,
viewbox
)
.
append
(
"svg:g"
)
.
attr
(
"transform"
,
"translate("
+
scope
.
m
[
3
]
+
","
+
scop
e
.
m
[
0
]
+
")"
);
.
attr
(
"transform"
,
"translate("
+
directive
.
m
[
3
]
+
","
+
directiv
e
.
m
[
0
]
+
")"
);
// Add foreground lines.
scope
.
foreground
=
scop
e
.
svg
.
append
(
"svg:g"
)
directive
.
foreground
=
directiv
e
.
svg
.
append
(
"svg:g"
)
.
attr
(
"class"
,
"foreground"
);
scope
.
initializing
=
false
;
...
...
@@ -227,16 +230,16 @@ angular.module('kibana.parallelcoordinates', [])
// Returns the path for a given data point.
function
path
(
d
)
{
return
scope
.
line
(
scope
.
panel
.
fields
.
map
(
function
(
p
)
{
return
[
scope
.
x
(
p
),
scop
e
.
y
[
p
](
d
[
p
])];
}));
return
directive
.
line
(
scope
.
panel
.
fields
.
map
(
function
(
p
)
{
return
[
directive
.
x
(
p
),
directiv
e
.
y
[
p
](
d
[
p
])];
}));
}
// Handles a brush event, toggling the display of foreground lines.
function
brush
()
{
var
actives
=
scope
.
panel
.
fields
.
filter
(
function
(
p
)
{
return
!
scop
e
.
y
[
p
].
brush
.
empty
();
}),
extents
=
actives
.
map
(
function
(
p
)
{
return
scop
e
.
y
[
p
].
brush
.
extent
();
});
var
actives
=
scope
.
panel
.
fields
.
filter
(
function
(
p
)
{
return
!
directiv
e
.
y
[
p
].
brush
.
empty
();
}),
extents
=
actives
.
map
(
function
(
p
)
{
return
directiv
e
.
y
[
p
].
brush
.
extent
();
});
//.fade class hides the "inactive" lines, helps speed up rendering significantly
scop
e
.
foregroundLines
.
classed
(
"fade"
,
function
(
d
)
{
directiv
e
.
foregroundLines
.
classed
(
"fade"
,
function
(
d
)
{
return
!
actives
.
every
(
function
(
p
,
i
)
{
var
inside
=
extents
[
i
][
0
]
<=
d
[
p
]
&&
d
[
p
]
<=
extents
[
i
][
1
];
return
inside
;
...
...
@@ -260,25 +263,25 @@ angular.module('kibana.parallelcoordinates', [])
//Drag functions are used for dragging the axis aroud
function
dragstart
(
d
)
{
scop
e
.
i
=
scope
.
panel
.
fields
.
indexOf
(
d
);
directiv
e
.
i
=
scope
.
panel
.
fields
.
indexOf
(
d
);
}
function
drag
(
d
)
{
scope
.
x
.
range
()[
scop
e
.
i
]
=
d3
.
event
.
x
;
scope
.
panel
.
fields
.
sort
(
function
(
a
,
b
)
{
return
scope
.
x
(
a
)
-
scop
e
.
x
(
b
);
});
scope
.
foregroundLines
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
scope
.
traits
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
scope
.
brushes
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
scope
.
axisLines
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
scop
e
.
foregroundLines
.
attr
(
"d"
,
path
);
directive
.
x
.
range
()[
directiv
e
.
i
]
=
d3
.
event
.
x
;
scope
.
panel
.
fields
.
sort
(
function
(
a
,
b
)
{
return
directive
.
x
(
a
)
-
directiv
e
.
x
(
b
);
});
directive
.
foregroundLines
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
directive
.
traits
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
directive
.
brushes
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
directive
.
axisLines
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
directiv
e
.
foregroundLines
.
attr
(
"d"
,
path
);
}
function
dragend
(
d
)
{
scope
.
x
.
domain
(
scope
.
panel
.
fields
).
rangePoints
([
0
,
scop
e
.
w
]);
directive
.
x
.
domain
(
scope
.
panel
.
fields
).
rangePoints
([
0
,
directiv
e
.
w
]);
var
t
=
d3
.
transition
().
duration
(
500
);
t
.
selectAll
(
".trait"
).
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
t
.
selectAll
(
".axis"
).
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
t
.
selectAll
(
".brush"
).
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
t
.
selectAll
(
".trait"
).
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
t
.
selectAll
(
".axis"
).
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
t
.
selectAll
(
".brush"
).
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
t
.
selectAll
(
".foregroundlines"
).
attr
(
"d"
,
path
);
}
...
...
@@ -293,21 +296,21 @@ angular.module('kibana.parallelcoordinates', [])
//update the svg if the size has changed
scope
.
w
=
$
(
elem
[
0
]).
width
()
-
scope
.
m
[
1
]
-
scop
e
.
m
[
3
];
scope
.
h
=
$
(
elem
[
0
]).
height
()
-
scope
.
m
[
0
]
-
scop
e
.
m
[
2
];
scope
.
svg
.
attr
(
"viewbox"
,
"0 0 "
+
(
scope
.
w
+
scope
.
m
[
1
]
+
scope
.
m
[
3
])
+
" "
+
(
scope
.
h
+
scope
.
m
[
0
]
+
scop
e
.
m
[
2
]));
directive
.
w
=
$
(
elem
[
0
]).
width
()
-
directive
.
m
[
1
]
-
directiv
e
.
m
[
3
];
directive
.
h
=
$
(
elem
[
0
]).
height
()
-
directive
.
m
[
0
]
-
directiv
e
.
m
[
2
];
directive
.
svg
.
attr
(
"viewbox"
,
"0 0 "
+
(
directive
.
w
+
directive
.
m
[
1
]
+
directive
.
m
[
3
])
+
" "
+
(
directive
.
h
+
directive
.
m
[
0
]
+
directiv
e
.
m
[
2
]));
scope
.
x
=
d3
.
scale
.
ordinal
().
domain
(
scope
.
panel
.
fields
).
rangePoints
([
0
,
scop
e
.
w
]);
scop
e
.
y
=
{};
directive
.
x
=
d3
.
scale
.
ordinal
().
domain
(
scope
.
panel
.
fields
).
rangePoints
([
0
,
directiv
e
.
w
]);
directiv
e
.
y
=
{};
scop
e
.
line
=
d3
.
svg
.
line
().
interpolate
(
'cardinal'
);
scop
e
.
axis
=
d3
.
svg
.
axis
().
orient
(
"left"
);
directiv
e
.
line
=
d3
.
svg
.
line
().
interpolate
(
'cardinal'
);
directiv
e
.
axis
=
d3
.
svg
.
axis
().
orient
(
"left"
);
var
colorExtent
=
d3
.
extent
(
scope
.
data
,
function
(
p
)
{
return
+
p
[
scope
.
panel
.
fields
[
0
]];
});
scop
e
.
colors
=
d3
.
scale
.
linear
()
directiv
e
.
colors
=
d3
.
scale
.
linear
()
.
domain
([
colorExtent
[
0
],
colorExtent
[
1
]])
.
range
([
"#4580FF"
,
"#FF9245"
]);
...
...
@@ -321,19 +324,17 @@ angular.module('kibana.parallelcoordinates', [])
var
value
=
function
(
v
)
{
return
v
[
d
];
};
var
values
=
_
.
map
(
_
.
uniq
(
scope
.
data
,
value
),
value
);
scop
e
.
y
[
d
]
=
d3
.
scale
.
ordinal
()
directiv
e
.
y
[
d
]
=
d3
.
scale
.
ordinal
()
.
domain
(
values
)
.
rangeBands
([
scop
e
.
h
,
0
]);
.
rangeBands
([
directiv
e
.
h
,
0
]);
}
else
if
(
_
.
isNumber
(
scope
.
data
[
0
][
d
]))
{
scop
e
.
y
[
d
]
=
d3
.
scale
.
linear
()
directiv
e
.
y
[
d
]
=
d3
.
scale
.
linear
()
.
domain
(
d3
.
extent
(
scope
.
data
,
function
(
p
)
{
return
+
p
[
d
];
}))
.
range
([
scop
e
.
h
,
0
]);
.
range
([
directiv
e
.
h
,
0
]);
}
scope
.
y
[
d
].
brush
=
d3
.
svg
.
brush
()
.
y
(
scope
.
y
[
d
])
directive
.
y
[
d
].
brush
=
d3
.
svg
.
brush
()
.
y
(
directive
.
y
[
d
])
.
on
(
"brush"
,
brush
);
});
...
...
@@ -349,7 +350,7 @@ angular.module('kibana.parallelcoordinates', [])
//Lines
scope
.
foregroundLines
=
scop
e
.
foreground
directive
.
foregroundLines
=
directiv
e
.
foreground
.
selectAll
(
".foregroundlines"
)
.
data
(
activeData
,
function
(
d
,
i
){
var
id
=
""
;
...
...
@@ -358,39 +359,39 @@ angular.module('kibana.parallelcoordinates', [])
});
return
id
;
});
scop
e
.
foregroundLines
directiv
e
.
foregroundLines
.
enter
().
append
(
"svg:path"
)
.
attr
(
"d"
,
path
)
.
attr
(
"class"
,
"foregroundlines"
)
.
attr
(
"style"
,
function
(
d
)
{
return
"stroke:"
+
scop
e
.
colors
(
d
[
scope
.
panel
.
fields
[
0
]])
+
";"
;
return
"stroke:"
+
directiv
e
.
colors
(
d
[
scope
.
panel
.
fields
[
0
]])
+
";"
;
});
scop
e
.
foregroundLines
.
exit
().
remove
();
directiv
e
.
foregroundLines
.
exit
().
remove
();
//Axis group
scope
.
traits
=
scop
e
.
svg
.
selectAll
(
".trait"
)
directive
.
traits
=
directiv
e
.
svg
.
selectAll
(
".trait"
)
.
data
(
scope
.
panel
.
fields
,
String
);
scop
e
.
traits
directiv
e
.
traits
.
enter
().
append
(
"svg:g"
)
.
attr
(
"class"
,
"trait"
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
scop
e
.
traits
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
directiv
e
.
traits
.
exit
().
remove
();
//brushes used to select lines
scope
.
brushes
=
scop
e
.
svg
.
selectAll
(
".brush"
)
directive
.
brushes
=
directiv
e
.
svg
.
selectAll
(
".brush"
)
.
data
(
scope
.
panel
.
fields
,
String
);
scop
e
.
brushes
directiv
e
.
brushes
.
enter
()
.
append
(
"svg:g"
)
.
attr
(
"class"
,
"brush"
)
.
each
(
function
(
d
)
{
d3
.
select
(
this
)
.
call
(
scop
e
.
y
[
d
].
brush
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
.
call
(
directiv
e
.
y
[
d
].
brush
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
})
.
selectAll
(
"rect"
)
.
attr
(
"x"
,
-
8
)
...
...
@@ -399,29 +400,29 @@ angular.module('kibana.parallelcoordinates', [])
//this section is repeated because enter() only works on "new" data, but we always need to
//update the brushes if things change. This just calls the brushing function, so it doesn't
//affect currently active rects
scop
e
.
brushes
directiv
e
.
brushes
.
each
(
function
(
d
)
{
d3
.
select
(
this
)
.
call
(
scop
e
.
y
[
d
].
brush
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
.
call
(
directiv
e
.
y
[
d
].
brush
)
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
});
scop
e
.
brushes
directiv
e
.
brushes
.
exit
().
remove
();
//vertical axis and labels
scope
.
axisLines
=
scop
e
.
svg
.
selectAll
(
".axis"
)
directive
.
axisLines
=
directiv
e
.
svg
.
selectAll
(
".axis"
)
.
data
(
scope
.
panel
.
fields
,
String
);
scop
e
.
axisLines
directiv
e
.
axisLines
.
enter
()
.
append
(
"svg:g"
)
.
attr
(
"class"
,
"axis"
)
.
each
(
function
(
d
)
{
d3
.
select
(
this
)
.
call
(
scope
.
axis
.
scale
(
scop
e
.
y
[
d
]))
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
scop
e
.
x
(
d
)
+
")"
;
});
.
call
(
directive
.
axis
.
scale
(
directiv
e
.
y
[
d
]))
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
directiv
e
.
x
(
d
)
+
")"
;
});
}).
call
(
d3
.
behavior
.
drag
()
.
origin
(
function
(
d
)
{
return
{
x
:
scop
e
.
x
(
d
)};
})
.
origin
(
function
(
d
)
{
return
{
x
:
directiv
e
.
x
(
d
)};
})
.
on
(
"dragstart"
,
dragstart
)
.
on
(
"drag"
,
drag
)
.
on
(
"dragend"
,
dragend
))
...
...
@@ -430,7 +431,7 @@ angular.module('kibana.parallelcoordinates', [])
.
attr
(
"text-anchor"
,
"middle"
)
.
attr
(
"y"
,
-
9
)
.
text
(
String
);
scop
e
.
axisLines
directiv
e
.
axisLines
.
exit
().
remove
();
//Simulate a dragend in case there is new data and we need to rearrange
...
...
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