jjmontesl / cubesviewer

Explore and visualize analytical datasets
http://www.cubesviewer.com
Other
441 stars 112 forks source link

Allow currency, integer, and number formatting of aggregates #61

Closed devvmh closed 8 years ago

devvmh commented 8 years ago

Allows aggregates to include any of the following options:

"info": {
  "cv-formatter": "integer"
}
"info": {
  "cv-formatter": "percent"
}
"info": {
  "cv-formatter": "currency",
  "cv-currency-prefix: "",
  "cv-currency-suffix: "元"
}

The currency formatter prefixes a '$' character by default.

devvmh commented 8 years ago

I'm happy to update the cv- option names if you have API ideas of your own

devvmh commented 8 years ago

Thanks for merging all these PRs! That's great!

I threw up a commit with some documentation to this PR. I'm happy to make changes to any of these branches as I have time

jjmontesl commented 8 years ago

Based on your commit, I implemented this on measures instead of aggregates, and using a Javascript expression for formatting. Applies to all views, including charts.

I'm closing this. If you still need per-aggregate formatting please let me know filing a new issue.

devvmh commented 8 years ago

That's excellent.

That'll cover me for most cases except for my aggregates that use expressions. I'm using a devel version of cubes that enables aggregates to look like this:

{
  "name": "sign_rate",
  "label": "签单率",
  "expression": "(is_deposit_received_sum - refunded_sum) / valuable_sum",
  "info": {
    "cv-formatter": "percent"
  }
}

So then I'm not sure if that aggregate will take on the formatting of any of those dimensions.

I'll update my patched version of cubesviewer in the next two weeks and see what I can make work, and I'll submit an issue or pull request with what I figure out.

Thanks for merging all this!

jjmontesl commented 8 years ago

No, I was suspecting something like this. Then we need to also support expressions for aggregates, it shall be easy to do by slightly improving columnFormatFunction in cubesviewer.views.cube.js, to use the formatter from the aggregate if one is defined.

However, hold on. I need more time to finish the ongoing refactor, so please bear with me until I can release a working update. I do not recommend to do much work on the current master branch during the next couple of weeks :/.

devvmh commented 8 years ago

Amazing, sounds good. I'm not working actively on my cubesviewer project right now anyway, so that works well (unless the project manager comes back to me tomorrow with feature requests!!)

On Mon, Apr 18, 2016 at 11:19 AM Jose Juan Montes notifications@github.com wrote:

No, I was suspecting something like this. Then we need to also support expressions for aggregates, it shall be easy to do by slightly improving columnFormatFunction in cubesviewer.views.cube.js, to use the formatter from the aggregate if one is defined.

However, hold on. I need more time to finish the ongoing refactor, so please bear with me until I can release a working update. I do not recommend to do much work on the current master branch.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jjmontesl/cubesviewer/pull/61#issuecomment-211170410