Repository: voxel51/fiftyone

Issue:
[BUG] `Labels`' graph is incomplete and `Other fields`'s graph throws a `TypeError` 
### System information

-   **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Ubuntu 18.04
-   **FiftyOne installed from (pip or source)**: pip
-   **FiftyOne version (run `fiftyone --version`)**: 0.16.2
-   **Python version**: 3.9.12

### Commands to reproduce

As thoroughly as possible, please provide the Python and/or shell commands used
to encounter the issue. Application steps can be described in the next section.

```python
# load any dataset with 20+ classes
session = fo.launch_app(dataset, address="0.0.0.0", port=5151)
```

### Describe the problem

I am running a jupyter notebook server on a remote machine and accessing the fiftyone APP via chrome browser from a Macbook pro 2019 intel.

Describe the problem clearly here. Include descriptions of the expected
behavior and the actual behavior.

I have 37 classes in my dataset but I cannot visualise them fully on the "Show [graphs]" section. The bar chart only shows the first 10 even though the side bar indicates I have 37. Also, I cannot scroll on the drop-down menu of the labels sidebar. Find below example screenshots

<img width="282" alt="image" src="https://user-images.githubusercontent.com/35779409/171727580-2fbe7d66-1b9f-401c-842d-c2480b1458fa.png">
<img width="375" alt="image" src="https://user-images.githubusercontent.com/35779409/171727739-104618ab-5cef-46ae-8e43-007b996a4784.png">

Additionally, when trying to visualise the "other fields" graph I always get prompted with this `TypeError`:

```
TypeError: Invalid time value
    at DateTimeFormat.formatRange (<anonymous>)
    at content (http://192.168.19.35:5151/assets/index.0750e387.js:640:1190)
    at ef (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:62613)
    at up (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:83562)
    at th (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:121056)
    at Zh (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:109068)
    at Jh (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:108996)
    at Yh (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:108858)
    at Dh (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:105666)
    at Hh (http://192.168.19.35:5151/assets/vendor.b0739682.js:43:104198)
```

The expected behaviour is the one I was experiencing with version 0.15.1 where the "Show [graphs]" section is working fine and all the classes can be visualised. Find attaches example screenshots using the same dataset.

<img width="259" alt="image" src="https://user-images.githubusercontent.com/35779409/171728604-8bc0a9b4-3ae4-453e-a003-ec3d65dc10a9.png">

<img width="1103" alt="image" src="https://user-images.githubusercontent.com/35779409/171728448-e8eb645a-5e2a-46ee-afee-cafccc23779d.png">


### Code to reproduce issue

Load any dataset with 20+ classes into fiftyone 0.16.2.

### Other info / logs

Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and
files should be attached. Please do not use screenshots for sharing text. Code
snippets should be used instead when providing tracebacks, logs, etc.

### What areas of FiftyOne does this bug affect?

-   [x] `App`: FiftyOne application issue
-   [ ] `Core`: Core `fiftyone` Python library issue
-   [ ] `Server`: Fiftyone server issue

### Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?

-   [ ] Yes. I can contribute a fix for this bug independently.
-   [x] Yes. I would be willing to contribute a fix for this bug with guidance
        from the FiftyOne community.
-   [ ] No. I cannot contribute a bug fix at this time.



Discussion:

Resolving patch:
diff --git a/fiftyone/server/routes/distributions.py b/fiftyone/server/routes/distributions.py
--- a/fiftyone/server/routes/distributions.py
+++ b/fiftyone/server/routes/distributions.py
@@ -47,7 +47,7 @@ def filter(field):
 
                 return path
 
-            aggs, fields, paths = _count_values(filter, view)
+            aggs, fields, paths = _count_values(filter, view, limit)
             results = await _gather_results(aggs, fields, paths, view)
 
         elif group == "labels":
@@ -60,7 +60,7 @@ def filter(field):
 
                 return path
 
-            aggs, fields, paths = _count_values(filter, view)
+            aggs, fields, paths = _count_values(filter, view, limit)
             results = await _gather_results(aggs, fields, paths, view)
 
         elif group == "sample tags":
@@ -84,7 +84,7 @@ def filter(field):
 
                 return None
 
-            aggs, fields, paths = _count_values(filter, view)
+            aggs, fields, paths = _count_values(filter, view, limit)
 
             (
                 hist_aggs,
@@ -224,7 +224,7 @@ async def _gather_results(aggs, fields, paths, view, ticks=None):
     return results
 
 
-def _count_values(f, view):
+def _count_values(f, view, limit):
     aggregations = []
     fields = []
     schemas = [(view.get_field_schema(), "")]
@@ -242,7 +242,7 @@ def _count_values(f, view):
             paths.append(prefix + path)
             aggregations.append(
                 foa.CountValues(
-                    "%s%s" % (prefix, path), _first=LIST_LIMIT, _asc=False
+                    "%s%s" % (prefix, path), _first=limit, _asc=False
                 )
             )
 
@@ -284,7 +284,7 @@ async def _numeric_histograms(view, schema, prefix=""):
                 range_ = [0, 1]
 
         if isinstance(range_[1], datetime):
-            range_ = (range_[0], range_[1] + timedelta(milliseconds=1))
+            range_ = (range_[0], range_[1] + timedelta(milliseconds=100))
         elif isinstance(range_[1], date):
             range_ = (range_[0], range_[1] + timedelta(days=1))
         else:


Test patch: