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

Continuous scales do not support .rangeRound() #232

Open
Pezmc opened this issue Dec 10, 2020 · 1 comment
Open

Continuous scales do not support .rangeRound() #232

Pezmc opened this issue Dec 10, 2020 · 1 comment

Comments

@Pezmc
Copy link

Pezmc commented Dec 10, 2020

The majority of scales (including sequential and diverging) support calling rangeRound() to return the rounded min and max.

However, time (underpinned by continuous) only supports .rangeRound([min, max]).
Not passing in arguments causes the method to throw, since the range gets set to undefined, then the scale expects the range to be defined!

Uncaught TypeError: Cannot read property 'length' of undefined

    function rescale() {
      var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear,
          uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
      output = linear(domain, range, uninterpolate, interpolate);
      input = linear(range, domain, uninterpolate, d3_interpolate);
      return scale;
    }
@mbostock
Copy link
Member

scale.rangeRound isn’t intended to be used as a getter; it’s only supposed to be used as a setter. This is an oversight.

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

No branches or pull requests

2 participants