Jump to content
  • 0

Column Chart Datapage with Multiple Number Fields - Columns not aligning with labels?


kpcollier

Question

I rarely use chart datapages, and I am struggling building one. Hoping for some insight.

The chart will receive an ID parameter on load. This will select a single field from our Job Table.

I need to include 12 number fields from this Job table record and compare them using columns. These Number fields are labeled JAN-DEC, but they are not Date/Time fields. They are for entering in an estimated amount of hours needed.

The columns aren't aligning with the legend/labels on the bottom of the chart, so it is hard to tell which is which.

 

*Edit: using third part chart libraries are much easier to use imo. 

chart2.PNG.4cf0feaee0c383310a62de3294b82a69.PNG

 

chart.PNG

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello @kpcollier,

Actually, Caspio uses the Highcharts library to render Chart DataPages, so you may want to check the Highcharts documentation https://api.highcharts.com/highcharts/ 

My understanding regarding the labels is that in your example these are not labels, but legend. You may test this by unchecking the "Display legend" checkbox.

For example, to decrease the space between the legend items you may add this code to the Footer:

<script>
document.addEventListener('DataPageReady', chartUpdateHandler)

function chartUpdateHandler(event) {

 var cleaner = function (interv) {
  clearInterval(interv);
 }

 let interv = setInterval(() => {

  var chart = Highcharts.charts[0];
  if (!chart) return;
  chart.update({
             legend: {         
               itemDistance: 0
               }
  });

  cleaner(interv);

 }, 200);
} 
</script>

 

This is not an ideal solution, however, you may test whether this helps to align the names of months.

Link to comment
Share on other sites

  • 0
On 4/5/2022 at 6:38 AM, CoopperBackpack said:

Hello @kpcollier,

Actually, Caspio uses the Highcharts library to render Chart DataPages, so you may want to check the Highcharts documentation https://api.highcharts.com/highcharts/ 

My understanding regarding the labels is that in your example these are not labels, but legend. You may test this by unchecking the "Display legend" checkbox.

For example, to decrease the space between the legend items you may add this code to the Footer:

<script>
document.addEventListener('DataPageReady', chartUpdateHandler)

function chartUpdateHandler(event) {

 var cleaner = function (interv) {
  clearInterval(interv);
 }

 let interv = setInterval(() => {

  var chart = Highcharts.charts[0];
  if (!chart) return;
  chart.update({
             legend: {         
               itemDistance: 0
               }
  });

  cleaner(interv);

 }, 200);
} 
</script>

 

This is not an ideal solution, however, you may test whether this helps to align the names of months.

Hi, sharing in here a script that I found that allows you to check if an element exists (followed by your code if that element in fact exists) instead of using a timer (setInterval):

 

function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                resolve(document.querySelector(selector));
                observer.disconnect();
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}

 

 

 

 

To use it:

waitForElm('.some-class').then((elm) => {
    console.log('Element is ready');
    console.log(elm.textContent);
});
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...