Comparing version 0.40.2 to 0.40.4
{ | ||
"name": "vizabi", | ||
"version": "0.40.2", | ||
"version": "0.40.4", | ||
"description": "Vizabi Framework, Interactive charts and visualization tools animated through time", | ||
@@ -5,0 +5,0 @@ "main": "build/vizabi.js", |
@@ -5,4 +5,3 @@ import interpolator from "vizabi-interpolators/interpolators"; | ||
export const d3json = function(path, callback) { | ||
if (window.fetch && navigator.userAgent.toLowerCase().indexOf(" electron/") === -1) { | ||
// Chrome Canary issue fix: avoid XMLHttpRequest | ||
if (window.fetch) { | ||
// we should use fetch as often as possible | ||
@@ -25,4 +24,3 @@ fetch(path) | ||
export const d3text = function(path, callback) { | ||
if (window.fetch && navigator.userAgent.toLowerCase().indexOf(" electron/") === -1) { | ||
// Chrome Canary issue fix: avoid XMLHttpRequest | ||
if (window.fetch) { | ||
// we should use fetch as often as possible | ||
@@ -1717,10 +1715,1 @@ fetch(path) | ||
}; | ||
export const rgbHex = value => { | ||
const hex = value => { | ||
value = Math.max(0, Math.min(255, Math.round(value) || 0)); | ||
return (value < 16 ? "0" : "") + value.toString(16); | ||
}; | ||
const valueRGB = d3.color(value).rgb(); | ||
return "#" + hex(valueRGB.r) + hex(valueRGB.g) + hex(valueRGB.b); | ||
}; |
@@ -61,3 +61,3 @@ import { isTouchDevice } from "base/utils"; | ||
this._nCellsH = 30; // number of cells by hues (angular) | ||
this._minH = 0; // which hue do we start from: 0 to 1 instead of 0 to 365 | ||
this._minH = 0; // which hue do we start from: 0 to 1 instead of 0 to 360 | ||
this._nCellsL = 8; // number of cells by lightness (radial) | ||
@@ -102,10 +102,10 @@ this._minL = 0.4; // which lightness to start from: 0 to 1. Recommended .3...0.5 | ||
for (let h = 0; h <= _nCellsH; h++) { | ||
const hue = _minH + (1 - _minH) / _nCellsH * h; | ||
const hue = 360 * (_minH + (1 - _minH) / _nCellsH * h); | ||
// new cell | ||
result[l].push({ | ||
fill: this.constructor.hsl2rgb( | ||
fill: d3.hsl( | ||
hue, | ||
h === 0 ? _firstAngleSat : _satConstant, | ||
l === 0 ? _outerL : lightness | ||
), | ||
).hex(), | ||
@@ -521,41 +521,2 @@ stroke: l === 0 ? _colorWhite : _colorBlack | ||
static hsl2rgb(h, s, l) { | ||
let r, g, b; | ||
if (s == 0) { | ||
r = g = b = l; // achromatic | ||
} else { | ||
const q = l < 0.5 ? l * (1 + s) : l + s - l * s; | ||
const p = 2 * l - q; | ||
r = this.hue2rgb(p, q, h + 1 / 3); | ||
g = this.hue2rgb(p, q, h); | ||
b = this.hue2rgb(p, q, h - 1 / 3); | ||
} | ||
const hex = { | ||
r: Math.round(r * 255).toString(16), | ||
g: Math.round(g * 255).toString(16), | ||
b: Math.round(b * 255).toString(16) | ||
}; | ||
if (hex.r.length === 1) hex.r = "0" + hex.r; | ||
if (hex.g.length === 1) hex.g = "0" + hex.g; | ||
if (hex.b.length === 1) hex.b = "0" + hex.b; | ||
return "#" + hex.r + hex.g + hex.b; | ||
} | ||
static hue2rgb(p, q, t) { | ||
if (t < 0) | ||
t += 1; | ||
if (t > 1) | ||
t -= 1; | ||
if (t < 1 / 6) | ||
return p + (q - p) * 6 * t; | ||
if (t < 1 / 2) | ||
return q; | ||
if (t < 2 / 3) | ||
return p + (q - p) * (2 / 3 - t) * 6; | ||
return p; | ||
} | ||
static px2num(px) { | ||
@@ -562,0 +523,0 @@ return parseFloat(px) || 0; |
@@ -11,7 +11,7 @@ import * as utils from "base/utils"; | ||
"_default": "#ffb600", | ||
"0": "hsl(270, 80%, 55%)", | ||
"25": "hsl(202.5, 80%, 55%)", | ||
"50": "hsl(135, 80%, 55%)", | ||
"75": "hsl(48, 70%, 62%)", | ||
"100": "hsl(0, 80%, 55%)" | ||
"0": "#8c30e8", //"hsl(270, 80%, 55%)", | ||
"25": "#30a3e8", //"hsl(202.5, 80%, 55%)", | ||
"50": "#30e85e", //"hsl(135, 80%, 55%)", | ||
"75": "#e2c75a", //"hsl(48, 70%, 62%)", | ||
"100": "#e83030" //"hsl(0, 80%, 55%)" | ||
}, | ||
@@ -84,3 +84,3 @@ "_discrete": { | ||
Object.keys(defaultPalette).forEach(key => { | ||
if (!paletteHiddenKeys.includes(key) && (!currentPalette[key] || utils.rgbHex(defaultPalette[key]) == utils.rgbHex(currentPalette[key]))) palette[key] = defaultPalette[key]; | ||
if (!paletteHiddenKeys.includes(key) && (!currentPalette[key] || defaultPalette[key] == d3.color(currentPalette[key]).hex())) palette[key] = defaultPalette[key]; | ||
}); | ||
@@ -136,3 +136,3 @@ _this.set("palette", palette, false, false); | ||
setColor(value, pointer, oldPointer, persistent, force = false) { | ||
if (value) value = utils.rgbHex(value); | ||
if (value) value = d3.color(value).hex(); | ||
@@ -184,3 +184,3 @@ let range; | ||
if (paletteObj[pointer] && defaultPalette[pointer] && paletteObj[pointer] === utils.rgbHex(defaultPalette[pointer])) { | ||
if (paletteObj[pointer] && defaultPalette[pointer] && paletteObj[pointer] === defaultPalette[pointer]) { | ||
persistent = false; | ||
@@ -187,0 +187,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7820583
58109