echarts-stat icon indicating copy to clipboard operation
echarts-stat copied to clipboard

Datasets with one value break freedmanDiaconis and scott methods

Open hughess opened this issue 4 years ago • 1 comments

Occasionally, I need to show a histogram that contains only one value (the dataset below is an example):

[
{a: 5},
{a: 5},
{a: 5},
{a: 5},
{a: 5},
{a: 5},
{a: 5}
]

This works with the default bin method (square root) and works with sturges, but does not work with freedmanDiaconis or scott. For the two methods where it does not work, I receive an "Invalid array length" error.

While the chart itself isn't meaningful when it only has 1 value, it is a use case that will come up occasionally.

hughess avatar Nov 16 '21 15:11 hughess

+1

pomelo-alias avatar Jun 02 '22 03:06 pomelo-alias