invertExtent method

(num, num) invertExtent(
  1. Y y
)

Returns the extent of values in the domain (x0, x1) for the corresponding value in the range: the inverse of call.

color.invertExtent("#eff3ff"); // (2700, 3475)
color.invertExtent("#6baed6"); // (3800, 4300)
color.invertExtent("#08519c"); // (4950, 6300)

This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

Implementation

(num, num) invertExtent(Y y) {
  var i = _range.indexOf(y);
  return i < 0
      ? (double.nan, double.nan)
      : (
          i > 0 ? _thresholds[i - 1] : _domain[0],
          i < _thresholds.length
              ? _thresholds[i]
              : _domain[_domain.length - 1]
        );
}