question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Data numbers to money

See original GitHub issue

Just a question here. My data array is money. I use accounting.js to convert to money.

var data = {
    labels: ["January", "February", "March", "April", "May", "June", "July"],
    datasets: [
        {
            label: "My First dataset",
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1,
            data: [65, 59, 80, 81, 56, 55, 40],
        }
    ]
};

Let’s focus on the data array. I need to convert the numbers to money.

var a = accounting.formatMoney(65, "£", 2, ",", ".");
var b = accounting.formatMoney(59, "£", 2, ",", ".");
...

data: [a, b, ...] // This possible?

How to go about this? Is this a StackOverflow question? Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
madmoizocommented, Nov 18, 2016

Let your data be numbers and override the display (coffeescript syntax):

tooltips: callbacks: label: (tooltipItem, data) -> return ' ' + tooltipItem.yLabel + ' £'

scales: yAxes: [ ticks: callback: (tick, index, ticks) -> return tick + ' £' ]

0reactions
SylarRubycommented, Nov 18, 2016

@frlinw Yes. I had to use http://js2.coffee/ 😃 Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Format numbers as currency - Microsoft Support
Display numbers as currency in your worksheet, and then read about differences between the Currency and Accounting formats.
Read more >
Google | Phone | Currency Conversion - LeetCode Discuss
Question Paramenters: array of currency conversion rates. E.g. ['USD', 'GBP', 0.77] which means 1 USD is equal to 0.77 GBP; an array containing...
Read more >
How to format numbers as currency strings - Stack Overflow
You will loose precision and data. You should store it as a integer number of cents (or pennies etc.) and then convert prior...
Read more >
How to Format the Values of Numbers in a Pivot Table - Got It AI
Here's how to format values in a pivot table to get your data the way you want it. ... Post your problem and...
Read more >
Please use the table below to answer the following questions ...
C = currency. D = demand deposits. ER = excess reserves. RR = required reserves. MB = monetary base. All numbers are in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found