mm.js - Change Currency and Locale Documentation

Change the Currency and Locale of an embedded Chart or Calculator

mm.js - Change Currency and Locale Documentation

It’s simple to change the currency of a mm.js chart.

Just call moneymage.setLocaleCurrency()

The defaults are Money Mage currency and locale are: GBP for currency and en-GB for locale.

How to Embed

If you are using WordPress use the HTML editor.

1. Include the required dependencies

Add the following scripts to your page:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.3/clipboard.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.12.0/d3.min.js"></script>
<script src="https://www.moneymage.net/mm.min.js"></script>

These are required dependencies for mm.js. They are all minified, compressed, and served via a reliable Content Distribution Network to improve your site speed.

2. Add a containing div to your page or article

Insert a containing div to your page or article where you would like the chart to appear.

Specify an ID that you will use later.

<div id="compound-interest-chart"></div>

The chart will be inserted at this location.

3. Call mm.js to insert the chart

You are now ready to add the chart!

Insert a <script> ... </script> block to the bottom of your page.

Add the following script to your page or article.

The arguments you provide will change the behaviour of the chart.

<script>
moneymage.setLocaleCurrency("en-US", "USD");
moneymage.ready(() => {
    var principal = 0;
    var interestRate = 3.0/100.0;
    var monthlyContributions = 100;
    var months = 25 * 12;

    moneymage.createCompoundInterestChart(principal, 
                                     interestRate, 
                                     monthlyContributions, 
                                     months,
                                     "compound-interest-chart");
});
</script>

API

moneymage.setLocaleCurrency()

Set the currency and locale used by mm.js

Parameters


Parameter Type Description
locale string An IETF BCP 47 locale, i.e. en-GB, en-US.
currency string An ISO currency code, i.e. GBP, USD, JPY


Example

    moneymage.setLocaleCurrency("ja-JP", "JPY");
    moneymage.createCompoundInterestChart(1000, 
                                     0.03, 
                                     50, 
                                     12,
                                     "compound-interest-chart");