File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
1
define ( [
2
2
'jquery' ,
3
3
'lodash' ,
4
+ 'moment'
4
5
] ,
5
- function ( $ , _ ) {
6
+ function ( $ , _ , moment ) {
6
7
'use strict' ;
7
8
8
9
var kbn = { } ;
@@ -580,6 +581,20 @@ function($, _) {
580
581
}
581
582
} ;
582
583
584
+ // Date and time
585
+ kbn . toDateTime = function ( size , timeScale ) {
586
+ var datetime = moment ( size * timeScale ) ;
587
+ return datetime . format ( 'YYYY-MM-DD hh:mm:ss' ) ;
588
+ } ;
589
+
590
+ kbn . valueFormats . datems = function ( size ) {
591
+ return kbn . toDateTime ( size , 1000 ) ;
592
+ } ;
593
+
594
+ kbn . valueFormats . dates = function ( size ) {
595
+ return kbn . toDateTime ( size , 1 ) ;
596
+ } ;
597
+
583
598
///// FORMAT MENU /////
584
599
585
600
kbn . getUnitFormats = function ( ) {
@@ -618,6 +633,13 @@ function($, _) {
618
633
{ text : 'days (d)' , value : 'd' } ,
619
634
]
620
635
} ,
636
+ {
637
+ text : 'date and time' ,
638
+ submenu : [
639
+ { text : 'date (ms)' , value : 'datems' } ,
640
+ { text : 'date (s)' , value : 'dates' }
641
+ ]
642
+ } ,
621
643
{
622
644
text : 'data' ,
623
645
submenu : [
You can’t perform that action at this time.
0 commit comments