2013-04-20 11:49:57 +08:00
|
|
|
/*
|
|
|
|
|
|
|
|
## Histogram
|
|
|
|
|
|
|
|
A bucketted time series representation of the current query or queries. Note that this
|
|
|
|
panel uses facetting. I tried to make it safe by using sequential/serial querying but,
|
|
|
|
yeah, you should know that it uses facetting. It should be pretty safe.
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
* query :: an array of objects as such: {query: 'somequery', label 'legent text'}.
|
|
|
|
this is usually populated by a stringquery panel wher the query and label
|
|
|
|
parameter are the same
|
2013-05-04 04:54:29 +08:00
|
|
|
* auto_int :: Auto calculate data point interval?
|
2013-05-14 05:26:34 +08:00
|
|
|
* resolution :: If auto_int is enables, shoot for this many data points, rounding to
|
|
|
|
sane intervals
|
2013-05-04 04:54:29 +08:00
|
|
|
* interval :: Datapoint interval in elasticsearch date math format (eg 1d, 1w, 1y, 5y)
|
2013-04-20 11:49:57 +08:00
|
|
|
* fill :: Only applies to line charts. Level of area shading from 0-10
|
|
|
|
* linewidth :: Only applies to line charts. How thick the line should be in pixels
|
|
|
|
While the editor only exposes 0-10, this can be any numeric value.
|
|
|
|
Set to 0 and you'll get something like a scatter plot
|
|
|
|
* timezone :: This isn't totally functional yet. Currently only supports browser and utc.
|
|
|
|
browser will adjust the x-axis labels to match the timezone of the user's
|
|
|
|
browser
|
|
|
|
* spyable :: Dislay the 'eye' icon that show the last elasticsearch query
|
|
|
|
* zoomlinks :: Show the zoom links?
|
|
|
|
* bars :: Show bars in the chart
|
|
|
|
* stack :: Stack multiple queries. This generally a crappy way to represent things.
|
|
|
|
You probably should just use a line chart without stacking
|
|
|
|
* points :: Should circles at the data points on the chart
|
|
|
|
* lines :: Line chart? Sweet.
|
|
|
|
* legend :: Show the legend?
|
|
|
|
* x-axis :: Show x-axis labels and grid lines
|
|
|
|
* y-axis :: Show y-axis labels and grid lines
|
2013-05-27 00:38:18 +08:00
|
|
|
* interactive :: Allow drag to select time range
|
2013-04-20 11:49:57 +08:00
|
|
|
### Group Events
|
|
|
|
#### Receives
|
|
|
|
* time :: An object containing the time range to use and the index(es) to query
|
|
|
|
* query :: An Array of queries, even if its only one
|
|
|
|
#### Sends
|
|
|
|
* get_time :: On panel initialization get time range to query
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-01-31 12:39:57 +08:00
|
|
|
angular.module('kibana.histogram', [])
|
2013-02-08 06:05:55 +08:00
|
|
|
.controller('histogram', function($scope, eventBus) {
|
2013-01-31 12:39:57 +08:00
|
|
|
|
|
|
|
// Set and populate defaults
|
|
|
|
var _d = {
|
2013-06-18 01:34:18 +08:00
|
|
|
status : "Stable",
|
2013-05-14 05:26:34 +08:00
|
|
|
group : "default",
|
|
|
|
query : [ {query: "*", label:"Query"} ],
|
|
|
|
mode : 'count',
|
|
|
|
value_field : null,
|
|
|
|
auto_int : true,
|
|
|
|
resolution : 100,
|
|
|
|
interval : '5m',
|
|
|
|
fill : 3,
|
|
|
|
linewidth : 3,
|
|
|
|
timezone : 'browser', // browser, utc or a standard timezone
|
|
|
|
spyable : true,
|
|
|
|
zoomlinks : true,
|
|
|
|
bars : true,
|
|
|
|
stack : true,
|
|
|
|
points : false,
|
|
|
|
lines : false,
|
|
|
|
legend : true,
|
|
|
|
'x-axis' : true,
|
|
|
|
'y-axis' : true,
|
2013-05-27 00:38:18 +08:00
|
|
|
percentage : false,
|
|
|
|
interactive : true,
|
2013-02-06 05:30:08 +08:00
|
|
|
}
|
|
|
|
_.defaults($scope.panel,_d)
|
|
|
|
|
|
|
|
$scope.init = function() {
|
2013-03-13 04:40:14 +08:00
|
|
|
eventBus.register($scope,'time', function(event,time){$scope.set_time(time)});
|
2013-04-09 23:04:29 +08:00
|
|
|
|
|
|
|
// Consider eliminating the check for array, this should always be an array
|
2013-02-08 06:05:55 +08:00
|
|
|
eventBus.register($scope,'query', function(event, query) {
|
2013-02-22 06:26:48 +08:00
|
|
|
if(_.isArray(query)) {
|
|
|
|
$scope.panel.query = _.map(query,function(q) {
|
|
|
|
return {query: q, label: q};
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
$scope.panel.query[0] = {query: query, label: query}
|
|
|
|
}
|
2013-02-06 05:30:08 +08:00
|
|
|
$scope.get_data();
|
|
|
|
});
|
2013-04-09 23:04:29 +08:00
|
|
|
|
2013-02-13 07:25:39 +08:00
|
|
|
// Now that we're all setup, request the time from our group if we don't
|
|
|
|
// have it yet
|
|
|
|
if(_.isUndefined($scope.time))
|
|
|
|
eventBus.broadcast($scope.$id,$scope.panel.group,'get_time')
|
2013-01-31 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
2013-02-09 06:18:35 +08:00
|
|
|
$scope.remove_query = function(q) {
|
|
|
|
$scope.panel.query = _.without($scope.panel.query,q);
|
2013-02-09 06:57:24 +08:00
|
|
|
$scope.get_data();
|
2013-02-09 06:18:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.add_query = function(label,query) {
|
2013-02-14 03:23:24 +08:00
|
|
|
if(!(_.isArray($scope.panel.query)))
|
|
|
|
$scope.panel.query = new Array();
|
2013-02-09 06:18:35 +08:00
|
|
|
$scope.panel.query.unshift({
|
|
|
|
query: query,
|
|
|
|
label: label,
|
|
|
|
});
|
|
|
|
$scope.get_data();
|
|
|
|
}
|
|
|
|
|
2013-04-02 06:12:07 +08:00
|
|
|
$scope.get_data = function(segment,query_id) {
|
2013-04-06 04:01:32 +08:00
|
|
|
delete $scope.panel.error
|
2013-02-05 08:05:36 +08:00
|
|
|
// Make sure we have everything for the request to complete
|
2013-05-07 02:05:54 +08:00
|
|
|
if(_.isUndefined($scope.index) || _.isUndefined($scope.time))
|
2013-02-05 08:05:36 +08:00
|
|
|
return
|
|
|
|
|
2013-05-04 04:54:29 +08:00
|
|
|
if ($scope.panel.auto_int)
|
2013-05-14 05:26:34 +08:00
|
|
|
$scope.panel.interval = secondsToHms(calculate_interval($scope.time.from,$scope.time.to,$scope.panel.resolution,0)/1000);
|
2013-05-04 04:54:29 +08:00
|
|
|
|
2013-02-28 01:00:39 +08:00
|
|
|
$scope.panel.loading = true;
|
2013-04-09 23:04:29 +08:00
|
|
|
var _segment = _.isUndefined(segment) ? 0 : segment
|
2013-05-07 02:05:54 +08:00
|
|
|
var request = $scope.ejs.Request().indices($scope.index[_segment]);
|
2013-05-30 03:07:05 +08:00
|
|
|
|
2013-01-31 12:39:57 +08:00
|
|
|
// Build the question part of the query
|
|
|
|
var queries = [];
|
|
|
|
_.each($scope.panel.query, function(v) {
|
|
|
|
queries.push($scope.ejs.FilteredQuery(
|
|
|
|
ejs.QueryStringQuery(v.query || '*'),
|
2013-02-14 05:51:56 +08:00
|
|
|
ejs.RangeFilter($scope.time.field)
|
|
|
|
.from($scope.time.from)
|
|
|
|
.to($scope.time.to))
|
2013-01-31 12:39:57 +08:00
|
|
|
)
|
|
|
|
});
|
|
|
|
|
2013-04-09 23:04:29 +08:00
|
|
|
// Build the facet part, injecting the query in as a facet filter
|
2013-01-31 12:39:57 +08:00
|
|
|
_.each(queries, function(v) {
|
2013-05-14 04:31:59 +08:00
|
|
|
|
|
|
|
var facet = $scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
|
|
|
|
|
|
|
|
if($scope.panel.mode === 'count') {
|
|
|
|
facet = facet.field($scope.time.field)
|
|
|
|
} else {
|
|
|
|
if(_.isNull($scope.panel.value_field)) {
|
|
|
|
$scope.panel.error = "In " + $scope.panel.mode + " mode a field must be specified";
|
|
|
|
return
|
|
|
|
}
|
|
|
|
facet = facet.keyField($scope.time.field).valueField($scope.panel.value_field)
|
|
|
|
}
|
|
|
|
facet = facet.interval($scope.panel.interval).facetFilter($scope.ejs.QueryFilter(v))
|
|
|
|
request = request.facet(facet).size(0)
|
2013-01-31 12:39:57 +08:00
|
|
|
})
|
|
|
|
|
2013-04-09 23:04:29 +08:00
|
|
|
// Populate the inspector panel
|
2013-03-13 00:20:18 +08:00
|
|
|
$scope.populate_modal(request);
|
|
|
|
|
2013-01-31 12:39:57 +08:00
|
|
|
// Then run it
|
|
|
|
var results = request.doSearch();
|
|
|
|
|
|
|
|
// Populate scope when we have results
|
|
|
|
results.then(function(results) {
|
2013-02-28 01:00:39 +08:00
|
|
|
$scope.panel.loading = false;
|
2013-04-02 06:12:07 +08:00
|
|
|
if(_segment == 0) {
|
2013-04-03 12:20:08 +08:00
|
|
|
$scope.hits = 0;
|
2013-02-28 03:51:59 +08:00
|
|
|
$scope.data = [];
|
2013-04-02 06:12:07 +08:00
|
|
|
query_id = $scope.query_id = new Date().getTime();
|
|
|
|
}
|
2013-02-28 03:51:59 +08:00
|
|
|
|
2013-04-06 04:01:32 +08:00
|
|
|
// Check for error and abort if found
|
|
|
|
if(!(_.isUndefined(results.error))) {
|
|
|
|
$scope.panel.error = $scope.parse_error(results.error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-09 23:04:29 +08:00
|
|
|
// Make sure we're still on the same query
|
2013-04-02 06:12:07 +08:00
|
|
|
if($scope.query_id === query_id) {
|
2013-04-03 12:20:08 +08:00
|
|
|
|
2013-04-05 06:13:31 +08:00
|
|
|
var i = 0;
|
2013-04-02 06:12:07 +08:00
|
|
|
_.each(results.facets, function(v, k) {
|
2013-04-05 06:13:31 +08:00
|
|
|
|
2013-04-02 06:12:07 +08:00
|
|
|
// Null values at each end of the time range ensure we see entire range
|
2013-04-05 06:13:31 +08:00
|
|
|
if(_.isUndefined($scope.data[i]) || _segment == 0) {
|
2013-04-02 06:12:07 +08:00
|
|
|
var data = [[$scope.time.from.getTime(), null],[$scope.time.to.getTime(), null]];
|
2013-04-05 08:02:49 +08:00
|
|
|
var hits = 0;
|
2013-04-02 06:12:07 +08:00
|
|
|
} else {
|
2013-04-05 06:13:31 +08:00
|
|
|
var data = $scope.data[i].data
|
2013-04-05 08:02:49 +08:00
|
|
|
var hits = $scope.data[i].hits
|
2013-04-02 06:12:07 +08:00
|
|
|
}
|
2013-02-28 03:51:59 +08:00
|
|
|
|
2013-04-05 06:13:31 +08:00
|
|
|
// Assemble segments
|
2013-04-02 06:12:07 +08:00
|
|
|
var segment_data = [];
|
|
|
|
_.each(v.entries, function(v, k) {
|
2013-05-14 04:31:59 +08:00
|
|
|
segment_data.push([v['time'],v[$scope.panel.mode]])
|
2013-04-09 23:04:29 +08:00
|
|
|
hits += v['count']; // The series level hits counter
|
|
|
|
$scope.hits += v['count']; // Entire dataset level hits counter
|
2013-04-02 06:12:07 +08:00
|
|
|
});
|
2013-04-09 23:04:29 +08:00
|
|
|
data.splice.apply(data,[1,0].concat(segment_data)) // Join histogram data
|
2013-02-28 05:47:43 +08:00
|
|
|
|
2013-04-09 23:04:29 +08:00
|
|
|
// Create the flot series object
|
2013-04-02 06:12:07 +08:00
|
|
|
var series = {
|
|
|
|
data: {
|
2013-04-05 06:13:31 +08:00
|
|
|
label: $scope.panel.query[i].label || "query"+(parseInt(i)+1),
|
2013-04-02 06:12:07 +08:00
|
|
|
data: data,
|
2013-04-05 08:02:49 +08:00
|
|
|
hits: hits
|
2013-04-02 06:12:07 +08:00
|
|
|
},
|
|
|
|
};
|
2013-02-06 05:30:08 +08:00
|
|
|
|
2013-04-05 06:13:31 +08:00
|
|
|
if (!(_.isUndefined($scope.panel.query[i].color)))
|
|
|
|
series.data.color = $scope.panel.query[i].color;
|
2013-04-02 06:12:07 +08:00
|
|
|
|
2013-04-05 06:13:31 +08:00
|
|
|
$scope.data[i] = series.data
|
|
|
|
|
|
|
|
i++;
|
2013-04-02 06:12:07 +08:00
|
|
|
});
|
|
|
|
|
2013-04-09 23:04:29 +08:00
|
|
|
// Tell the histogram directive to render.
|
2013-04-02 06:12:07 +08:00
|
|
|
$scope.$emit('render')
|
2013-04-09 23:04:29 +08:00
|
|
|
|
|
|
|
// If we still have segments left, get them
|
2013-05-07 02:05:54 +08:00
|
|
|
if(_segment < $scope.index.length-1) {
|
2013-04-02 06:12:07 +08:00
|
|
|
$scope.get_data(_segment+1,query_id)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-01-31 12:39:57 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-03-14 06:32:22 +08:00
|
|
|
// function $scope.zoom
|
|
|
|
// factor :: Zoom factor, so 0.5 = cuts timespan in half, 2 doubles timespan
|
|
|
|
$scope.zoom = function(factor) {
|
2013-05-04 04:54:29 +08:00
|
|
|
eventBus.broadcast($scope.$id,$scope.panel.group,'zoom',factor);
|
2013-03-14 06:32:22 +08:00
|
|
|
}
|
|
|
|
|
2013-03-13 00:20:18 +08:00
|
|
|
// I really don't like this function, too much dom manip. Break out into directive?
|
|
|
|
$scope.populate_modal = function(request) {
|
|
|
|
$scope.modal = {
|
|
|
|
title: "Inspector",
|
|
|
|
body : "<h5>Last Elasticsearch Query</h5><pre>"+
|
2013-05-07 02:05:54 +08:00
|
|
|
'curl -XGET '+config.elasticsearch+'/'+$scope.index+"/_search?pretty -d'\n"+
|
2013-03-13 00:20:18 +08:00
|
|
|
angular.toJson(JSON.parse(request.toString()),true)+
|
|
|
|
"'</pre>",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-04 04:54:29 +08:00
|
|
|
$scope.set_refresh = function (state) {
|
|
|
|
$scope.refresh = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.close_edit = function() {
|
|
|
|
if($scope.refresh)
|
|
|
|
$scope.get_data();
|
|
|
|
$scope.refresh = false;
|
|
|
|
$scope.$emit('render');
|
|
|
|
}
|
|
|
|
|
2013-03-13 04:40:14 +08:00
|
|
|
$scope.set_time = function(time) {
|
2013-02-14 05:51:56 +08:00
|
|
|
$scope.time = time;
|
2013-05-23 02:50:49 +08:00
|
|
|
$scope.index = time.index || $scope.index
|
2013-02-06 05:30:08 +08:00
|
|
|
$scope.get_data();
|
2013-02-05 08:05:36 +08:00
|
|
|
}
|
|
|
|
|
2013-01-31 12:39:57 +08:00
|
|
|
})
|
2013-04-07 07:34:04 +08:00
|
|
|
.directive('histogramChart', function(eventBus) {
|
2013-01-31 12:39:57 +08:00
|
|
|
return {
|
|
|
|
restrict: 'A',
|
|
|
|
link: function(scope, elem, attrs, ctrl) {
|
|
|
|
|
2013-02-14 03:23:24 +08:00
|
|
|
// Receive render events
|
2013-02-13 07:25:39 +08:00
|
|
|
scope.$on('render',function(){
|
|
|
|
render_panel();
|
2013-01-31 12:39:57 +08:00
|
|
|
});
|
2013-02-13 07:25:39 +08:00
|
|
|
|
2013-02-02 05:16:55 +08:00
|
|
|
// Re-render if the window is resized
|
2013-01-31 12:39:57 +08:00
|
|
|
angular.element(window).bind('resize', function(){
|
2013-02-13 07:25:39 +08:00
|
|
|
render_panel();
|
2013-01-31 12:39:57 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Function for rendering panel
|
2013-02-13 07:25:39 +08:00
|
|
|
function render_panel() {
|
2013-05-04 04:54:29 +08:00
|
|
|
|
2013-01-31 12:39:57 +08:00
|
|
|
// Set barwidth based on specified interval
|
|
|
|
var barwidth = interval_to_seconds(scope.panel.interval)*1000
|
|
|
|
|
2013-05-30 03:30:38 +08:00
|
|
|
var scripts = $LAB.script("common/lib/panels/jquery.flot.js").wait()
|
2013-01-31 12:39:57 +08:00
|
|
|
.script("common/lib/panels/jquery.flot.time.js")
|
|
|
|
.script("common/lib/panels/jquery.flot.stack.js")
|
2013-03-13 04:40:14 +08:00
|
|
|
.script("common/lib/panels/jquery.flot.selection.js")
|
2013-02-17 12:48:38 +08:00
|
|
|
.script("common/lib/panels/timezone.js")
|
2013-01-31 12:39:57 +08:00
|
|
|
|
|
|
|
// Populate element. Note that jvectormap appends, does not replace.
|
|
|
|
scripts.wait(function(){
|
2013-04-07 14:42:34 +08:00
|
|
|
var stack = scope.panel.stack ? true : null;
|
2013-04-05 06:13:31 +08:00
|
|
|
|
2013-02-13 07:25:39 +08:00
|
|
|
// Populate element
|
2013-04-02 06:12:07 +08:00
|
|
|
try {
|
2013-05-27 00:38:18 +08:00
|
|
|
var options = {
|
2013-04-09 23:04:29 +08:00
|
|
|
legend: { show: false },
|
2013-04-02 06:12:07 +08:00
|
|
|
series: {
|
2013-05-25 00:13:13 +08:00
|
|
|
stackpercent: scope.panel.stack ? scope.panel.percentage : false,
|
|
|
|
stack: scope.panel.percentage ? null : stack,
|
2013-04-06 11:52:35 +08:00
|
|
|
lines: {
|
2013-04-07 14:42:34 +08:00
|
|
|
show: scope.panel.lines,
|
2013-04-06 11:52:35 +08:00
|
|
|
fill: scope.panel.fill/10,
|
|
|
|
lineWidth: scope.panel.linewidth,
|
2013-04-07 14:42:34 +08:00
|
|
|
steps: false
|
2013-04-06 11:52:35 +08:00
|
|
|
},
|
2013-04-07 14:42:34 +08:00
|
|
|
bars: { show: scope.panel.bars, fill: 1, barWidth: barwidth/1.8 },
|
2013-04-11 07:48:48 +08:00
|
|
|
points: { show: scope.panel.points, fill: 1, fillColor: false, radius: 5},
|
2013-04-02 06:12:07 +08:00
|
|
|
shadowSize: 1
|
|
|
|
},
|
2013-05-25 00:13:13 +08:00
|
|
|
yaxis: {
|
|
|
|
show: scope.panel['y-axis'],
|
|
|
|
min: 0,
|
|
|
|
max: scope.panel.percentage && scope.panel.stack ? 100 : null,
|
|
|
|
color: "#c8c8c8"
|
|
|
|
},
|
2013-04-02 06:12:07 +08:00
|
|
|
xaxis: {
|
|
|
|
timezone: scope.panel.timezone,
|
2013-04-07 14:42:34 +08:00
|
|
|
show: scope.panel['x-axis'],
|
2013-04-02 06:12:07 +08:00
|
|
|
mode: "time",
|
|
|
|
timeformat: time_format(scope.panel.interval),
|
|
|
|
label: "Datetime",
|
2013-05-23 02:50:49 +08:00
|
|
|
color: "#c8c8c8",
|
2013-04-02 06:12:07 +08:00
|
|
|
},
|
|
|
|
grid: {
|
2013-05-24 08:28:50 +08:00
|
|
|
backgroundColor: null,
|
2013-04-02 06:12:07 +08:00
|
|
|
borderWidth: 0,
|
|
|
|
borderColor: '#eee',
|
|
|
|
color: "#eee",
|
|
|
|
hoverable: true,
|
|
|
|
},
|
2013-04-12 05:25:49 +08:00
|
|
|
colors: ['#86B22D','#BF6730','#1D7373','#BFB930','#BF3030','#77207D']
|
2013-05-27 00:38:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(scope.panel.interactive)
|
|
|
|
options.selection = { mode: "x", color: '#aaa' };
|
|
|
|
|
|
|
|
scope.plot = $.plot(elem, scope.data, options)
|
2013-04-05 06:13:31 +08:00
|
|
|
|
|
|
|
// Work around for missing legend at initialization
|
|
|
|
if(!scope.$$phase)
|
|
|
|
scope.$apply()
|
|
|
|
|
2013-03-06 00:54:29 +08:00
|
|
|
} catch(e) {
|
2013-04-02 06:12:07 +08:00
|
|
|
elem.text(e)
|
2013-03-06 00:54:29 +08:00
|
|
|
}
|
2013-01-31 12:39:57 +08:00
|
|
|
})
|
2013-03-13 04:40:14 +08:00
|
|
|
}
|
2013-02-06 10:20:32 +08:00
|
|
|
|
2013-03-14 05:18:59 +08:00
|
|
|
function time_format(interval) {
|
|
|
|
var _int = interval_to_seconds(interval)
|
|
|
|
if(_int >= 2628000)
|
|
|
|
return "%m/%y"
|
|
|
|
if(_int >= 86400)
|
|
|
|
return "%m/%d/%y"
|
|
|
|
if(_int >= 60)
|
|
|
|
return "%H:%M<br>%m/%d"
|
|
|
|
else
|
|
|
|
return "%H:%M:%S"
|
|
|
|
}
|
|
|
|
|
2013-03-13 04:40:14 +08:00
|
|
|
function tt(x, y, contents) {
|
2013-05-04 04:54:29 +08:00
|
|
|
// If the tool tip already exists, don't recreate it, just update it
|
2013-03-13 04:40:14 +08:00
|
|
|
var tooltip = $('#pie-tooltip').length ?
|
|
|
|
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
2013-05-04 04:54:29 +08:00
|
|
|
|
2013-04-06 11:52:35 +08:00
|
|
|
tooltip.html(contents).css({
|
2013-03-13 04:40:14 +08:00
|
|
|
position: 'absolute',
|
|
|
|
top : y + 5,
|
|
|
|
left : x + 5,
|
2013-05-23 02:50:49 +08:00
|
|
|
color : "#c8c8c8",
|
2013-04-06 11:52:35 +08:00
|
|
|
padding : '10px',
|
|
|
|
'font-size': '11pt',
|
2013-04-08 09:47:02 +08:00
|
|
|
'font-weight' : 200,
|
2013-05-23 02:50:49 +08:00
|
|
|
'background-color': '#1f1f1f',
|
|
|
|
'border-radius': '5px',
|
2013-03-13 04:40:14 +08:00
|
|
|
}).appendTo("body");
|
|
|
|
}
|
|
|
|
|
|
|
|
elem.bind("plothover", function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
tt(pos.pageX, pos.pageY,
|
2013-05-25 00:13:13 +08:00
|
|
|
"<div style='vertical-align:middle;display:inline-block;background:"+
|
|
|
|
item.series.color+";height:15px;width:15px;border-radius:10px;'></div> "+
|
2013-04-06 11:52:35 +08:00
|
|
|
item.datapoint[1].toFixed(0) + " @ " +
|
2013-05-23 02:50:49 +08:00
|
|
|
moment(item.datapoint[0]).format('MM/DD HH:mm:ss'));
|
2013-03-13 04:40:14 +08:00
|
|
|
} else {
|
|
|
|
$("#pie-tooltip").remove();
|
2013-02-06 10:20:32 +08:00
|
|
|
}
|
2013-03-13 04:40:14 +08:00
|
|
|
});
|
2013-02-06 10:20:32 +08:00
|
|
|
|
2013-03-13 04:40:14 +08:00
|
|
|
elem.bind("plotselected", function (event, ranges) {
|
2013-05-23 02:50:49 +08:00
|
|
|
scope.time.from = moment(ranges.xaxis.from);
|
|
|
|
scope.time.to = moment(ranges.xaxis.to)
|
2013-03-14 00:33:51 +08:00
|
|
|
eventBus.broadcast(scope.$id,scope.panel.group,'set_time',scope.time)
|
2013-03-13 04:40:14 +08:00
|
|
|
});
|
2013-01-31 12:39:57 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
})
|