Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
opentrafficshaper
opentrafficshaper
Commits
e7d64f18
Commit
e7d64f18
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added our flot functions for opentrafficshaper
parent
4305c489
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaper/plugins/webserver/pages/static/js/flot-functions.js
+193
-0
193 additions, 0 deletions
...haper/plugins/webserver/pages/static/js/flot-functions.js
with
193 additions
and
0 deletions
opentrafficshaper/plugins/webserver/pages/static/js/flot-functions.js
0 → 100644
+
193
−
0
View file @
e7d64f18
/*
* Functions to help create flot graphs
* Copyright (c) 2013-2014, AllWorldIT
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
// Function draw a graph
function
awit_flot_draw_graph
(
options
)
{
// Setup default graph options
var
defaults
=
{
series
:
{
lines
:
{
show
:
true
,
lineWidth
:
1
,
fill
:
true
,
fillColor
:
{
colors
:
[
{
opacity
:
0.1
},
{
opacity
:
0.13
}
]
}
},
points
:
{
show
:
false
,
lineWidth
:
2
,
radius
:
3
},
shadowSize
:
0
,
stack
:
true
},
grid
:
{
hoverable
:
true
,
clickable
:
false
,
tickColor
:
"
#f9f9f9
"
,
borderWidth
:
1
},
legend
:
{
labelBoxBorderColor
:
"
#aaa
"
},
xaxes
:
[
{
mode
:
"
time
"
,
tickSize
:
[
5
,
"
minute
"
]
// tickLength: 10
/*
tickFormatter: function (v, axis) {
var date = new Date(v);
if (date.getSeconds() % 160 == 0) {
//if (v % m == 0) {
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return hours + ":" + minutes + ":" + seconds;
} else {
return "";
}
}
*/
}
],
yaxes
:
[
{
position
:
'
left
'
,
min
:
0
,
tickFormatter
:
_flot_format_bandwidth
},
{
position
:
'
right
'
,
min
:
0
,
alignTicksWithAxis
:
true
,
tickDecimals
:
false
}
]
}
// Merge our options ontop of our defaults
var
plotOptions
=
jQuery
.
extend
({},
defaults
,
options
);
// Grab the placeholder
var
placeholder
=
jQuery
(
'
#
'
+
plotOptions
.
id
);
// Plot the graph, the [] signifies an empty dataset, the data is populated by awitds
var
plot
=
jQuery
.
plot
(
placeholder
,
[
],
plotOptions
);
return
plot
;
}
// Function draw pie graph
function
awit_flot_draw_pie
(
options
)
{
// Setup default graph options
var
defaults
=
{
series
:
{
pie
:
{
show
:
true
,
radius
:
1
,
label
:
{
show
:
true
,
radius
:
3
/
4
,
formatter
:
_flot_format_pie_label
,
background
:
{
opacity
:
0.5
,
color
:
'
#000
'
}
}
}
}
}
// Merge our options ontop of our defaults
var
plotOptions
=
jQuery
.
extend
({},
defaults
,
options
);
// Set count to 1 and override timestamp to 1 for all identifiers
if
(
typeof
(
plotOptions
.
awitds
)
!==
'
undefined
'
)
{
for
(
var
tag
in
plotOptions
.
awitds
.
xaxis
)
{
for
(
var
identifier
in
plotOptions
.
awitds
.
xaxis
[
tag
])
{
plotOptions
.
awitds
.
xaxis
[
tag
][
identifier
].
maxCount
=
1
;
plotOptions
.
awitds
.
xaxis
[
tag
][
identifier
].
overrideTimestamp
=
1
;
}
}
}
// Grab the placeholder
var
placeholder
=
jQuery
(
'
#
'
+
plotOptions
.
id
);
// Plot the graph, the [] signifies an empty dataset, the data is populated by awitds
var
plot
=
jQuery
.
plot
(
placeholder
,
[
],
plotOptions
);
return
plot
;
}
// Function to format thousands with , and add Kbps
function
_flot_format_bandwidth
(
value
,
axis
)
{
return
_flot_format_thousands
(
value
,
axis
)
+
'
Kbps
'
;
}
// Function to format thousands
function
_flot_format_thousands
(
value
,
axis
)
{
// Convert number to string
value
=
value
.
toString
();
// Match on 3 digits
var
R
=
new
RegExp
(
'
(-?[0-9]+)([0-9]{3})
'
);
while
(
R
.
test
(
value
))
{
// Replace market with ,
value
=
value
.
replace
(
R
,
'
$1,$2
'
);
}
return
value
;
}
function
_flot_format_pie_label
(
label
,
series
)
{
return
"
<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>
"
+
label
+
"
<br/>
"
+
Math
.
round
(
series
.
percent
)
+
"
%</div>
"
;
}
// vim: ts=4
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment