hyperprop-charting-library 0.1.125 → 0.1.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hyperprop-charting-library.cjs +29 -6
- package/dist/hyperprop-charting-library.js +29 -6
- package/dist/index.cjs +29 -6
- package/dist/index.js +29 -6
- package/package.json +1 -1
|
@@ -303,15 +303,38 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
303
303
|
var clampIndicatorLength = (value, fallback) => {
|
|
304
304
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
305
305
|
};
|
|
306
|
-
var
|
|
307
|
-
if (!value) return
|
|
306
|
+
var parseColorToRgb = (value) => {
|
|
307
|
+
if (!value) return null;
|
|
308
308
|
const normalized = value.trim().toLowerCase();
|
|
309
|
-
if (normalized === "white"
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
if (normalized === "white") return { r: 255, g: 255, b: 255 };
|
|
310
|
+
if (normalized === "black") return { r: 0, g: 0, b: 0 };
|
|
311
|
+
const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
|
|
312
|
+
if (hex3) {
|
|
313
|
+
return {
|
|
314
|
+
r: parseInt(hex3[1] + hex3[1], 16),
|
|
315
|
+
g: parseInt(hex3[2] + hex3[2], 16),
|
|
316
|
+
b: parseInt(hex3[3] + hex3[3], 16)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
|
|
320
|
+
if (hex) {
|
|
321
|
+
return {
|
|
322
|
+
r: parseInt(hex[1], 16),
|
|
323
|
+
g: parseInt(hex[2], 16),
|
|
324
|
+
b: parseInt(hex[3], 16)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
328
|
+
if (rgb) {
|
|
329
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
312
332
|
};
|
|
313
333
|
var labelTextColorOn = (background, textColor) => {
|
|
314
|
-
|
|
334
|
+
const rgb = parseColorToRgb(background);
|
|
335
|
+
if (!rgb) return textColor;
|
|
336
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
337
|
+
return luminance >= 0.62 ? "#000000" : textColor;
|
|
315
338
|
};
|
|
316
339
|
var computeSmaSeries = (data, length, source) => {
|
|
317
340
|
const result = new Array(data.length).fill(null);
|
|
@@ -277,15 +277,38 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
277
277
|
var clampIndicatorLength = (value, fallback) => {
|
|
278
278
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
279
279
|
};
|
|
280
|
-
var
|
|
281
|
-
if (!value) return
|
|
280
|
+
var parseColorToRgb = (value) => {
|
|
281
|
+
if (!value) return null;
|
|
282
282
|
const normalized = value.trim().toLowerCase();
|
|
283
|
-
if (normalized === "white"
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
if (normalized === "white") return { r: 255, g: 255, b: 255 };
|
|
284
|
+
if (normalized === "black") return { r: 0, g: 0, b: 0 };
|
|
285
|
+
const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
|
|
286
|
+
if (hex3) {
|
|
287
|
+
return {
|
|
288
|
+
r: parseInt(hex3[1] + hex3[1], 16),
|
|
289
|
+
g: parseInt(hex3[2] + hex3[2], 16),
|
|
290
|
+
b: parseInt(hex3[3] + hex3[3], 16)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
|
|
294
|
+
if (hex) {
|
|
295
|
+
return {
|
|
296
|
+
r: parseInt(hex[1], 16),
|
|
297
|
+
g: parseInt(hex[2], 16),
|
|
298
|
+
b: parseInt(hex[3], 16)
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
302
|
+
if (rgb) {
|
|
303
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
286
306
|
};
|
|
287
307
|
var labelTextColorOn = (background, textColor) => {
|
|
288
|
-
|
|
308
|
+
const rgb = parseColorToRgb(background);
|
|
309
|
+
if (!rgb) return textColor;
|
|
310
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
311
|
+
return luminance >= 0.62 ? "#000000" : textColor;
|
|
289
312
|
};
|
|
290
313
|
var computeSmaSeries = (data, length, source) => {
|
|
291
314
|
const result = new Array(data.length).fill(null);
|
package/dist/index.cjs
CHANGED
|
@@ -303,15 +303,38 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
303
303
|
var clampIndicatorLength = (value, fallback) => {
|
|
304
304
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
305
305
|
};
|
|
306
|
-
var
|
|
307
|
-
if (!value) return
|
|
306
|
+
var parseColorToRgb = (value) => {
|
|
307
|
+
if (!value) return null;
|
|
308
308
|
const normalized = value.trim().toLowerCase();
|
|
309
|
-
if (normalized === "white"
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
if (normalized === "white") return { r: 255, g: 255, b: 255 };
|
|
310
|
+
if (normalized === "black") return { r: 0, g: 0, b: 0 };
|
|
311
|
+
const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
|
|
312
|
+
if (hex3) {
|
|
313
|
+
return {
|
|
314
|
+
r: parseInt(hex3[1] + hex3[1], 16),
|
|
315
|
+
g: parseInt(hex3[2] + hex3[2], 16),
|
|
316
|
+
b: parseInt(hex3[3] + hex3[3], 16)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
|
|
320
|
+
if (hex) {
|
|
321
|
+
return {
|
|
322
|
+
r: parseInt(hex[1], 16),
|
|
323
|
+
g: parseInt(hex[2], 16),
|
|
324
|
+
b: parseInt(hex[3], 16)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
328
|
+
if (rgb) {
|
|
329
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
312
332
|
};
|
|
313
333
|
var labelTextColorOn = (background, textColor) => {
|
|
314
|
-
|
|
334
|
+
const rgb = parseColorToRgb(background);
|
|
335
|
+
if (!rgb) return textColor;
|
|
336
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
337
|
+
return luminance >= 0.62 ? "#000000" : textColor;
|
|
315
338
|
};
|
|
316
339
|
var computeSmaSeries = (data, length, source) => {
|
|
317
340
|
const result = new Array(data.length).fill(null);
|
package/dist/index.js
CHANGED
|
@@ -277,15 +277,38 @@ var getIndicatorSourceValue = (point, source) => {
|
|
|
277
277
|
var clampIndicatorLength = (value, fallback) => {
|
|
278
278
|
return Math.max(1, Math.round(Number(value) || fallback));
|
|
279
279
|
};
|
|
280
|
-
var
|
|
281
|
-
if (!value) return
|
|
280
|
+
var parseColorToRgb = (value) => {
|
|
281
|
+
if (!value) return null;
|
|
282
282
|
const normalized = value.trim().toLowerCase();
|
|
283
|
-
if (normalized === "white"
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
if (normalized === "white") return { r: 255, g: 255, b: 255 };
|
|
284
|
+
if (normalized === "black") return { r: 0, g: 0, b: 0 };
|
|
285
|
+
const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
|
|
286
|
+
if (hex3) {
|
|
287
|
+
return {
|
|
288
|
+
r: parseInt(hex3[1] + hex3[1], 16),
|
|
289
|
+
g: parseInt(hex3[2] + hex3[2], 16),
|
|
290
|
+
b: parseInt(hex3[3] + hex3[3], 16)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
|
|
294
|
+
if (hex) {
|
|
295
|
+
return {
|
|
296
|
+
r: parseInt(hex[1], 16),
|
|
297
|
+
g: parseInt(hex[2], 16),
|
|
298
|
+
b: parseInt(hex[3], 16)
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
|
|
302
|
+
if (rgb) {
|
|
303
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
286
306
|
};
|
|
287
307
|
var labelTextColorOn = (background, textColor) => {
|
|
288
|
-
|
|
308
|
+
const rgb = parseColorToRgb(background);
|
|
309
|
+
if (!rgb) return textColor;
|
|
310
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
311
|
+
return luminance >= 0.62 ? "#000000" : textColor;
|
|
289
312
|
};
|
|
290
313
|
var computeSmaSeries = (data, length, source) => {
|
|
291
314
|
const result = new Array(data.length).fill(null);
|