Chart Averages

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Is there any way to restrict the number of decimal points the Average aggregate function uses?



I am getting a huge number of decimal places in my chart. Not causing any functional problems, but doesn't look the best!

Thanks in advance.
Photo of sam

sam

  • 588 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Yup. A snippet for this.

var chart = arguments[0],
    
    chart.tooltip.formatter = function () {
                return this.x + '(AVG): ' + Math.round(this.y) ;
            };
    
   

Put the snippet name here.
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks Pat.  Looks like you are digging into the HiCharts API pretty hard.. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
And this:  J told me at lunch that this issue will be fixed in our next release... 
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Sam,

Pat's snippet will work, but try setting chart.tooltip.valueDecimals if you want to keep the rest of the formatting at the default, but limit the number of decimals.

I do want to mention that making our tooltips a little smarter when it comes to the number of decimal places will be included in our next patch release. Basically, Skuid will automatically limit the number of decimal places shown in the tooltip to whatever your value field's metadata specifies. If none is specified for your value field, the tooltip will display as it did before.

Also, if you want to make those bars a little wider, try turning Stacking on:

    
Photo of sam

sam

  • 588 Points 500 badge 2x thumb
Thanks for all the replies. Problem solved!
Photo of Eoin O'Neill

Eoin O'Neill

  • 144 Points 100 badge 2x thumb
This script throws an error as of today looks like you can't access tooltip any more? 
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Is this in reference to your other post? If so, I just wanted to close the loop on this thread for anyone who might come across it. Thanks! 
Photo of Eoin O'Neill

Eoin O'Neill

  • 144 Points 100 badge 2x thumb
Yep it is, thanks :) Apologies for the cross posting, was doing the same thing as the solution here now no longer works. Checking out the solution provided on the other thread now :)