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

Histogram can't take function as binsNumber argument #7457

Closed
Munksgaard opened this Issue Nov 27, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@Munksgaard
Contributor

Munksgaard commented Nov 27, 2017

Expected behaviour

Passing a function as the binsNumber argument to a histogram chart uses that function to compute the number of bins to show.

Actual behaviour

The following error is thrown (in Chrome)

Uncaught TypeError: f is not a function
    at l.binsNumber (https://code.highcharts.com/modules/histogram-bellcurve.js:13:354)
    at l.setDerivedData (https://code.highcharts.com/modules/histogram-bellcurve.js:12:442)
    at a.Chart.<anonymous> (https://code.highcharts.com/modules/histogram-bellcurve.js:10:78)
    at a.fireEvent (https://code.highcharts.com/highcharts.js:31:242)
    at a.Chart.<anonymous> (https://code.highcharts.com/modules/histogram-bellcurve.js:11:26)
    at a.Chart.a.(anonymous function) [as linkSeries] (https://code.highcharts.com/highcharts.js:19:293)
    at a.Chart.firstRender (https://code.highcharts.com/highcharts.js:256:277)
    at a.Chart.init (https://code.highcharts.com/highcharts.js:232:5)
    at a.Chart.getArgs (https://code.highcharts.com/highcharts.js:230:403)
    at new a.Chart (https://code.highcharts.com/highcharts.js:230:202)

Live demo with steps to reproduce

http://jsfiddle.net/3drny1k9/1/

Affected browser(s)

Firefox and chrome

@Munksgaard

This comment has been minimized.

Show comment
Hide comment
@Munksgaard

Munksgaard Nov 27, 2017

Contributor

I believe the following code is at fault: https://github.com/highcharts/highcharts/blob/master/js/modules/histogram.src.js#L190-L198

The computed binsNumber on line 192 is a boolean (true if the argument was a function, false otherwise) and on line 195 it is called as a function resulting in the error that is shown above.

Contributor

Munksgaard commented Nov 27, 2017

I believe the following code is at fault: https://github.com/highcharts/highcharts/blob/master/js/modules/histogram.src.js#L190-L198

The computed binsNumber on line 192 is a boolean (true if the argument was a function, false otherwise) and on line 195 it is called as a function resulting in the error that is shown above.

@KacperMadej

This comment has been minimized.

Show comment
Hide comment
@KacperMadej

KacperMadej Nov 27, 2017

Contributor

Hi,

Thank you for reporting about the bug and pointing the source of the error.

Another problems:

  • number of bins is bigger than the setting by 1
  • docs says: By default it is set to the square of the base series' data length but should say square root
Contributor

KacperMadej commented Nov 27, 2017

Hi,

Thank you for reporting about the bug and pointing the source of the error.

Another problems:

  • number of bins is bigger than the setting by 1
  • docs says: By default it is set to the square of the base series' data length but should say square root
@KacperMadej

This comment has been minimized.

Show comment
Hide comment
@KacperMadej

KacperMadej Nov 28, 2017

Contributor

The above commit should resolve 2 out of 3 issues: allow functions to be used as the option and fix docs info.

The remaining issue can be resolved by having the last bin right closed.
Would that be a good solution?
@morganfree

Contributor

KacperMadej commented Nov 28, 2017

The above commit should resolve 2 out of 3 issues: allow functions to be used as the option and fix docs info.

The remaining issue can be resolved by having the last bin right closed.
Would that be a good solution?
@morganfree

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