mode / alamode

A community-maintained library of visualizations for Mode reports
MIT License
70 stars 67 forks source link

Support user-provided formatter for addTotalsRow #30

Closed sprine closed 6 years ago

sprine commented 6 years ago

Often when summing up tables, we really just need to round up the number to two decimal places. Similarly, for financials, a prefix of $ or € may be desirable.

This PR allows the user to provide their own d3 formatter via the fmt parameter. If not provided, the default formatter is applied.

alamode.addTotalsRow({ 
    query_name: "Overview",
    table_id: "table_xxx,
    columns_with_totals: ["Number of Merchants", "Sales"],
    fmt: d3.format(",.2f"),
})

/cc @mdeadman @deniszgonjanin

bstancil commented 6 years ago

Love it. Thanks!