Jump to content

Change the labels of the Y Axis in Charts (Solution)


Recommended Posts

Pretty sure most of you guys was confused once in your Caspio lifetime on how you can set your Y Axis to any non-numeric values. I am not sure if we had the same adventures exploring charts but I only saw that it is doable only on Bar charts.

So, since I need this on my line chart to show the feedback on a school menu and I can't just simply show 1, 2, 3, 4, 5 in Y axis, I dug a little deeper in highcharts documentation. Here is what I did to change the Y-axis' values.

I made a table relationship with my table to a lookup table to show the text equivalent of the feedback in tables(display value). NOTE: you need the values in your main table as integer or number to put it in Y axis.

Then in the chart, set the y axis as the feedback field and set the aggregation to None,

Next paste this script in your footer block:

<script type = "text/javascript" >
    var timer = setInterval(function() {
   
        if (document.getElementsByTagName('rect') != null) {
       
            UpdateChart();
        }
    }, 500);
function UpdateChart() {
    try {
        Highcharts.charts[0].update({
yAxis: {
categories: [' ', 'Bad', 'Slightly Bad', 'Mediocre', 'Interesting', 'Outstanding']
}
});

        clearInterval(timer);
    } catch (err) {

    }
}; </script>

Simply change the categories to your proper labels but do not forget the blank category at the beginning as it will mess up your chart if you forget that.

Preview:
image.thumb.png.621d7922bb5330e74053c4d810c80a29.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...