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
c1d4516c
Commit
c1d4516c
authored
Jun 03, 2011
by
Ole Laursen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for multiple thresholds, patch by Arnaud Bellec
parent
5a606968
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
NEWS.txt
NEWS.txt
+3
-0
jquery.flot.threshold.js
jquery.flot.threshold.js
+37
-10
No files found.
NEWS.txt
View file @
c1d4516c
...
...
@@ -20,6 +20,9 @@ Changes:
- Support for setting the interval between redraws of the overlay
canvas with redrawOverlayInterval (suggested in issue 185).
- Support for multiple thresholds in thresholds plugin (patch by
Arnaud Bellec, issue 523).
Bug fixes
- Fix problem with null values and pie plugin (patch by gcruxifix,
...
...
jquery.flot.threshold.js
View file @
c1d4516c
...
...
@@ -12,6 +12,19 @@ Flot plugin for thresholding data. Controlled through the option
or in a specific series
$.plot($("#placeholder"), [{ data: [ ... ], threshold: { ... }}])
An array can be passed for multiple thresholding
threshold: [{
below: number1
color: color1
},{
below: number2
color: color2
}]
These multiple threshold objects can be passed in any order since they
are sorted by the processing function.
The data points below "below" are drawn with the specified color. This
makes it easy to mark points below 0, e.g. for budget data.
...
...
@@ -29,22 +42,18 @@ events.
};
function
init
(
plot
)
{
function
thresholdData
(
plot
,
s
,
datapoints
)
{
if
(
!
s
.
threshold
)
return
;
function
thresholdData
(
plot
,
s
,
datapoints
,
below
,
color
)
{
var
ps
=
datapoints
.
pointsize
,
i
,
x
,
y
,
p
,
prevp
,
thresholded
=
$
.
extend
({},
s
);
// note: shallow copy
thresholded
.
datapoints
=
{
points
:
[],
pointsize
:
ps
};
thresholded
.
label
=
null
;
thresholded
.
color
=
s
.
threshold
.
color
;
thresholded
.
color
=
color
;
thresholded
.
threshold
=
null
;
thresholded
.
originSeries
=
s
;
thresholded
.
data
=
[];
var
below
=
s
.
threshold
.
below
,
origpoints
=
datapoints
.
points
,
var
origpoints
=
datapoints
.
points
,
addCrossingPoints
=
s
.
lines
.
show
;
threspoints
=
[];
...
...
@@ -93,13 +102,31 @@ events.
// FIXME: there are probably some edge cases left in bars
}
plot
.
hooks
.
processDatapoints
.
push
(
thresholdData
);
function
processThresholds
(
plot
,
s
,
datapoints
)
{
if
(
!
s
.
threshold
)
return
;
if
(
s
.
threshold
instanceof
Array
)
{
s
.
threshold
.
sort
(
function
(
a
,
b
)
{
return
a
.
below
-
b
.
below
;
});
$
(
s
.
threshold
).
each
(
function
(
i
,
th
)
{
thresholdData
(
plot
,
s
,
datapoints
,
th
.
below
,
th
.
color
);
});
}
else
{
thresholdData
(
plot
,
s
,
datapoints
,
s
.
threshold
.
below
,
s
.
threshold
.
color
);
}
}
plot
.
hooks
.
processDatapoints
.
push
(
processThresholds
);
}
$
.
plot
.
plugins
.
push
({
init
:
init
,
options
:
options
,
name
:
'threshold'
,
version
:
'1.
1
'
version
:
'1.
2
'
});
})(
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