Jump to content
  • 0

Set a fixed zero (start) point value in graphs


KG360

Question

Caspio graphs adjust the scale and the start point value to the data.

I would need a script that sets the start / zero point to numerical zero  (regardless of whether it's percent or currency etc).

Would anyone have such a script to pass on?

/KG

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello,

There is an option to set the Y Axis range manually:

image.png.792687121db6da1b04732acabade1c20.png


To change the chart using JavaScript, I found this article that shows some options: https://howto.caspio.com/tech-tips-and-articles/customize-caspio-chart-datapages/

I tried to change that code and I was able to make the Chart to always start from 0 on the YAxis and it seems to work for some Charts. Maybe there is someone else that knows a better approach:

 

<script>
        document.addEventListener('DataPageReady', function()
        {
            var cleaner = function(interv) {
            clearInterval(interv);
            } 

            let interv = setInterval(() => {

                if(typeof Highcharts == "undefined" || !Highcharts.charts.length) return;
                    var seriesLength = Highcharts.charts[0].series.length;
                    var getInsideValue = Highcharts.charts[0].series[0].userOptions.data.length;

                    cleaner(interv);
                Highcharts.charts[0].yAxis[0].min = 0
                Highcharts.charts[0].redraw();
    })
    });
</script>

 

Link to comment
Share on other sites

  • 0
On 4/12/2024 at 12:16 PM, Barry said:

Hello,

There is an option to set the Y Axis range manually:

image.png.792687121db6da1b04732acabade1c20.png


To change the chart using JavaScript, I found this article that shows some options: https://howto.caspio.com/tech-tips-and-articles/customize-caspio-chart-datapages/

I tried to change that code and I was able to make the Chart to always start from 0 on the YAxis and it seems to work for some Charts. Maybe there is someone else that knows a better approach:

 

<script>
        document.addEventListener('DataPageReady', function()
        {
            var cleaner = function(interv) {
            clearInterval(interv);
            } 

            let interv = setInterval(() => {

                if(typeof Highcharts == "undefined" || !Highcharts.charts.length) return;
                    var seriesLength = Highcharts.charts[0].series.length;
                    var getInsideValue = Highcharts.charts[0].series[0].userOptions.data.length;

                    cleaner(interv);
                Highcharts.charts[0].yAxis[0].min = 0
                Highcharts.charts[0].redraw();
    })
    });
</script>

 

Many thanks @Barry! The first method does not work and the option does not even show up. This may be because of how the data series are selected and the type of graph. With a wuick test of the script it does not work either. I will try again later and get back to this thread.

/KG

Screenshot 2024-04-15 183729.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
Answer this question...

×   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...