-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2054 from denzelsN/master
add active trace chart in inspector page
- Loading branch information
Showing
6 changed files
with
246 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
web/src/main/webapp/features/activeTraceChart/active-trace-chart.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
(function() { | ||
'use strict'; | ||
angular.module( "pinpointApp" ).directive( "activeTraceChartDirective", [ "$timeout", | ||
function ( $timeout ) { | ||
return { | ||
template: '<div></div>', | ||
replace: true, | ||
restrict: 'E', | ||
scope: { | ||
namespace: '@' // string value | ||
}, | ||
link: function postLink(scope, element, attrs) { | ||
|
||
// define variables | ||
var sId, oChart; | ||
|
||
// define variables of methods | ||
var setIdAutomatically, setWidthHeight, render, showCursorAt, resize; | ||
|
||
/** | ||
* set id automatically | ||
*/ | ||
setIdAutomatically = function () { | ||
sId = 'multipleValueAxesId-' + scope.namespace; | ||
element.attr('id', sId); | ||
}; | ||
|
||
/** | ||
* set width height | ||
* @param w | ||
* @param h | ||
*/ | ||
setWidthHeight = function (w, h) { | ||
if (w) element.css('width', w); | ||
if (h) element.css('height', h); | ||
}; | ||
|
||
/** | ||
* render | ||
* @param chartData | ||
*/ | ||
render = function (chartData) { | ||
var options = { | ||
"type": "serial", | ||
"theme": "light", | ||
"autoMargins": false, | ||
"marginTop": 10, | ||
"marginLeft": 70, | ||
"marginRight": 70, | ||
"marginBottom": 30, | ||
"legend": { | ||
"useGraphSettings": true, | ||
"autoMargins": true, | ||
"align" : "right", | ||
"position": "top", | ||
"valueWidth": 70 | ||
}, | ||
"usePrefixes": true, | ||
"dataProvider": chartData, | ||
"valueAxes": [ | ||
{ | ||
"stackType": "regular", | ||
"gridAlpha": 0, | ||
"axisAlpha": 1, | ||
"position": "left", | ||
"title": "Active Trace", | ||
"minimum" : 0 | ||
} | ||
], | ||
"graphs": [ | ||
{ | ||
"balloonText": "Trace Fast : [[value]]", | ||
"legendValueText": "[[value]]", | ||
"lineColor": "rgb(214, 141, 8)", | ||
"fillColor": "rgb(214, 141, 8)", | ||
"title": "Fast", | ||
"valueField": "traceFace", | ||
"fillAlphas": 0.4, | ||
"connect": true | ||
},{ | ||
"balloonText": "Trace Normal : [[value]]", | ||
"legendValueText": "[[value]]", | ||
"lineColor": "rgb(252, 178, 65)", | ||
"fillColor": "rgb(252, 178, 65)", | ||
"title": "Normal", | ||
"valueField": "traceNormal", | ||
"fillAlphas": 0.4, | ||
"connect": true | ||
},{ | ||
"balloonText": "Trace Slow : [[value]]", | ||
"legendValueText": "[[value]]", | ||
"lineColor": "rgb(90, 103, 166)", | ||
"fillColor": "rgb(90, 103, 166)", | ||
"title": "Slow", | ||
"valueField": "traceSlow", | ||
"fillAlphas": 0.4, | ||
"connect": true | ||
},{ | ||
"balloonText": "Trace Very Slow : [[value]]", | ||
"legendValueText": "[[value]]", | ||
"lineColor": "rgb(160, 153, 255)", | ||
"fillColor": "rgb(160, 153, 255)", | ||
"title": "Very Slow", | ||
"valueField": "traceVerySlow", | ||
"fillAlphas": 0.4, | ||
"connect": true | ||
} | ||
], | ||
"chartCursor": { | ||
"categoryBalloonAlpha": 0.7, | ||
"fullWidth": true, | ||
"cursorAlpha": 0.1 | ||
}, | ||
"categoryField": "time", | ||
"categoryAxis": { | ||
"axisColor": "#DADADA", | ||
"startOnAxis": true, | ||
"gridPosition": "start", | ||
"labelFunction": function (valueText, serialDataItem, categoryAxis) { | ||
return moment(valueText).format("HH:mm:ss"); | ||
} | ||
} | ||
}; | ||
$timeout(function () { | ||
oChart = AmCharts.makeChart(sId, options); | ||
oChart.chartCursor.addListener( "changed", function (event) { | ||
scope.$emit( "activeTraceChartDirective.cursorChanged." + scope.namespace, event); | ||
}); | ||
}); | ||
}; | ||
|
||
/** | ||
* show cursor at | ||
* @param category | ||
*/ | ||
showCursorAt = function (category) { | ||
if (category) { | ||
if (angular.isNumber(category)) { | ||
category = oChart.dataProvider[category].time; | ||
} | ||
oChart.chartCursor.showCursorAt(category); | ||
} else { | ||
oChart.chartCursor.hideCursor(); | ||
} | ||
}; | ||
|
||
/** | ||
* resize | ||
*/ | ||
resize = function () { | ||
if (oChart) { | ||
oChart.validateNow(); | ||
oChart.validateSize(); | ||
} | ||
}; | ||
|
||
scope.$on( "activeTraceChartDirective.initAndRenderWithData." + scope.namespace, function (event, data, w, h) { | ||
setIdAutomatically(); | ||
setWidthHeight(w, h); | ||
render(data); | ||
}); | ||
|
||
scope.$on( "activeTraceChartDirective.showCursorAt." + scope.namespace, function (event, category) { | ||
showCursorAt(category); | ||
}); | ||
|
||
scope.$on( "activeTraceChartDirective.resize." + scope.namespace, function (event) { | ||
resize(); | ||
}); | ||
} | ||
}; | ||
} | ||
]); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters