Skip to content

Rails 7 - Format y-axis to dollars #81

Answered by styd
bweathers3 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @bweathers3 . Sorry for a late reply. I was on a vacation.

Have you tried using formatter function?
I think you can try adding formatter for y-axis' label:

<% options = {
  title: 'Revenue vs Expenses',
  subtitle: 'Grouped Per Month',
  xtitle: 'Months',
  ytitle: 'Dollars',
  yaxis: {
    labels: {
      formatter: {
        function: {
          args: "val",
          body: "return '$' + parseFloat(val).toLocaleString();"
        }
      }
    }
  } 
} %>

You can also do so for the dataLabels.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by bweathers3
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants