Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
flot
Project
Project
Details
Activity
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HS-public
flot
Commits
db3a081d
Commit
db3a081d
authored
May 28, 2013
by
Karl Quinsland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated threshold plugin to work with 'above' operator
parent
355331fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
jquery.flot.threshold.js
jquery.flot.threshold.js
+19
-18
No files found.
jquery.flot.threshold.js
View file @
db3a081d
...
@@ -7,7 +7,8 @@ The plugin supports these options:
...
@@ -7,7 +7,8 @@ The plugin supports these options:
series: {
series: {
threshold: {
threshold: {
below: number
below: number,
above: mumber,
color: colorspec
color: colorspec
}
}
}
}
...
@@ -22,10 +23,10 @@ It can also be applied to a single series, like this:
...
@@ -22,10 +23,10 @@ It can also be applied to a single series, like this:
An array can be passed for multiple thresholding, like this:
An array can be passed for multiple thresholding, like this:
threshold: [{
threshold: [{
below: number1
below: number1
,
color: color1
color: color1
},{
},{
below: number2
above: number2,
color: color2
color: color2
}]
}]
...
@@ -46,9 +47,9 @@ You may need to check for this in hover events.
...
@@ -46,9 +47,9 @@ You may need to check for this in hover events.
var
options
=
{
var
options
=
{
series
:
{
threshold
:
null
}
// or { below: number, color: color spec}
series
:
{
threshold
:
null
}
// or { below: number, color: color spec}
};
};
function
init
(
plot
)
{
function
init
(
plot
)
{
function
thresholdData
(
plot
,
s
,
datapoints
,
below
,
color
)
{
function
thresholdData
(
plot
,
s
,
datapoints
,
below
,
above
,
color
)
{
var
ps
=
datapoints
.
pointsize
,
i
,
x
,
y
,
p
,
prevp
,
var
ps
=
datapoints
.
pointsize
,
i
,
x
,
y
,
p
,
prevp
,
thresholded
=
$
.
extend
({},
s
);
// note: shallow copy
thresholded
=
$
.
extend
({},
s
);
// note: shallow copy
...
@@ -58,7 +59,7 @@ You may need to check for this in hover events.
...
@@ -58,7 +59,7 @@ You may need to check for this in hover events.
thresholded
.
threshold
=
null
;
thresholded
.
threshold
=
null
;
thresholded
.
originSeries
=
s
;
thresholded
.
originSeries
=
s
;
thresholded
.
data
=
[];
thresholded
.
data
=
[];
var
origpoints
=
datapoints
.
points
,
var
origpoints
=
datapoints
.
points
,
addCrossingPoints
=
s
.
lines
.
show
;
addCrossingPoints
=
s
.
lines
.
show
;
...
@@ -71,7 +72,7 @@ You may need to check for this in hover events.
...
@@ -71,7 +72,7 @@ You may need to check for this in hover events.
y
=
origpoints
[
i
+
1
];
y
=
origpoints
[
i
+
1
];
prevp
=
p
;
prevp
=
p
;
if
(
y
<
below
)
if
(
y
<
below
||
y
>
above
)
p
=
threspoints
;
p
=
threspoints
;
else
else
p
=
newpoints
;
p
=
newpoints
;
...
@@ -83,7 +84,7 @@ You may need to check for this in hover events.
...
@@ -83,7 +84,7 @@ You may need to check for this in hover events.
prevp
.
push
(
below
);
prevp
.
push
(
below
);
for
(
m
=
2
;
m
<
ps
;
++
m
)
for
(
m
=
2
;
m
<
ps
;
++
m
)
prevp
.
push
(
origpoints
[
i
+
m
]);
prevp
.
push
(
origpoints
[
i
+
m
]);
p
.
push
(
null
);
// start new segment
p
.
push
(
null
);
// start new segment
p
.
push
(
null
);
p
.
push
(
null
);
for
(
m
=
2
;
m
<
ps
;
++
m
)
for
(
m
=
2
;
m
<
ps
;
++
m
)
...
@@ -102,41 +103,41 @@ You may need to check for this in hover events.
...
@@ -102,41 +103,41 @@ You may need to check for this in hover events.
datapoints
.
points
=
newpoints
;
datapoints
.
points
=
newpoints
;
thresholded
.
datapoints
.
points
=
threspoints
;
thresholded
.
datapoints
.
points
=
threspoints
;
if
(
thresholded
.
datapoints
.
points
.
length
>
0
)
{
if
(
thresholded
.
datapoints
.
points
.
length
>
0
)
{
var
origIndex
=
$
.
inArray
(
s
,
plot
.
getData
());
var
origIndex
=
$
.
inArray
(
s
,
plot
.
getData
());
// Insert newly-generated series right after original one (to prevent it from becoming top-most)
// Insert newly-generated series right after original one (to prevent it from becoming top-most)
plot
.
getData
().
splice
(
origIndex
+
1
,
0
,
thresholded
);
plot
.
getData
().
splice
(
origIndex
+
1
,
0
,
thresholded
);
}
}
// FIXME: there are probably some edge cases left in bars
// FIXME: there are probably some edge cases left in bars
}
}
function
processThresholds
(
plot
,
s
,
datapoints
)
{
function
processThresholds
(
plot
,
s
,
datapoints
)
{
if
(
!
s
.
threshold
)
if
(
!
s
.
threshold
)
return
;
return
;
if
(
s
.
threshold
instanceof
Array
)
{
if
(
s
.
threshold
instanceof
Array
)
{
s
.
threshold
.
sort
(
function
(
a
,
b
)
{
s
.
threshold
.
sort
(
function
(
a
,
b
)
{
return
a
.
below
-
b
.
below
;
return
a
.
below
-
b
.
below
;
});
});
$
(
s
.
threshold
).
each
(
function
(
i
,
th
)
{
$
(
s
.
threshold
).
each
(
function
(
i
,
th
)
{
thresholdData
(
plot
,
s
,
datapoints
,
th
.
below
,
th
.
color
);
thresholdData
(
plot
,
s
,
datapoints
,
th
.
below
,
th
.
above
,
th
.
color
);
});
});
}
}
else
{
else
{
thresholdData
(
plot
,
s
,
datapoints
,
s
.
threshold
.
below
,
s
.
threshold
.
color
);
thresholdData
(
plot
,
s
,
datapoints
,
s
.
threshold
.
below
,
s
.
threshold
.
above
,
s
.
threshold
.
color
);
}
}
}
}
plot
.
hooks
.
processDatapoints
.
push
(
processThresholds
);
plot
.
hooks
.
processDatapoints
.
push
(
processThresholds
);
}
}
$
.
plot
.
plugins
.
push
({
$
.
plot
.
plugins
.
push
({
init
:
init
,
init
:
init
,
options
:
options
,
options
:
options
,
name
:
'threshold'
,
name
:
'threshold'
,
version
:
'1.
2
'
version
:
'1.
3
'
});
});
})(
jQuery
);
})(
jQuery
);
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