Statistics app sort order

Started by Carlo Didier, April 25, 2018, 03:53:44 PM

Previous topic - Next topic

Carlo Didier

Quick question: is there a simple modification I can make to the statistics app to get the "Top 20 focal length" graph sorted by focal length instead of the number of pictures? I think I found the line for the sort, but I don't understand how it works at all ...

Mario

#1
This is doable. You need to change the function metadataFunc.

After the sort by size and the cut-off have been done, you sort by the numerical value of the name (in this case the focal length) in ascending order.



Click to zoom. Change enclosed in yellow border.
The sort function must return int: < 0 if a is < b, > 0 if a is > b, else 0. For numerical values a simple subtract is all that's needed.


Notes: This works in this case because the JavaScript parseFloat method can easily convert a text like "85 mm" into the numerical value "85".
This will not work for arbitrary tags (e.g. a country name or model name) so you will have to either make this dependent on the tag or allow the user to select which sort to use.

Do not change the default script because your changes will be overwritten when you install an updated version of IMatch.
Make a copy of the entire statsapp folder into your "User" app folder.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Works exactly as I wanted!

Thanks!

There are just too many focal lengths. Could they be grouped?

Carlo Didier

The app also considers the whole database. It would be useful to have it only consider the current selection.

Mario

This app is a sample app, to demonstrate how to use the D3 library.
Feel free to make your own app, with all the features you need.

Keep in mind that there is also the Charts Panel, with many powerful statistic functions.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Quote from: Mario on April 26, 2018, 12:04:50 PM
Keep in mind that there is also the Charts Panel, with many powerful statistic functions.

You mean the "Statistics" panel? That's not working at all for some cases (nothing is displayed at all) and not well for most others (not all focal lengths shown either for lack of space and/or good grouping).

Mario

Stats Panel right.
Just checked, focal length works great.  Remember: The Statistics Panel is interactive and works with the current selection! You can control the cut-off via the option (default is 20 for most standard charts).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Quote from: Mario on April 26, 2018, 03:22:45 PMStats Panel right.

Within limits ... see attached examples. The info about the shorter focal lengths is lost because there is no grouping to reduce the number of focal lengths displayed.

Mario

No, there is no grouping. Increase the cut-off to 50 to see 50 different focal length (or how many you use).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Hmm, looks like I really only need 3 fixed focal length lenses ...  8)