chore: bump to 1.5.2 🎉

This commit is contained in:
Shivam Mishra 2020-07-08 21:20:37 +05:30
parent 222cbb686f
commit 2572e317c7
13 changed files with 42 additions and 11 deletions

View File

@ -364,6 +364,19 @@ function getPositionByAngle(angle, radius) {
};
}
/**
* Check if a number is valid for svg attributes
* @param {object} candidate Candidate to test
* @param {Boolean} nonNegative flag to treat negative number as invalid
*/
function isValidNumber(candidate, nonNegative=false) {
if (Number.isNaN(candidate)) return false;
else if (candidate === undefined) return false;
else if (!Number.isFinite(candidate)) return false;
else if (nonNegative && candidate < 0) return false;
else return true;
}
function getBarHeightAndYAttr(yTop, zeroLine) {
let height, y;
if (yTop <= zeroLine) {
@ -864,6 +877,8 @@ function makeHoriLine(y, label, x1, x2, options={}) {
}
function yLine(y, label, width, options={}) {
if (!isValidNumber(y)) y = 0;
if(!options.pos) options.pos = 'left';
if(!options.offset) options.offset = 0;
if(!options.mode) options.mode = 'span';
@ -892,6 +907,8 @@ function yLine(y, label, width, options={}) {
}
function xLine(x, label, height, options={}) {
if (!isValidNumber(x)) x = 0;
if(!options.pos) options.pos = 'bottom';
if(!options.offset) options.offset = 0;
if(!options.mode) options.mode = 'span';
@ -1002,6 +1019,12 @@ function datasetBar(x, yTop, width, color, label='', index=0, offset=0, meta={})
y -= meta.minHeight;
}
// Preprocess numbers to avoid svg building errors
if (!isValidNumber(x)) x = 0;
if (!isValidNumber(y)) y = 0;
if (!isValidNumber(height, true)) height = 0;
if (!isValidNumber(width, true)) width = 0;
let rect = createSVG('rect', {
className: `bar mini`,
style: `fill: ${color}`,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -79,6 +79,14 @@ function getRandomBias(min, max, bias, influence) {
return rnd * (1 - mix) + biasValue * mix; // mix full range and bias
}
/**
* Check if a number is valid for svg attributes
* @param {object} candidate Candidate to test
* @param {Boolean} nonNegative flag to treat negative number as invalid
*/
// Playing around with dates

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "frappe-charts",
"version": "1.5.1",
"version": "1.5.2",
"description": "https://frappe.github.io/charts",
"main": "dist/frappe-charts.min.cjs.js",
"module": "dist/frappe-charts.min.esm.js",

View File

@ -3,7 +3,7 @@ import * as Charts from './chart';
let frappe = { };
frappe.NAME = 'Frappe Charts';
frappe.VERSION = '1.5.1';
frappe.VERSION = '1.5.2';
frappe = Object.assign({ }, frappe, Charts);