diff --git a/dist/frappe-charts.esm.js b/dist/frappe-charts.esm.js deleted file mode 100644 index a5e67b6..0000000 --- a/dist/frappe-charts.esm.js +++ /dev/null @@ -1,4072 +0,0 @@ -function $(expr, con) { - return typeof expr === "string"? (con || document).querySelector(expr) : expr || null; -} - - - -$.create = (tag, o) => { - var element = document.createElement(tag); - - for (var i in o) { - var val = o[i]; - - if (i === "inside") { - $(val).appendChild(element); - } - else if (i === "around") { - var ref = $(val); - ref.parentNode.insertBefore(element, ref); - element.appendChild(ref); - - } else if (i === "styles") { - if(typeof val === "object") { - Object.keys(val).map(prop => { - element.style[prop] = val[prop]; - }); - } - } else if (i in element ) { - element[i] = val; - } - else { - element.setAttribute(i, val); - } - } - - return element; -}; - -function getOffset(element) { - let rect = element.getBoundingClientRect(); - return { - // https://stackoverflow.com/a/7436602/6495043 - // rect.top varies with scroll, so we add whatever has been - // scrolled to it to get absolute distance from actual page top - top: rect.top + (document.documentElement.scrollTop || document.body.scrollTop), - left: rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft) - }; -} - -// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent -// an element's offsetParent property will return null whenever it, or any of its parents, -// is hidden via the display style property. -function isHidden(el) { - return (el.offsetParent === null); -} - -function isElementInViewport(el) { - // Although straightforward: https://stackoverflow.com/a/7557433/6495043 - var rect = el.getBoundingClientRect(); - - return ( - rect.top >= 0 && - rect.left >= 0 && - rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ - rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ - ); -} - -function getElementContentWidth(element) { - var styles = window.getComputedStyle(element); - var padding = parseFloat(styles.paddingLeft) + - parseFloat(styles.paddingRight); - - return element.clientWidth - padding; -} - - - - - -function fire(target, type, properties) { - var evt = document.createEvent("HTMLEvents"); - - evt.initEvent(type, true, true ); - - for (var j in properties) { - evt[j] = properties[j]; - } - - return target.dispatchEvent(evt); -} - -// https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/ - -const BASE_MEASURES = { - margins: { - top: 10, - bottom: 10, - left: 20, - right: 20 - }, - paddings: { - top: 20, - bottom: 40, - left: 30, - right: 10 - }, - - baseHeight: 240, - titleHeight: 20, - legendHeight: 30, - - titleFontSize: 12, -}; - -function getTopOffset(m) { - return m.titleHeight + m.margins.top + m.paddings.top; -} - -function getLeftOffset(m) { - return m.margins.left + m.paddings.left; -} - -function getExtraHeight(m) { - let totalExtraHeight = m.margins.top + m.margins.bottom - + m.paddings.top + m.paddings.bottom - + m.titleHeight + m.legendHeight; - return totalExtraHeight; -} - -function getExtraWidth(m) { - let totalExtraWidth = m.margins.left + m.margins.right - + m.paddings.left + m.paddings.right; - - return totalExtraWidth; -} - -const INIT_CHART_UPDATE_TIMEOUT = 700; -const CHART_POST_ANIMATE_TIMEOUT = 400; - -const DEFAULT_AXIS_CHART_TYPE = 'line'; -const AXIS_DATASET_CHART_TYPES = ['line', 'bar']; - -const AXIS_LEGEND_BAR_SIZE = 100; - -const BAR_CHART_SPACE_RATIO = 0.5; -const MIN_BAR_PERCENT_HEIGHT = 0.00; - -const LINE_CHART_DOT_SIZE = 4; -const DOT_OVERLAY_SIZE_INCR = 4; - -const PERCENTAGE_BAR_DEFAULT_HEIGHT = 20; -const PERCENTAGE_BAR_DEFAULT_DEPTH = 2; - -// Fixed 5-color theme, -// More colors are difficult to parse visually -const HEATMAP_DISTRIBUTION_SIZE = 5; - -const HEATMAP_SQUARE_SIZE = 10; -const HEATMAP_GUTTER_SIZE = 2; - -const DEFAULT_CHAR_WIDTH = 7; - -const TOOLTIP_POINTER_TRIANGLE_HEIGHT = 5; - -const DEFAULT_CHART_COLORS = ['light-blue', 'blue', 'violet', 'red', 'orange', - 'yellow', 'green', 'light-green', 'purple', 'magenta', 'light-grey', 'dark-grey']; -const HEATMAP_COLORS_GREEN = ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127']; - - - -const DEFAULT_COLORS = { - bar: DEFAULT_CHART_COLORS, - line: DEFAULT_CHART_COLORS, - pie: DEFAULT_CHART_COLORS, - percentage: DEFAULT_CHART_COLORS, - heatmap: HEATMAP_COLORS_GREEN, - donut: DEFAULT_CHART_COLORS -}; - -// Universal constants -const ANGLE_RATIO = Math.PI / 180; -const FULL_ANGLE = 360; - -class SvgTip { - constructor({ - parent = null, - colors = [] - }) { - this.parent = parent; - this.colors = colors; - this.titleName = ''; - this.titleValue = ''; - this.listValues = []; - this.titleValueFirst = 0; - - this.x = 0; - this.y = 0; - - this.top = 0; - this.left = 0; - - this.setup(); - } - - setup() { - this.makeTooltip(); - } - - refresh() { - this.fill(); - this.calcPosition(); - } - - makeTooltip() { - this.container = $.create('div', { - inside: this.parent, - className: 'graph-svg-tip comparison', - innerHTML: ` -