Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global formatter for all metrics #812

Closed
wants to merge 8 commits into from
Closed

Global formatter for all metrics #812

wants to merge 8 commits into from

Conversation

mcuadros
Copy link

@mcuadros mcuadros commented Jan 7, 2014

Hi,

First at all, congratulations for this excellent tool.

In my company we are using kibana for make a bit of bi, so we have a lot of currency related metrics.

I cannot find any way to format the numbers as currency except in the new stats module
(#724)

So i decided to make this PR to provide a way to format every metric in all the panels,

The code is based in the same numeral library (http://adamwdraper.github.io/Numeral-js/) introduced with the stats panel. A new formatter service and partial template for the combo was made.

This is the list of working panels:

  • 'histogram',
  • 'pie'
  • 'hits'
  • 'trends'
  • 'terms'
  • 'stats'

Some screenshoots:
screen shot 2014-01-07 at 19 49 08
screen shot 2014-01-07 at 20 03 03
screen shot 2014-01-07 at 19 49 58

Regards

this.format = function(format, value) {
switch (format) {
case 'money':
value = numeral(value).format('$0,0.00');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps an idea to make the sign configurable?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, there are different currencies after all

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course this is no the final sign is just a wildcard from the numberal library.

The final currency sign will change if the language is changed. So i must include a global option (or maybe) a local one to provide the language.

@rashidkpc
Copy link
Contributor

This looks really good and is quite needed

@mcuadros
Copy link
Author

mcuadros commented Jan 7, 2014

Thanks @rashidkpc.

I am on right direction?, i want double check this before change all the editors and panels.

</tr>
</table>

<!-- horizontal legend above -->
<span class="small" ng-show="panel.arrangement == 'horizontal'" ng-repeat="term in legend" style="float:left;padding-left: 10px;">
<span><i class="icon-circle" ng-style="{color:term.color}"></i> {{term.label}} ({{term.data[0][1]}}) </span>
<span><i class="icon-circle" ng-style="{color:term.color}"></i> {{term.label}} ({{format(panel.format,term.data[0][1])}}) </span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to implement this as an angularjs filter

@rashidkpc
Copy link
Contributor

  • I'd rather see the format function attached to the kbn object for now. Thats where we've historically stored our utility functions.
  • Formatting in the view should be done as a filter
  • Optionally configurable precision would be good

@rashidkpc
Copy link
Contributor

Also important to run this through the grunt build process, currently doesn't build.

@mcuadros
Copy link
Author

mcuadros commented Jan 7, 2014

Perfect @rashidkpc i will take a look tomorrow in the morning, good hints.

I just uploaded too the global config setup, i placed the options at Global tab:
screen shot 2014-01-08 at 00 46 45

@mcuadros
Copy link
Author

mcuadros commented Jan 8, 2014

@rashidkpc about the "Optionally configurable precision would be good" i dont see any easy to use way to make this.

@rashidkpc
Copy link
Contributor

Yeah, I'm ok dropping configurable precision. Can you rebase this on top of master? I also noticed that the only locale available for english is en-gb?

@mcuadros
Copy link
Author

No you have en-gb and the default one the hardcoded one.

@mcuadros
Copy link
Author

Fixed and master merged.

@mcuadros
Copy link
Author

ping

@rashidkpc
Copy link
Contributor

Thanks, I'll review this next week. The change touches two dozen files so there's quite a lot of review to be done here

@mcuadros
Copy link
Author

mcuadros commented Feb 5, 2014

ping

@mithun35h
Copy link

Any update on this??

@mcuadros
Copy link
Author

🎯

@dumip
Copy link

dumip commented Jul 29, 2014

Any chance to have this feature merged into master?

@hadoopjax
Copy link

would like to see this added as we're using Kibana for a similar use case

@mcuadros
Copy link
Author

ping

@w33ble w33ble closed this Oct 6, 2014
@spalger
Copy link
Contributor

spalger commented Oct 6, 2014

Woops! Sorry about that! We recently replaced the master branch with Kibana 4. This action force closed all of the old pull requests against master. We will be reviewing these on a case-by-case basis and creating new tickets as necessary.

The good news is that many long requested features can be found in Kibana 4, and we're being entirely open about our roadmap. Check out the roadmap tickets (which we're still filling in) here.

If you're looking for the old Kibana 3 code you can find it here.

@rashidkpc
Copy link
Contributor

We've decided to take this in a slight different direction. We've centralized the logic for displaying field values and have a "Field Formatter" feature on the roadmap here: #1543

We believe this will give additional flexibly, as well as allowing for for better maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants