UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

14 lines (13 loc) 510 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.invertScale = invertScale; var _isBandScale = require("./isBandScale"); function invertScale(scale, data, value) { if ((0, _isBandScale.isBandScale)(scale)) { const dataIndex = scale.bandwidth() === 0 ? Math.floor((value - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((value - Math.min(...scale.range())) / scale.step()); return data[dataIndex]; } return scale.invert(value); }