From 70f6a297003f8784380fad2bbda7aa69cef52a77 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 5 Feb 2013 19:20:32 -0700 Subject: [PATCH] Added missing text panel, added hover to pie and histogram --- dashboards.js | 12 +++++++----- panels/histogram/module.js | 27 +++++++++++++++++++++++++++ panels/pie/module.js | 2 +- panels/text/module.html | 4 ++++ panels/text/module.js | 17 +++++++++++++++++ 5 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 panels/text/module.html create mode 100644 panels/text/module.js diff --git a/dashboards.js b/dashboards.js index 2ae02f74ebc..54507e97968 100644 --- a/dashboards.js +++ b/dashboards.js @@ -41,7 +41,8 @@ var dashboards = span: 3, content : "Panels can send events to other panels. In the case of" + " the sort panel, it also receives a field event that it uses" + - " to populate its list of fields from the table panel" + " to populate its list of fields from the table panel. The time " + + " selector is a member of two groups." }, ] }, @@ -55,10 +56,11 @@ var dashboards = title : "About", fontsize : "85%", span: 2, - content : "These pies demonstrate configurable binding. They are" + + content : "These donut charts demonstrate configurable binding." + + " They exist in a different group from the other panels and are" + " bound only to the time selector, not to the query input. Thus" + " they will change when you select a new time range, but not if" + - " you enter a search. Try hovering over a pie slice.", + " you enter a search.", }, { title : "Hamlet", @@ -175,8 +177,8 @@ var dashboards = title : "Monkey Shakespeare Lines", type : "histogram", span : 5, - show : ['lines','stack'], - fill : 0.3, + show : ['bars','stack'], + fill : 1, query : [ { label : "Query Hits", query : "*", color: '#86B32D' }, { label : "Hamlet", query : "play_name:Hamlet" }, diff --git a/panels/histogram/module.js b/panels/histogram/module.js index c254b8663a9..a9008f38699 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -164,6 +164,33 @@ angular.module('kibana.histogram', []) } }) }) + + function tt(x, y, contents) { + var tooltip = $('#pie-tooltip').length ? + $('#pie-tooltip') : $('
'); + //var tooltip = $('#pie-tooltip') + tooltip.text(contents).css({ + position: 'absolute', + top : y + 5, + left : x + 5, + color : "#FFF", + border : '1px solid #FFF', + padding : '2px', + 'font-size': '8pt', + 'background-color': '#000', + }).appendTo("body"); + } + + elem.bind("plothover", function (event, pos, item) { + if (item) { + var percent = parseFloat(item.series.percent).toFixed(1) + "%"; + tt(pos.pageX, pos.pageY, + item.datapoint[1].toFixed(1) + " @ " + + new Date(item.datapoint[0]).format(config.timeformat)); + } else { + $("#pie-tooltip").remove(); + } + }); } } }; diff --git a/panels/pie/module.js b/panels/pie/module.js index 68ca313d92c..f0937ae078a 100644 --- a/panels/pie/module.js +++ b/panels/pie/module.js @@ -191,7 +191,7 @@ angular.module('kibana.pie', []) elem.bind("plothover", function (event, pos, item) { if (item) { - var percent = parseFloat(item.series.percent).toFixed(2) + "%"; + var percent = parseFloat(item.series.percent).toFixed(1) + "%"; piett(pos.pageX, pos.pageY, percent + " " + item.series.label); } else { $("#pie-tooltip").remove(); diff --git a/panels/text/module.html b/panels/text/module.html new file mode 100644 index 00000000000..92458c0f6c0 --- /dev/null +++ b/panels/text/module.html @@ -0,0 +1,4 @@ +
+

{{panel.title}}

+

{{panel.content}}

+
\ No newline at end of file diff --git a/panels/text/module.js b/panels/text/module.js new file mode 100644 index 00000000000..d0ae6b3db5f --- /dev/null +++ b/panels/text/module.js @@ -0,0 +1,17 @@ +angular.module('kibana.text', []) +.controller('text', function($scope, $rootScope) { + + var _id = _.uniqueId(); + + // Set and populate defaults + var _d = { + group : "default", + content : "", + 'fontsize': "100%" + } + _.defaults($scope.panel,_d); + + $scope.init = function() { + } + $scope.init(); +}) \ No newline at end of file