frappe-charts
Advanced tools
Comparing version 2.0.0-rc5 to 2.0.0-rc6
{ | ||
"name": "frappe-charts", | ||
"version": "2.0.0-rc5", | ||
"version": "2.0.0-rc6", | ||
"main": "src/js/chart.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/frappe-charts.esm.js", |
@@ -12,5 +12,7 @@ import SvgTip from '../objects/SvgTip'; | ||
import { downloadFile, prepareForExport } from '../utils/export'; | ||
import { deepClone } from '../utils/helpers'; | ||
export default class BaseChart { | ||
constructor(parent, options) { | ||
options = deepClone(options) | ||
@@ -17,0 +19,0 @@ this.parent = typeof parent === 'string' |
@@ -17,6 +17,6 @@ import { ANGLE_RATIO } from './constants'; | ||
export function arraysEqual(arr1, arr2) { | ||
if (arr1.length !== arr2.length) return false; | ||
if(arr1.length !== arr2.length) return false; | ||
let areEqual = true; | ||
arr1.map((d, i) => { | ||
if (arr2[i] !== d) areEqual = false; | ||
if(arr2[i] !== d) areEqual = false; | ||
}); | ||
@@ -50,4 +50,4 @@ return areEqual; | ||
*/ | ||
export function fillArray(array, count, element, start = false) { | ||
if (!element) { | ||
export function fillArray(array, count, element, start=false) { | ||
if(!element) { | ||
element = start ? array[0] : array[array.length - 1]; | ||
@@ -66,3 +66,3 @@ } | ||
export function getStringWidth(string, charWidth) { | ||
return (string + "").length * charWidth; | ||
return (string+"").length * charWidth; | ||
} | ||
@@ -72,7 +72,7 @@ | ||
return new Proxy(obj, { | ||
set: function (target, prop, value) { | ||
set: function(target, prop, value) { | ||
setFn(); | ||
return Reflect.set(target, prop, value); | ||
}, | ||
get: function (target, prop) { | ||
get: function(target, prop) { | ||
getFn(); | ||
@@ -105,3 +105,3 @@ return Reflect.get(target, prop); | ||
*/ | ||
export function isValidNumber(candidate, nonNegative = false) { | ||
export function isValidNumber(candidate, nonNegative=false) { | ||
if (Number.isNaN(candidate)) return false; | ||
@@ -122,2 +122,28 @@ else if (candidate === undefined) return false; | ||
return Number(Math.round(d + 'e4') + 'e-4'); | ||
} | ||
} | ||
/** | ||
* Creates a deep clone of an object | ||
* @param {Object} candidate Any Object | ||
*/ | ||
export function deepClone(candidate) { | ||
let cloned, value, key; | ||
if (candidate instanceof Date) { | ||
return new Date(candidate.getTime()); | ||
} | ||
if (typeof candidate !== "object" || candidate === null) { | ||
return candidate; | ||
} | ||
cloned = Array.isArray(candidate) ? [] : {}; | ||
for (key in candidate) { | ||
value = candidate[key]; | ||
cloned[key] = deepClone(value); | ||
} | ||
return cloned; | ||
} |
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 too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
899889
4494
0