Using Keen IO (https://keen.io), I am trying to get a Stripe event to show in $X.XX format when displayed as a Keen.Number.
The result come out in pennies, so I adjusted it to dollars by dividing by 100.
It is pre-formatted to one decimal place, and I'm having trouble adding two decimal places.
Thanks in advance.
Keen.onChartsReady(function() {
var revenue = new Keen.Metric(stripeEvent, {
analysisType: "sum",
timeframe: "this_day",
targetProperty: "data.object.amount",
timezone:"US/Pacific"
});
// Switch results from pennies to dollars
var resultsInDollars = {}
revenue.getResponse(function(response){
result = response.result/100
resultsInDollars = {
result: result
}
var revenue = new Keen.Number(revenue, {
prefix:"$",
label:"Revenue",
});
// Draw number
revenue.draw(document.getElementById("revenue"),resultsInDollars);
});
});
This should be a pretty easy fix!
Instead of:
result = response.result/100
try:
result = (Math.floor(response.result) / 100).toFixed(2)