Skip to content

Commit

Permalink
sparkline - yaxis issue fixes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Aug 16, 2018
1 parent 654451b commit 763a86b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 54 deletions.
2 changes: 1 addition & 1 deletion dist/apexcharts.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/apexcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ window.Apex = {}
class ApexCharts {
constructor (el, opts) {
this.opts = opts
this.ctx = this

// Pass the user supplied options to the Base Class where these options will be extended with defaults. The returned object from Base Class will become the config object in the entire codebase.
this.w = new Base(this.opts).init()
this.ctx = this
this.w = new Base(opts).init()

this.el = el
this.core = new Core(el, this.ctx)
this.core = new Core(el, this)

this.w.globals.cuid = (Math.random() + 1).toString(36).substring(4)
this.w.globals.chartID = this.w.config.chart.id ? this.w.config.chart.id : this.w.globals.cuid
Expand Down
4 changes: 0 additions & 4 deletions src/modules/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ class Core {
cnf.chart.zoom.enabled = false
cnf.xaxis.tooltip.enabled = false
cnf.xaxis.axisBorder.show = false
for (const yaxe of cnf.yaxis) {
yaxe.tooltip.enabled = false
yaxe.labels.show = false
}
cnf.chart.scroller.enabled = false
cnf.dataLabels.enabled = false
}
Expand Down
1 change: 0 additions & 1 deletion src/modules/settings/Options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* ApexCharts Options for setting the initial configuration of ApexCharts.
**/
Expand Down
84 changes: 39 additions & 45 deletions src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,45 +71,40 @@ class Utils {
return arrToExtend
}

static addProps(obj, arr, val) {
static addProps (obj, arr, val) {
if (typeof arr === 'string') { arr = arr.split('.') }

if (typeof arr == 'string')
arr = arr.split(".");
obj[arr[0]] = obj[arr[0]] || {}

obj[arr[0]] = obj[arr[0]] || {};

var tmpObj = obj[arr[0]];
var tmpObj = obj[arr[0]]

if (arr.length > 1) {
arr.shift();
this.addProps(tmpObj, arr, val);
}
else
obj[arr[0]] = val;
arr.shift()
this.addProps(tmpObj, arr, val)
} else { obj[arr[0]] = val }

return obj;

}
return obj
}

static clone(source) {
static clone (source) {
if (Object.prototype.toString.call(source) === '[object Array]') {
let cloneResult = [];
for (let i=0; i<source.length; i++) {
cloneResult[i] = this.clone(source[i]);
}
return cloneResult;
} else if (typeof(source)==="object") {
let cloneResult = {};
for (let prop in source) {
if (source.hasOwnProperty(prop)) {
cloneResult[prop] = this.clone(source[prop]);
}
let cloneResult = []
for (let i = 0; i < source.length; i++) {
cloneResult[i] = this.clone(source[i])
}
return cloneResult
} else if (typeof (source) === 'object') {
let cloneResult = {}
for (let prop in source) {
if (source.hasOwnProperty(prop)) {
cloneResult[prop] = this.clone(source[prop])
}
return cloneResult;
}
return cloneResult
} else {
return source;
return source
}
}
}

static getDimensions (el) {
let computedStyle = getComputedStyle(el)
Expand Down Expand Up @@ -159,17 +154,17 @@ class Utils {
}

static rgb2hex (rgb) {
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
}
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i)
return (rgb && rgb.length === 4) ? '#' +
('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) +
('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) +
('0' + parseInt(rgb[3], 10).toString(16)).slice(-2) : ''
}

// beautiful color shading blending code
// http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
shadeColor (p, from, to = undefined) {
if(from[0] !== '#' || from[0] !== 'r') {
if (from[0] !== '#' || from[0] !== 'r') {
from = this.getHexColorFromName(from)
}
if (typeof (p) !== 'number' || p < -1 || p > 1 || typeof (from) !== 'string' || (from[0] !== 'r' && from[0] !== '#') || (typeof (to) !== 'string' && typeof (to) !== 'undefined')) return null // ErrorCheck
Expand Down Expand Up @@ -206,12 +201,12 @@ class Utils {
}

// https://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
getHexColorFromName(colorStr) {
var a = document.createElement('div');
a.style.color = colorStr;
var colors = window.getComputedStyle( document.body.appendChild(a) ).color.match(/\d+/g).map(function(a){ return parseInt(a,10); });
document.body.removeChild(a);
return (colors.length >= 3) ? '#' + (((1 << 24) + (colors[0] << 16) + (colors[1] << 8) + colors[2]).toString(16).substr(1)) : false;
getHexColorFromName (colorStr) {
var a = document.createElement('div')
a.style.color = colorStr
var colors = window.getComputedStyle(document.body.appendChild(a)).color.match(/\d+/g).map(function (a) { return parseInt(a, 10) })
document.body.removeChild(a)
return (colors.length >= 3) ? '#' + (((1 << 24) + (colors[0] << 16) + (colors[1] << 8) + colors[2]).toString(16).substr(1)) : false
}

static polarToCartesian (centerX, centerY, radius, angleInDegrees) {
Expand Down Expand Up @@ -257,11 +252,10 @@ class Utils {
!isNaN(parseInt(value, 10))
}

static isFloat(n){
return Number(n) === n && n % 1 !== 0;
static isFloat (n) {
return Number(n) === n && n % 1 !== 0
}


static isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);

static isIE () {
Expand Down

0 comments on commit 763a86b

Please sign in to comment.