scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
28 lines (27 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateColorStops = exports.HEIGHT_SERIES_MAX_TEXTURE_SIZE = void 0;
exports.HEIGHT_SERIES_MAX_TEXTURE_SIZE = 1024;
function validateColorStops(colorSettings) {
if (!colorSettings) {
return true;
}
if (colorSettings.colorStops.length < 2) {
throw new Error("Must define at least 2 colorStops");
}
var minGap = Number.MAX_VALUE;
var colorStops = colorSettings.colorStops;
var min = colorStops[0].dataValue;
var max = colorStops[colorStops.length - 1].dataValue;
for (var i = 0; i < colorStops.length - 1; i++) {
if (colorStops[i].dataValue >= colorStops[i + 1].dataValue) {
throw new Error("colorStops must be unique and in ascending order");
}
minGap = Math.min(minGap, colorStops[i + 1].dataValue - colorStops[i].dataValue);
}
if ((max - min) / minGap > exports.HEIGHT_SERIES_MAX_TEXTURE_SIZE) {
throw new Error("Unsupported stop configuration. The range can be at most ".concat(exports.HEIGHT_SERIES_MAX_TEXTURE_SIZE, " times the smallest difference between stops.\n If you need more resolution than this, use a Fill PaletteProvider"));
}
return true;
}
exports.validateColorStops = validateColorStops;