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
e858d3cb
Commit
e858d3cb
authored
Aug 22, 2013
by
Spencer Alger
Committed by
Rashid Khan
Aug 26, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved the timeSeries service into the histogram module.
parent
1274a718
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
76 deletions
+72
-76
js/services.js
+0
-76
panels/histogram/module.js
+72
-0
No files found.
js/services.js
View file @
e858d3cb
...
@@ -870,79 +870,4 @@ angular.module('kibana.services', [])
...
@@ -870,79 +870,4 @@ angular.module('kibana.services', [])
return
false
;
return
false
;
});
});
};
};
})
.
service
(
'timeSeries'
,
function
()
{
/**
* Certain graphs require 0 entries to be specified for them to render
* properly (like the line graph). So with this we will caluclate all of
* the expected time measurements, and fill the missing ones in with 0
* @param date start The start time for the result set
* @param date end The end time for the result set
* @param integer interval The length between measurements, in es interval
* notation (1m, 30s, 1h, 15d)
*/
var
undef
;
function
dateToSecondsWithBlankMs
(
date
)
{
// return the date as millis since epoch, with 0 millis
return
Math
.
floor
(
date
.
getTime
()
/
1000
)
*
1000
;
}
function
base10Int
(
val
)
{
return
parseInt
(
val
,
10
);
}
this
.
ZeroFilled
=
function
(
interval
,
start
,
end
)
{
// the expected differenece between readings.
this
.
interval_ms
=
parseInt
(
kbn
.
interval_to_seconds
(
interval
),
10
)
*
1000
;
// will keep all values here, keyed by their time
this
.
_data
=
{};
if
(
start
)
{
this
.
addValue
(
start
,
null
);
}
if
(
end
)
{
this
.
addValue
(
end
,
null
);
}
}
/**
* Add a row
* @param int time The time for the value, in
* @param any value The value at this time
*/
this
.
ZeroFilled
.
prototype
.
addValue
=
function
(
time
,
value
)
{
if
(
time
instanceof
Date
)
{
time
=
dateToSecondsWithBlankMs
(
time
);
}
else
{
time
=
parseInt
(
time
,
10
);
}
if
(
!
isNaN
(
time
))
{
this
.
_data
[
time
]
=
(
value
===
undef
?
0
:
value
);
}
};
/**
* return the rows in the format:
* [ [time, value], [time, value], ... ]
* @return array
*/
this
.
ZeroFilled
.
prototype
.
getFlotPairs
=
function
()
{
// var startTime = performance.now();
var
times
=
_
.
map
(
_
.
keys
(
this
.
_data
),
base10Int
).
sort
()
,
result
=
[]
,
i
,
next
,
expected_next
;
for
(
i
=
0
;
i
<
times
.
length
;
i
++
)
{
result
.
push
([
times
[
i
],
this
.
_data
[
times
[
i
]]
]);
next
=
times
[
i
+
1
];
expected_next
=
times
[
i
]
+
this
.
interval_ms
;
for
(;
times
.
length
>
i
&&
next
>
expected_next
;
expected_next
+=
this
.
interval_ms
)
{
/**
* since we don't know how the server will round subsequent segments
* we have to recheck for blanks each time.
*/
// this._data[expected_next] = 0;
result
.
push
([
expected_next
,
0
]);
}
}
// console.log(Math.round((performance.now() - startTime)*100)/100, 'ms to get', result.length, 'pairs');
return
result
;
};
});
});
\ No newline at end of file
panels/histogram/module.js
View file @
e858d3cb
...
@@ -436,4 +436,75 @@ angular.module('kibana.histogram', [])
...
@@ -436,4 +436,75 @@ angular.module('kibana.histogram', [])
});
});
}
}
};
};
})
.
service
(
'timeSeries'
,
function
()
{
/**
* Certain graphs require 0 entries to be specified for them to render
* properly (like the line graph). So with this we will caluclate all of
* the expected time measurements, and fill the missing ones in with 0
* @param date start The start time for the result set
* @param date end The end time for the result set
* @param integer interval The length between measurements, in es interval
* notation (1m, 30s, 1h, 15d)
*/
var
undef
;
function
base10Int
(
val
)
{
return
parseInt
(
val
,
10
);
}
this
.
ZeroFilled
=
function
(
interval
,
start
,
end
)
{
// the expected differenece between readings.
this
.
interval_ms
=
base10Int
(
kbn
.
interval_to_seconds
(
interval
))
*
1000
;
// will keep all values here, keyed by their time
this
.
_data
=
{};
if
(
start
)
{
this
.
addValue
(
start
,
null
);
}
if
(
end
)
{
this
.
addValue
(
end
,
null
);
}
}
/**
* Add a row
* @param int time The time for the value, in
* @param any value The value at this time
*/
this
.
ZeroFilled
.
prototype
.
addValue
=
function
(
time
,
value
)
{
if
(
time
instanceof
Date
)
{
time
=
Math
.
floor
(
time
.
getTime
()
/
1000
)
*
1000
;
}
else
{
time
=
base10Int
(
time
);
}
if
(
!
isNaN
(
time
))
{
this
.
_data
[
time
]
=
(
value
===
undef
?
0
:
value
);
}
};
/**
* return the rows in the format:
* [ [time, value], [time, value], ... ]
* @return array
*/
this
.
ZeroFilled
.
prototype
.
getFlotPairs
=
function
()
{
// var startTime = performance.now();
var
times
=
_
.
map
(
_
.
keys
(
this
.
_data
),
base10Int
).
sort
()
,
result
=
[]
,
i
,
next
,
expected_next
;
for
(
i
=
0
;
i
<
times
.
length
;
i
++
)
{
result
.
push
([
times
[
i
],
this
.
_data
[
times
[
i
]]
]);
next
=
times
[
i
+
1
];
expected_next
=
times
[
i
]
+
this
.
interval_ms
;
for
(;
times
.
length
>
i
&&
next
>
expected_next
;
expected_next
+=
this
.
interval_ms
)
{
/**
* since we don't know how the server will round subsequent segments
* we have to recheck for blanks each time.
*/
// this._data[expected_next] = 0;
result
.
push
([
expected_next
,
0
]);
}
}
// console.log(Math.round((performance.now() - startTime)*100)/100, 'ms to get', result.length, 'pairs');
return
result
;
};
});
});
\ No newline at end of file
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