mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-07 10:49:00 +00:00
Working static graphs
This commit is contained in:
parent
fa3c0342b6
commit
27d8491990
@ -5,7 +5,10 @@ import json
|
||||
def collect_subtree(storage, subtree, ts):
|
||||
for key, node in subtree.iteritems():
|
||||
if type(node) is not dict:
|
||||
storage.setdefault(key, []).append((ts, node))
|
||||
storage.setdefault(key, []).append({
|
||||
'x': ts,
|
||||
'y': node,
|
||||
})
|
||||
else:
|
||||
collect_subtree(storage.setdefault(key, {}), node, ts)
|
||||
|
||||
|
@ -19,29 +19,24 @@ app.controller "TankReport", ($scope) ->
|
||||
#$scope.tankData = JSON.parse msg
|
||||
#$scope.$apply()
|
||||
|
||||
app.filter "metricsToSeries", () ->
|
||||
(metrics) ->
|
||||
for name, points of metrics
|
||||
name: name
|
||||
color: 'steelblue'
|
||||
data: points.map (p) ->
|
||||
x: p[0]
|
||||
y: p[1]
|
||||
|
||||
app.directive "rickshaw", () ->
|
||||
restrict: "E"
|
||||
replace: true
|
||||
template: "<div></div>"
|
||||
scope:
|
||||
series: '='
|
||||
metrics: '='
|
||||
link: (scope, element, attrs) ->
|
||||
|
||||
graph = new Rickshaw.Graph
|
||||
element: element[0]
|
||||
renderer: attrs.renderer
|
||||
series: scope.series
|
||||
series: (
|
||||
{
|
||||
name: name
|
||||
color: 'steelblue'
|
||||
data: points
|
||||
} for name, points of scope.metrics)
|
||||
width: attrs.width,
|
||||
height: attrs.height
|
||||
# scope.$watch 'series', () ->
|
||||
# console.log "Changed"
|
||||
# if scope.series?
|
||||
graph.render()
|
||||
|
@ -24,41 +24,33 @@
|
||||
})(this));
|
||||
});
|
||||
|
||||
app.filter("metricsToSeries", function() {
|
||||
return function(metrics) {
|
||||
var name, points, _results;
|
||||
_results = [];
|
||||
for (name in metrics) {
|
||||
points = metrics[name];
|
||||
_results.push({
|
||||
name: name,
|
||||
color: 'steelblue',
|
||||
data: points.map(function(p) {
|
||||
return {
|
||||
x: p[0],
|
||||
y: p[1]
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
});
|
||||
|
||||
app.directive("rickshaw", function() {
|
||||
return {
|
||||
restrict: "E",
|
||||
replace: true,
|
||||
template: "<div></div>",
|
||||
scope: {
|
||||
series: '='
|
||||
metrics: '='
|
||||
},
|
||||
link: function(scope, element, attrs) {
|
||||
var graph;
|
||||
var graph, name, points;
|
||||
graph = new Rickshaw.Graph({
|
||||
element: element[0],
|
||||
renderer: attrs.renderer,
|
||||
series: scope.series,
|
||||
series: (function() {
|
||||
var _ref, _results;
|
||||
_ref = scope.metrics;
|
||||
_results = [];
|
||||
for (name in _ref) {
|
||||
points = _ref[name];
|
||||
_results.push({
|
||||
name: name,
|
||||
color: 'steelblue',
|
||||
data: points
|
||||
});
|
||||
}
|
||||
return _results;
|
||||
})(),
|
||||
width: attrs.width,
|
||||
height: attrs.height
|
||||
});
|
||||
|
@ -30,4 +30,4 @@ html(lang="en")
|
||||
h3 {{!host}}
|
||||
.rs.panel(ng-repeat="(group, metrics) in groups")
|
||||
h4 {{!group}}
|
||||
rickshaw(series="metrics | metricsToSeries", renderer="line", width="800", height="600")
|
||||
rickshaw(metrics="metrics", renderer="line", width="800", height="600")
|
||||
|
Loading…
Reference in New Issue
Block a user