Convert Seconds to Formatted Time in Bar/Column/Line charts

Comments

5 comments

  • Avatar
    wynne christen

    Works beautifully. Thank you.

    0
    Comment actions Permalink
  • Avatar
    Ilan Shichor

    For Pivot Tables and Indicators, please see this link: https://support.sisense.com/entries/40938460-Convert-Seconds-to-Time-Format-in-Pivot-Tables

    0
    Comment actions Permalink
  • Avatar
    Brian Bontrager (Edited )

    This is great!

     

    You can also apply this to the tooltip (for when you hover over the bar). Define convertRawTime() outside widget.on(...), and add another event handler to reformat the tooltip value.

     

    widget.on("beforedatapointtooltip",function(w,args){

    args.context.points[0].value=convertRawTime(args.context.points[0].value)

    })

     

    0
    Comment actions Permalink
  • Avatar
    Vishali Manivannan

    Could the script be modified to have the time format displayed in the Y2-axis instead of the Y-axis? The Y axis displays # of calls and the X axis displays the dates. 

    The widget displays a column chart with one of the values displayed as a line (series type) and the Y2 axis should display the time format. The values should be displayed in time format when you hover over the line.

    Thanks.

    0
    Comment actions Permalink
  • Avatar
    shani adani

    Hi Vishali, 

    If you want to apply the formatting on the second Y-axis, you can change the second Y-axis formatter by switching lines 27-29 with:

    if (args.options.yAxis.length > 1) {
       args.options.yAxis[1].labels.formatter = function(){
            return convertRawTime(this.value);
       };
    }

    1
    Comment actions Permalink

Please sign in to leave a comment.