From 87c0a0e2e17ba680fdd77ce2d27bfd54e5402733 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Wed, 13 Mar 2013 14:18:59 -0700 Subject: [PATCH] Made histogram x-axis labels dynamic --- config.js | 4 ---- panels/histogram/module.js | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/config.js b/config.js index a009e8a5a2f..eb21b00c348 100644 --- a/config.js +++ b/config.js @@ -3,13 +3,10 @@ elasticsearch: URL to your elasticsearch server kibana_index: The default ES index to use for storing Kibana specific object such as stored dashboards -timeformat: Format for time in histograms (might go away) modules: Panel modules to load. In the future these will be inferred from your initial dashboard, though if you share dashboards you will probably need to list them all here -NOTE: No timezone support yet, everything is in UTC at the moment. - If you need to configure the default dashboard, please see default.json */ @@ -17,7 +14,6 @@ var config = new Settings( { elasticsearch: 'http://localhost:9200', kibana_index: "kibana-int", - timeformat: 'mm/dd HH:MM:ss', modules: ['histogram','map','pie','table','stringquery','sort', 'timepicker','text','fields','hits','dashcontrol', 'column'], diff --git a/panels/histogram/module.js b/panels/histogram/module.js index e64c017e190..443e482362f 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -209,7 +209,7 @@ angular.module('kibana.histogram', []) timezone: scope.panel.timezone, show: show['x-axis'], mode: "time", - timeformat: "%H:%M:%S
%m-%d", + timeformat: time_format(scope.panel.interval), label: "Datetime", color: "#000", }, @@ -231,6 +231,18 @@ angular.module('kibana.histogram', []) }) } + 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
%m/%d" + else + return "%H:%M:%S" + } + function tt(x, y, contents) { var tooltip = $('#pie-tooltip').length ? $('#pie-tooltip') : $('
'); @@ -252,7 +264,7 @@ angular.module('kibana.histogram', []) 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)); + new Date(item.datapoint[0]).format('mm/dd HH:MM:ss')); } else { $("#pie-tooltip").remove(); }