1

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);
  });
});
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
Brent Chow
  • 327
  • 3
  • 10

1 Answers1

3

This should be a pretty easy fix!

Instead of:

result = response.result/100

try:

result = (Math.floor(response.result) / 100).toFixed(2)
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • It results in a perpetual "Loading..." – Brent Chow Feb 08 '14 at 00:15
  • 1
    The perpetual loading turned out to have been an issue with the logic in our JS SDK! We're coming out with a new JS SDK soon and this definitely won't be an issue in the new SDK. We're working on fixing the current JS SDK so you can use 2 decimal points. Sorry about this! – Rebecca Standig Feb 08 '14 at 01:36