Thursday, January 18, 2018

Date format in C3Graph

axis: {
                                 x: {
                                  type: 'timeseries',
                                    tick: {
                                         format: '%Y-%m-%d',// '%I-%M',
                                        culling: false,
                                        count:25,
                                        rotate: 60
                                     },
                                   /*
                                                       * tick: { values: xAxisTickValues, format:
                                                       * function (x) { return formatDateForGraph(x); },
                                                       * rotate: 60 },
                                                       */
                                    
                                     label: {
                                         text: messageObject.robotView.graph.xAxisValue/*,
                                         position: 'outer-middle'*/  }
                               
                                 },
                                 y: {
                                   max: 2.5,
                                      min: 0,
                                     label: {
                                         text: messageObject.robotView.graph.yAxisValue,
                                         position: 'outer-top'}
                                 }
                                
                             },
                                       tooltip: {
                                                  format: {
                                                    title: function (x) {
                                                       return getFormattedRobotViewDate(x) }
                                                  }
                                                }
                              
                                   });


function getFormattedRobotViewDate(date) {
                               var d = new Date(date),
                                   month = '' + (d.getMonth() + 1),
                                   day = '' + d.getDate(),
                                   year = d.getFullYear(),
                                   hour = ''+d.getHours(),
                                   minutues = ''+d.getMinutes();
                                   /*seconds = ''+d.getSeconds(),
                                   milliSeconds=''+d.getMilliseconds();*/

                                   if (month.length < 2) month = '0' + month;
                                   if (day.length < 2) day = '0' + day;
                                   if(hour.length<2) hour='0'+hour;
                                   if(minutues.length<2) minutues='0'+minutues;
                                   /*if(seconds.length<2) seconds='0'+seconds;
                                   if(milliSeconds.length==1) milliSeconds ='00'+milliSeconds;
                                   if(milliSeconds.length==2) milliSeconds ='0'+milliSeconds;*/
                                   var requiredDateStepOne = [year, month, day].join('-');
                                   var finalDate = requiredDateStepOne+" "+hour+":"+minutues;
                                   return finalDate;
                            }




No comments:

Post a Comment

Recent Post

Databricks Delta table merge Example

here's some sample code that demonstrates a merge operation on a Delta table using PySpark:   from pyspark.sql import SparkSession # cre...