Reverse X-axis order in a Line Chart

Comments

10 comments

  • Avatar
    David Hertzberg

    Thanks a lot Tommy !

    Where can we find a complete API reference ? The developperwebsite makes no reference to the reverse() method, and there is no DOM description for widgets and dashboards. You have to guess from examples or DOM explorer in your browser ...

    Thanks,

    David.

    0
    Comment actions Permalink
  • Avatar
    Sam Ovenshine

     

    To reverse the y-axis, try this script:

    widget.on("processresult",function(w,args){
    for (i=0;i<args.result.series.length;i++) {
    args.result.series[i].data.reverse();
    };
    args.result.yAxis[0].categories.reverse();
    })

    0
    Comment actions Permalink
  • Avatar
    Glenys Salas

    Hi!  I tried this and it didn't work

     



    0
    Comment actions Permalink
  • Avatar
    Sam Ovenshine

    Hi Glenys,

    Thanks for letting us know. We'll take a look and see if we can update the script.

    Sam

    0
    Comment actions Permalink
  • Avatar
    Brian Wilson

    Hi Sam, Any update on this one? I'd like to flip a line chart widget so that 1 (Ranked First) is at the top of Y-axis and the bottom ranked item is at the bottom. The chart would look like the attached (though with positive numbers instead of negative ones!)

    0
    Comment actions Permalink
  • Avatar
    Anjali Yadav

    I need a script to switch the ordering of x-axis in a chart with no break-by. Please help.

    0
    Comment actions Permalink
  • Avatar
    Tad Carlson

    I had success with the original script to reverse order of the x-axis:

    widget.on("processresult",function(w,args){
    	for (i=0;i<args.result.series.length;i++) {
    		args.result.series[i].data.reverse();
    	};
    	args.result.xAxis.categories.reverse();
    })

     

    However, I'm wondering if anything was ever developed for the same functionality y-axis?  

    0
    Comment actions Permalink
  • Avatar
    An Y

    Hi Tad 

    What is your chart type Bar or Column ?  My results with your script -

    Bar chart : reversed the y-axis

    Coln chart : reversed  nothing

     

    An

    0
    Comment actions Permalink
  • Avatar
    Tad Carlson

    Line chart

    0
    Comment actions Permalink
  • Avatar
    An Y (Edited )

    Correction : worked on my Line chart x axis as you had earlier stated.

    For the Y-axis I just tried the element highlighted in the screenshot attached, shows the array reversed in the console but no change on the  display,

    0
    Comment actions Permalink

Please sign in to leave a comment.