diff --git a/system/modules/admin/templates/migration/layout-pretext.tpl.php b/system/modules/admin/templates/migration/layout-pretext.tpl.php index c3955d43..c7cc5a8b 100644 --- a/system/modules/admin/templates/migration/layout-pretext.tpl.php +++ b/system/modules/admin/templates/migration/layout-pretext.tpl.php @@ -34,7 +34,6 @@ $w->enqueueScript(array("name" => "livevalidation.js", "uri" => "/system/templates/js/livevalidation.js", "weight" => 940)); $w->enqueueScript(array("name" => "main.js", "uri" => "/system/templates/js/main.js", "weight" => 995)); $w->enqueueScript(array("name" => "jquery.asmselect.js", "uri" => "/system/templates/js/jquery.asmselect.js", "weight" => 920)); - $w->enqueueScript(array("name" => "boxover.js", "uri" => "/system/templates/js/boxover.js", "weight" => 910)); $w->enqueueScript(array("name" => "ckeditor.js", "uri" => "/system/templates/js/ckeditor/ckeditor.js", "weight" => 900)); $w->enqueueScript(array("name" => "Chart.js", "uri" => "/system/templates/js/chart-js/dist/Chart.min.js", "weight" => 890)); diff --git a/system/modules/task/templates/edit.tpl.php b/system/modules/task/templates/edit.tpl.php index 8bf103a3..c7fdf876 100644 --- a/system/modules/task/templates/edit.tpl.php +++ b/system/modules/task/templates/edit.tpl.php @@ -187,7 +187,7 @@ function(result) { $('#task_type').val(''); $('#priority').parent().html(result[1]); $('#assignee_id').parent().html(result[2]); - $('#status').html(result[4]) + $('#status').parent().html(result[4]) } $('#tasktext').html(result[3]); $("#tasktext").fadeIn(); diff --git a/system/templates/js/boxover.js b/system/templates/js/boxover.js deleted file mode 100755 index b9cb869a..00000000 --- a/system/templates/js/boxover.js +++ /dev/null @@ -1,372 +0,0 @@ -/* --- BoxOver --- -/* --- v 2.1 17th June 2006 -By Oliver Bryant with help of Matthew Tagg -http://boxover.swazz.org */ - -if (typeof document.attachEvent!='undefined') { - window.attachEvent('onload',init); - document.attachEvent('onmousemove',moveMouse); - document.attachEvent('onclick',checkMove); } -else { - window.addEventListener('load',init,false); - document.addEventListener('mousemove',moveMouse,false); - document.addEventListener('click',checkMove,false); -} - -var oDv=document.createElement("div"); -var dvHdr=document.createElement("div"); -var dvBdy=document.createElement("div"); -var windowlock,boxMove,fixposx,fixposy,lockX,lockY,fixx,fixy,ox,oy,boxLeft,boxRight,boxTop,boxBottom,evt,mouseX,mouseY,boxOpen,totalScrollTop,totalScrollLeft; -boxOpen=false; -ox=10; -oy=10; -lockX=0; -lockY=0; - -function init() { - oDv.appendChild(dvHdr); - oDv.appendChild(dvBdy); - oDv.style.position="absolute"; - oDv.style.visibility='hidden'; - document.body.appendChild(oDv); -} - -function defHdrStyle() { - dvHdr.innerHTML='  '+dvHdr.innerHTML; - dvHdr.style.fontWeight='bold'; - dvHdr.style.width='150px'; - dvHdr.style.fontFamily='arial'; - dvHdr.style.border='1px solid #A5CFE9'; - dvHdr.style.padding='3'; - dvHdr.style.fontSize='11'; - dvHdr.style.color='#4B7A98'; - dvHdr.style.background='#D5EBF9'; - dvHdr.style.filter='alpha(opacity=85)'; // IE - dvHdr.style.opacity='0.85'; // FF -} - -function defBdyStyle() { - dvBdy.style.borderBottom='1px solid #A5CFE9'; - dvBdy.style.borderLeft='1px solid #A5CFE9'; - dvBdy.style.borderRight='1px solid #A5CFE9'; - dvBdy.style.width='150px'; - dvBdy.style.fontFamily='arial'; - dvBdy.style.fontSize='11'; - dvBdy.style.padding='3'; - dvBdy.style.color='#1B4966'; - dvBdy.style.background='#FFFFFF'; - dvBdy.style.filter='alpha(opacity=85)'; // IE - dvBdy.style.opacity='0.85'; // FF -} - -function checkElemBO(txt) { -if (!txt || typeof(txt) != 'string') return false; -if ((txt.indexOf('header')>-1)&&(txt.indexOf('body')>-1)&&(txt.indexOf('[')>-1)&&(txt.indexOf('[')>-1)) - return true; -else - return false; -} - -function scanBO(curNode) { - if (checkElemBO(curNode.title)) { - curNode.boHDR=getParam('header',curNode.title); - curNode.boBDY=getParam('body',curNode.title); - curNode.boCSSBDY=getParam('cssbody',curNode.title); - curNode.boCSSHDR=getParam('cssheader',curNode.title); - curNode.IEbugfix=(getParam('hideselects',curNode.title)=='on')?true:false; - curNode.fixX=parseInt(getParam('fixedrelx',curNode.title)); - curNode.fixY=parseInt(getParam('fixedrely',curNode.title)); - curNode.absX=parseInt(getParam('fixedabsx',curNode.title)); - curNode.absY=parseInt(getParam('fixedabsy',curNode.title)); - curNode.offY=(getParam('offsety',curNode.title)!='')?parseInt(getParam('offsety',curNode.title)):10; - curNode.offX=(getParam('offsetx',curNode.title)!='')?parseInt(getParam('offsetx',curNode.title)):10; - curNode.fade=(getParam('fade',curNode.title)=='on')?true:false; - curNode.fadespeed=(getParam('fadespeed',curNode.title)!='')?getParam('fadespeed',curNode.title):0.04; - curNode.delay=(getParam('delay',curNode.title)!='')?parseInt(getParam('delay',curNode.title)):0; - if (getParam('requireclick',curNode.title)=='on') { - curNode.requireclick=true; - document.all?curNode.attachEvent('onclick',showHideBox):curNode.addEventListener('click',showHideBox,false); - document.all?curNode.attachEvent('onmouseover',hideBox):curNode.addEventListener('mouseover',hideBox,false); - } - else {// Note : if requireclick is on the stop clicks are ignored - if (getParam('doubleclickstop',curNode.title)!='off') { - document.all?curNode.attachEvent('ondblclick',pauseBox):curNode.addEventListener('dblclick',pauseBox,false); - } - if (getParam('singleclickstop',curNode.title)=='on') { - document.all?curNode.attachEvent('onclick',pauseBox):curNode.addEventListener('click',pauseBox,false); - } - } - curNode.windowLock=getParam('windowlock',curNode.title).toLowerCase()=='off'?false:true; - curNode.title=''; - curNode.hasbox=1; - } - else - curNode.hasbox=2; -} - - -function getParam(param,list) { - var reg = new RegExp('([^a-zA-Z]' + param + '|^' + param + ')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]'); - var res = reg.exec(list); - var returnvar; - if(res) - return res[2].replace('[[','[').replace(']]',']'); - else - return ''; -} - -function Left(elem){ - var x=0; - if (elem.calcLeft) - return elem.calcLeft; - var oElem=elem; - while(elem){ - if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderLeftWidth)))&&(x!=0)) - x+=parseInt(elem.currentStyle.borderLeftWidth); - x+=elem.offsetLeft; - elem=elem.offsetParent; - } - oElem.calcLeft=x; - return x; - } - -function Top(elem){ - var x=0; - if (elem.calcTop) - return elem.calcTop; - var oElem=elem; - while(elem){ - if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderTopWidth)))&&(x!=0)) - x+=parseInt(elem.currentStyle.borderTopWidth); - x+=elem.offsetTop; - elem=elem.offsetParent; - } - oElem.calcTop=x; - return x; - -} - -var ah,ab; -function applyStyles() { - if(ab) - oDv.removeChild(dvBdy); - if (ah) - oDv.removeChild(dvHdr); - dvHdr=document.createElement("div"); - dvBdy=document.createElement("div"); - CBE.boCSSBDY?dvBdy.className=CBE.boCSSBDY:defBdyStyle(); - CBE.boCSSHDR?dvHdr.className=CBE.boCSSHDR:defHdrStyle(); - dvHdr.innerHTML=CBE.boHDR; - dvBdy.innerHTML=CBE.boBDY; - ah=false; - ab=false; - if (CBE.boHDR!='') { - oDv.appendChild(dvHdr); - ah=true; - } - if (CBE.boBDY!=''){ - oDv.appendChild(dvBdy); - ab=true; - } -} - -var CSE,iterElem,LSE,CBE,LBE, totalScrollLeft, totalScrollTop, width, height ; -var ini=false; - -// Customised function for inner window dimension -function SHW() { - if (document.body && (document.body.clientWidth !=0)) { - width=document.body.clientWidth; - height=document.body.clientHeight; - } - if (document.documentElement && (document.documentElement.clientWidth!=0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) { - width=document.documentElement.clientWidth; - height=document.documentElement.clientHeight; - } - return [width,height]; -} - - -var ID=null; -function moveMouse(e) { - //boxMove=true; - e?evt=e:evt=event; - - CSE=evt.target?evt.target:evt.srcElement; - - if (!CSE.hasbox) { - // Note we need to scan up DOM here, some elements like TR don't get triggered as srcElement - iElem=CSE; - while ((iElem.parentNode) && (!iElem.hasbox)) { - scanBO(iElem); - iElem=iElem.parentNode; - } - } - - if ((CSE!=LSE)&&(!isChild(CSE,dvHdr))&&(!isChild(CSE,dvBdy))){ - if (!CSE.boxItem) { - iterElem=CSE; - while ((iterElem.hasbox==2)&&(iterElem.parentNode)) - iterElem=iterElem.parentNode; - CSE.boxItem=iterElem; - } - iterElem=CSE.boxItem; - if (CSE.boxItem&&(CSE.boxItem.hasbox==1)) { - LBE=CBE; - CBE=iterElem; - if (CBE!=LBE) { - applyStyles(); - if (!CBE.requireclick) - if (CBE.fade) { - if (ID!=null) - clearTimeout(ID); - ID=setTimeout("fadeIn("+CBE.fadespeed+")",CBE.delay); - } - else { - if (ID!=null) - clearTimeout(ID); - COL=1; - ID=setTimeout("oDv.style.visibility='visible';ID=null;",CBE.delay); - } - if (CBE.IEbugfix) {hideSelects();} - fixposx=!isNaN(CBE.fixX)?Left(CBE)+CBE.fixX:CBE.absX; - fixposy=!isNaN(CBE.fixY)?Top(CBE)+CBE.fixY:CBE.absY; - lockX=0; - lockY=0; - boxMove=true; - ox=CBE.offX?CBE.offX:10; - oy=CBE.offY?CBE.offY:10; - } - } - else if (!isChild(CSE,dvHdr) && !isChild(CSE,dvBdy) && (boxMove)) { - // The conditional here fixes flickering between tables cells. - if ((!isChild(CBE,CSE)) || (CSE.tagName!='TABLE')) { - CBE=null; - if (ID!=null) - clearTimeout(ID); - fadeOut(); - showSelects(); - } - } - LSE=CSE; - } - else if (((isChild(CSE,dvHdr) || isChild(CSE,dvBdy))&&(boxMove))) { - totalScrollLeft=0; - totalScrollTop=0; - - iterElem=CSE; - while(iterElem) { - if(!isNaN(parseInt(iterElem.scrollTop))) - totalScrollTop+=parseInt(iterElem.scrollTop); - if(!isNaN(parseInt(iterElem.scrollLeft))) - totalScrollLeft+=parseInt(iterElem.scrollLeft); - iterElem=iterElem.parentNode; - } - if (CBE!=null) { - boxLeft=Left(CBE)-totalScrollLeft; - boxRight=parseInt(Left(CBE)+CBE.offsetWidth)-totalScrollLeft; - boxTop=Top(CBE)-totalScrollTop; - boxBottom=parseInt(Top(CBE)+CBE.offsetHeight)-totalScrollTop; - doCheck(); - } - } - - if (boxMove&&CBE) { - // This added to alleviate bug in IE6 w.r.t DOCTYPE - bodyScrollTop=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop; - bodyScrollLet=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft; - mouseX=evt.pageX?evt.pageX-bodyScrollLet:evt.clientX-document.body.clientLeft; - mouseY=evt.pageY?evt.pageY-bodyScrollTop:evt.clientY-document.body.clientTop; - if ((CBE)&&(CBE.windowLock)) { - mouseY < -oy?lockY=-mouseY-oy:lockY=0; - mouseX < -ox?lockX=-mouseX-ox:lockX=0; - mouseY > (SHW()[1]-oDv.offsetHeight-oy)?lockY=-mouseY+SHW()[1]-oDv.offsetHeight-oy:lockY=lockY; - mouseX > (SHW()[0]-dvBdy.offsetWidth-ox)?lockX=-mouseX-ox+SHW()[0]-dvBdy.offsetWidth:lockX=lockX; - } - oDv.style.left=((fixposx)||(fixposx==0))?fixposx:bodyScrollLet+mouseX+ox+lockX+"px"; - oDv.style.top=((fixposy)||(fixposy==0))?fixposy:bodyScrollTop+mouseY+oy+lockY+"px"; - - } -} - -function doCheck() { - if ( (mouseX < boxLeft) || (mouseX >boxRight) || (mouseY < boxTop) || (mouseY > boxBottom)) { - if (!CBE.requireclick) - fadeOut(); - if (CBE.IEbugfix) {showSelects();} - CBE=null; - } -} - -function pauseBox(e) { - e?evt=e:evt=event; - boxMove=false; - evt.cancelBubble=true; -} - -function showHideBox(e) { - oDv.style.visibility=(oDv.style.visibility!='visible')?'visible':'hidden'; -} - -function hideBox(e) { - oDv.style.visibility='hidden'; -} - -var COL=0; -var stopfade=false; -function fadeIn(fs) { - ID=null; - COL=0; - oDv.style.visibility='visible'; - fadeIn2(fs); -} - -function fadeIn2(fs) { - COL=COL+fs; - COL=(COL>1)?1:COL; - oDv.style.filter='alpha(opacity='+parseInt(100*COL)+')'; - oDv.style.opacity=COL; - if (COL<1) - setTimeout("fadeIn2("+fs+")",20); -} - - -function fadeOut() { - oDv.style.visibility='hidden'; - -} - -function isChild(s,d) { - while(s) { - if (s==d) - return true; - s=s.parentNode; - } - return false; -} - -var cSrc; -function checkMove(e) { - e?evt=e:evt=event; - cSrc=evt.target?evt.target:evt.srcElement; - if ((!boxMove)&&(!isChild(cSrc,oDv))) { - fadeOut(); - if (CBE&&CBE.IEbugfix) {showSelects();} - boxMove=true; - CBE=null; - } -} - -function showSelects(){ - var elements = document.getElementsByTagName("select"); - for (i=0;i< elements.length;i++){ - elements[i].style.visibility='visible'; - } -} - -function hideSelects(){ - var elements = document.getElementsByTagName("select"); - for (i=0;i< elements.length;i++){ - elements[i].style.visibility='hidden'; - } -} \ No newline at end of file diff --git a/system/templates/js/chart-js/.codeclimate.yml b/system/templates/js/chart-js/.codeclimate.yml deleted file mode 100644 index ee3a5fda..00000000 --- a/system/templates/js/chart-js/.codeclimate.yml +++ /dev/null @@ -1,19 +0,0 @@ -engines: - duplication: - enabled: true - config: - languages: - - javascript - eslint: - enabled: true - channel: "eslint-3" - fixme: - enabled: true -ratings: - paths: - - "src/**/*.js" -exclude_paths: -- dist/**/* -- node_modules/**/* -- test/**/* -- coverage/**/* diff --git a/system/templates/js/chart-js/.editorconfig b/system/templates/js/chart-js/.editorconfig deleted file mode 100644 index 4e0d877e..00000000 --- a/system/templates/js/chart-js/.editorconfig +++ /dev/null @@ -1,10 +0,0 @@ -# http://editorconfig.org -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = false diff --git a/system/templates/js/chart-js/.eslintignore b/system/templates/js/chart-js/.eslintignore deleted file mode 100644 index 96212a35..00000000 --- a/system/templates/js/chart-js/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/*{.,-}min.js diff --git a/system/templates/js/chart-js/.eslintrc b/system/templates/js/chart-js/.eslintrc deleted file mode 100644 index 7acbf600..00000000 --- a/system/templates/js/chart-js/.eslintrc +++ /dev/null @@ -1,224 +0,0 @@ -ecmaFeatures: - modules: true - jsx: true - -env: - amd: true - browser: true - es6: true - jquery: true - node: true - -# http://eslint.org/docs/rules/ -rules: - # Possible Errors - no-cond-assign: 2 - no-console: [2, {allow: [warn, error]}] - no-constant-condition: 2 - no-control-regex: 2 - no-debugger: 2 - no-dupe-args: 2 - no-dupe-keys: 2 - no-duplicate-case: 2 - no-empty: 2 - no-empty-character-class: 2 - no-ex-assign: 2 - no-extra-boolean-cast: 2 - no-extra-parens: [2, functions] - no-extra-semi: 2 - no-func-assign: 2 - no-inner-declarations: [2, functions] - no-invalid-regexp: 2 - no-irregular-whitespace: 2 - no-negated-in-lhs: 2 - no-obj-calls: 2 - no-regex-spaces: 2 - no-sparse-arrays: 2 - no-unexpected-multiline: 2 - no-unreachable: 2 - use-isnan: 2 - valid-jsdoc: 0 - valid-typeof: 2 - - # Best Practices - accessor-pairs: 2 - array-callback-return: 0 - block-scoped-var: 0 - complexity: [2, 6] - consistent-return: 0 - curly: [2, all] - default-case: 2 - dot-location: 0 - dot-notation: 2 - eqeqeq: 2 - guard-for-in: 2 - no-alert: 2 - no-caller: 2 - no-case-declarations: 2 - no-div-regex: 2 - no-else-return: 2 - no-empty-pattern: 2 - no-eq-null: 2 - no-eval: 2 - no-extend-native: 2 - no-extra-bind: 2 - no-fallthrough: 2 - no-floating-decimal: 2 - no-implicit-coercion: 0 - no-implied-eval: 2 - no-invalid-this: 0 - no-iterator: 2 - no-labels: 2 - no-lone-blocks: 2 - no-loop-func: 2 - no-magic-number: 0 - no-multi-spaces: 2 - no-multi-str: 2 - no-native-reassign: 2 - no-new-func: 2 - no-new-wrappers: 2 - no-new: 2 - no-octal-escape: 2 - no-octal: 2 - no-proto: 2 - no-redeclare: 2 - no-return-assign: 2 - no-script-url: 2 - no-self-compare: 2 - no-sequences: 2 - no-throw-literal: 0 - no-unused-expressions: 2 - no-useless-call: 2 - no-useless-concat: 2 - no-void: 2 - no-warning-comments: 0 - no-with: 2 - radix: 2 - vars-on-top: 0 - wrap-iife: 2 - yoda: [1, never] - - # Strict - strict: 0 - - # Variables - init-declarations: 0 - no-catch-shadow: 2 - no-delete-var: 2 - no-label-var: 2 - no-shadow-restricted-names: 2 - no-shadow: 2 - no-undef-init: 2 - no-undef: 2 - no-undefined: 0 - no-unused-vars: 2 - no-use-before-define: 2 - - # Node.js and CommonJS - callback-return: 2 - global-require: 2 - handle-callback-err: 2 - no-mixed-requires: 0 - no-new-require: 0 - no-path-concat: 2 - no-process-exit: 2 - no-restricted-modules: 0 - no-sync: 0 - - # Stylistic Issues - array-bracket-spacing: [2, never] - block-spacing: 0 - brace-style: [2, 1tbs] - camelcase: 2 - comma-dangle: [2, only-multiline] - comma-spacing: 2 - comma-style: [2, last] - computed-property-spacing: [2, never] - consistent-this: [2, me] - eol-last: 2 - func-call-spacing: 0 - func-names: [2, never] - func-style: 0 - id-length: 0 - id-match: 0 - indent: [2, tab] - jsx-quotes: 0 - key-spacing: 2 - keyword-spacing: 2 - linebreak-style: 0 - lines-around-comment: 0 - max-depth: 0 - max-len: 0 - max-lines: 0 - max-nested-callbacks: 0 - max-params: 0 - max-statements-per-line: 0 - max-statements: [2, 30] - multiline-ternary: 0 - new-cap: 0 - new-parens: 2 - newline-after-var: 0 - newline-before-return: 0 - newline-per-chained-call: 0 - no-array-constructor: 0 - no-bitwise: 0 - no-continue: 0 - no-inline-comments: 0 - no-lonely-if: 2 - no-mixed-operators: 0 - no-mixed-spaces-and-tabs: 2 - no-multiple-empty-lines: [2, {max: 2}] - no-negated-condition: 0 - no-nested-ternary: 0 - no-new-object: 0 - no-plusplus: 0 - no-restricted-syntax: 0 - no-spaced-func: 0 - no-ternary: 0 - no-trailing-spaces: 2 - no-underscore-dangle: 0 - no-unneeded-ternary: 0 - no-whitespace-before-property: 2 - object-curly-newline: 0 - object-curly-spacing: [2, never] - object-property-newline: 0 - one-var-declaration-per-line: 2 - one-var: 0 - operator-assignment: 0 - operator-linebreak: 0 - padded-blocks: 0 - quote-props: [2, as-needed] - quotes: [2, single, {avoidEscape: true}] - require-jsdoc: 0 - semi-spacing: 2 - semi: [2, always] - sort-keys: 0 - sort-vars: 0 - space-before-blocks: [2, always] - space-before-function-paren: [2, never] - space-in-parens: [2, never] - space-infix-ops: 0 - space-unary-ops: 0 - spaced-comment: [2, always] - unicode-bom: 0 - wrap-regex: 2 - - # ECMAScript 6 - arrow-body-style: 0 - arrow-parens: 0 - arrow-spacing: 0 - constructor-super: 0 - generator-star-spacing: 0 - no-arrow-condition: 0 - no-class-assign: 0 - no-const-assign: 0 - no-dupe-class-members: 0 - no-this-before-super: 0 - no-var: 0 - object-shorthand: 0 - prefer-arrow-callback: 0 - prefer-const: 0 - prefer-reflect: 0 - prefer-spread: 0 - prefer-template: 0 - require-yield: 0 diff --git a/system/templates/js/chart-js/.github/ISSUE_TEMPLATE.md b/system/templates/js/chart-js/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 7d57bbd0..00000000 --- a/system/templates/js/chart-js/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,40 +0,0 @@ - - - - -## Expected Behavior - - - -## Current Behavior - - - -## Possible Solution - - - -## Steps to Reproduce (for bugs) - - -1. -2. -3. -4. - -## Context - - - -## Environment - -* Chart.js version: -* Browser name and version: -* Link to your project: diff --git a/system/templates/js/chart-js/.github/PULL_REQUEST_TEMPLATE.md b/system/templates/js/chart-js/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b57d497e..00000000 --- a/system/templates/js/chart-js/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,9 +0,0 @@ -Please consider the following before submitting a pull request: - -Guidelines for contributing: https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md - -Example of changes on an interactive website such as the following: -- http://jsbin.com/ -- http://jsfiddle.net/ -- http://codepen.io/pen/ -- Premade template: http://codepen.io/pen?template=JXVYzq \ No newline at end of file diff --git a/system/templates/js/chart-js/.gitignore b/system/templates/js/chart-js/.gitignore deleted file mode 100644 index 17241343..00000000 --- a/system/templates/js/chart-js/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/coverage -/custom -/dist -/docs/index.md -/node_modules - -.DS_Store -.idea -.vscode -bower.json - -*.swp diff --git a/system/templates/js/chart-js/.npmignore b/system/templates/js/chart-js/.npmignore deleted file mode 100644 index 47b4948e..00000000 --- a/system/templates/js/chart-js/.npmignore +++ /dev/null @@ -1,13 +0,0 @@ -/.git -/.github -/coverage -/custom -/dist/*.zip -/docs/index.md -/node_modules - -.codeclimate.yml -.DS_Store -.gitignore -.idea -.travis.yml diff --git a/system/templates/js/chart-js/.travis.yml b/system/templates/js/chart-js/.travis.yml deleted file mode 100644 index 2df4a4cd..00000000 --- a/system/templates/js/chart-js/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -language: node_js -node_js: - - "5.10" - -before_install: - - "export CHROME_BIN=/usr/bin/google-chrome" - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - -before_script: - - npm install - -script: - - gulp build - - gulp test - - gulp coverage - - gulp package - - gulp bower - - cat ./coverage/lcov.info | ./node_modules/.bin/coveralls - -notifications: - slack: chartjs:pcfCZR6ugg5TEcaLtmIfQYuA - -sudo: required -dist: trusty - -addons: - firefox: latest - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - -deploy: -# Creates a tag containing dist files and bower.json -# Requires GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables -# IMPORTANT: the script has to be set executable in the Git repository (error 127) -# https://github.com/travis-ci/travis-ci/issues/5538#issuecomment-225025939 -- provider: script - script: ./scripts/release.sh - skip_cleanup: true - on: - branch: release -- provider: releases - api_key: $GITHUB_AUTH_TOKEN - file: - - "./dist/Chart.bundle.js" - - "./dist/Chart.bundle.min.js" - - "./dist/Chart.js" - - "./dist/Chart.min.js" - - "./dist/Chart.js.zip" - skip_cleanup: true - on: - tags: true -- provider: npm - email: $NPM_AUTH_EMAIL - api_key: $NPM_AUTH_TOKEN - skip_cleanup: true - on: - tags: true diff --git a/system/templates/js/chart-js/CONTRIBUTING.md b/system/templates/js/chart-js/CONTRIBUTING.md deleted file mode 100644 index 6ec10243..00000000 --- a/system/templates/js/chart-js/CONTRIBUTING.md +++ /dev/null @@ -1,64 +0,0 @@ -Contributing to Chart.js -======================== - -Contributions to Chart.js are welcome and encouraged, but please have a look through the guidelines in this document before raising an issue, or writing code for the project. - - -Using issues ------------- - -The [issue tracker](https://github.com/chartjs/Chart.js/issues) is the preferred channel for reporting bugs, requesting new features and submitting pull requests. - -If you're suggesting a new chart type, please take a look at [writing new chart types](https://github.com/chartjs/Chart.js/blob/master/docs/09-Advanced.md#writing-new-chart-types) in the documentation or consider [creating a plugin](https://github.com/chartjs/Chart.js/blob/master/docs/09-Advanced.md#creating-plugins). - -To keep the library lightweight for everyone, it's unlikely we'll add many more chart types to the core of Chart.js, but issues are a good medium to design and spec out how new chart types could work and look. - -Please do not use issues for support requests. For help using Chart.js, please take a look at the [`chartjs`](http://stackoverflow.com/questions/tagged/chartjs) tag on Stack Overflow. - - -Reporting bugs --------------- - -Well structured, detailed bug reports are hugely valuable for the project. - -Guidelines for reporting bugs: - - - Check the issue search to see if it has already been reported - - Isolate the problem to a simple test case - - Please include a demonstration of the bug on a website such as [JS Bin](http://jsbin.com/), [JS Fiddle](http://jsfiddle.net/), or [Codepen](http://codepen.io/pen/). ([Template](http://codepen.io/pen?template=JXVYzq)) - -Please provide any additional details associated with the bug, if it's browser or screen density specific, or only happens with a certain configuration or data. - - -Local development ------------------ - -Run `npm install` to install all the libraries, then run `gulp dev --test` to build and run tests as you make changes. - - -Pull requests -------------- - -Clear, concise pull requests are excellent at continuing the project's community driven growth. But please review [these guidelines](https://github.com/blog/1943-how-to-write-the-perfect-pull-request) and the guidelines below before starting work on the project. - -Be advised that **Chart.js 1.0.2 is in feature-complete status**. Pull requests adding new features to the 1.x branch will be disregarded. - -Guidelines: - - - Please create an issue first and/or talk with a team member: - - For bugs, we can discuss the fixing approach - - For enhancements, we can discuss if it is within the project scope and avoid duplicate effort - - Please make changes to the files in [`/src`](https://github.com/chartjs/Chart.js/tree/master/src), not `Chart.js` or `Chart.min.js` in the repo root directory, this avoids merge conflicts - - Tabs for indentation, not spaces please - - If adding new functionality, please also update the relevant `.md` file in [`/docs`](https://github.com/chartjs/Chart.js/tree/master/docs) - - Please make your commits in logical sections with clear commit messages - -Joining the project -------------- - - Active committers and contributors are invited to introduce yourself and request commit access to this project. Please send an email to hello@nickdownie.com or file an issue. - - We have a very active Slack community that you can join [here](https://chart-js-automation.herokuapp.com/). If you think you can help, we'd love to have you! - -License -------- - -By contributing your code, you agree to license your contribution under the [MIT license](https://github.com/chartjs/Chart.js/blob/master/LICENSE.md). diff --git a/system/templates/js/chart-js/MAINTAINING.md b/system/templates/js/chart-js/MAINTAINING.md deleted file mode 100644 index 5e34f433..00000000 --- a/system/templates/js/chart-js/MAINTAINING.md +++ /dev/null @@ -1,36 +0,0 @@ -# Maintaining -## Release Process -Chart.js relies on [Travis CI](https://travis-ci.org/) to automate the library [releases](https://github.com/chartjs/Chart.js/releases). - -### Releasing a New Version - -1. draft release notes on [GitHub](https://github.com/chartjs/Chart.js/releases/new) for the upcoming tag -1. update `master` `package.json` version using [semver](http://semver.org/) semantic -1. merge `master` into the `release` branch -1. follow the build process on [Travis CI](https://travis-ci.org/chartjs/Chart.js) - -> **Note:** if `master` is merged in `release` with a `package.json` version that already exists, the tag -creation fails and the release process is aborted. - -### Automated Tasks -Merging into the `release` branch kicks off the automated release process: - -* build of the `dist/*.js` files -* `bower.json` is generated from `package.json` -* `dist/*.js` and `bower.json` are added to a detached branch -* a tag is created from the `package.json` version -* tag (with dist files) is pushed to GitHub - -Creation of this tag triggers a new build: - -* `Chart.js.zip` package is generated, containing dist files and examples -* `dist/*.js` and `Chart.js.zip` are attached to the GitHub release (downloads) -* a new npm package is published on [npmjs](https://www.npmjs.com/package/chart.js) - -Finally, [cdnjs](https://cdnjs.com/libraries/Chart.js) is automatically updated from the npm release. - -### Further Reading - -* [Travis GitHub releases](https://github.com/chartjs/Chart.js/pull/2555) -* [Bower support and dist/* files](https://github.com/chartjs/Chart.js/issues/3033) -* [cdnjs npm auto update](https://github.com/cdnjs/cdnjs/pull/8401) diff --git a/system/templates/js/chart-js/bower.json b/system/templates/js/chart-js/bower.json deleted file mode 100644 index 8cea44e2..00000000 --- a/system/templates/js/chart-js/bower.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "chart.js", - "description": "Simple HTML5 charts using the canvas element.", - "homepage": "http://www.chartjs.org", - "license": "MIT", - "version": "2.5.0", - "main": "./dist/Chart.js", - "ignore": [ - ".github", - ".codeclimate.yml", - ".gitignore", - ".npmignore", - ".travis.yml", - "scripts" - ] -} \ No newline at end of file diff --git a/system/templates/js/chart-js/component.json b/system/templates/js/chart-js/component.json deleted file mode 100755 index 11e11c79..00000000 --- a/system/templates/js/chart-js/component.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Chart.js", - "version": "0.2.0", - "description": "Simple HTML5 Charts using the canvas element", - "keywords": ["charts"], - "homepage": "https://github.com/nnnick/Chart.js", - "author": "nnnick", - "main": ["Chart.min.js"], - "dependencies": { - } -} \ No newline at end of file diff --git a/system/templates/js/chart-js/composer.json b/system/templates/js/chart-js/composer.json deleted file mode 100644 index 48d05b8d..00000000 --- a/system/templates/js/chart-js/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "nnnick/chartjs", - "type": "library", - "description": "Simple HTML5 charts using the canvas element.", - "keywords": [ - "chart", - "js" - ], - "homepage": "http://www.chartjs.org/", - "license": "MIT", - "authors": [ - { - "name": "NICK DOWNIE", - "email": "hello@nickdownie.com" - } - ], - "require": { - "php": ">=5.3.3" - }, - "minimum-stability": "stable", - "extra": { - "branch-alias": { - "release/2.0": "v2.0-dev" - } - } -} diff --git a/system/templates/js/chart-js/config.jshintrc b/system/templates/js/chart-js/config.jshintrc deleted file mode 100644 index 00b42024..00000000 --- a/system/templates/js/chart-js/config.jshintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "node": true, - "unused": true, - "predef": [ "require", "module" ] -} \ No newline at end of file diff --git a/system/templates/js/chart-js/docs/00-Getting-Started.md b/system/templates/js/chart-js/docs/00-Getting-Started.md deleted file mode 100644 index 81e03c0a..00000000 --- a/system/templates/js/chart-js/docs/00-Getting-Started.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Getting started -anchor: getting-started ---- - -### Download Chart.js - -You can download the latest version of [Chart.js on GitHub](https://github.com/chartjs/Chart.js/releases/latest) or just use these [Chart.js CDN](https://cdnjs.com/libraries/Chart.js) links. -If you download or clone the repository, you must run `gulp build` to generate the dist files. Chart.js no longer comes with prebuilt release versions, so an alternative option to downloading the repo is **strongly** advised. - -### Installation - -#### npm - -```bash -npm install chart.js --save -``` - -#### bower - -```bash -bower install chart.js --save -``` - -### Selecting the Correct Build - -Chart.js provides two different builds that are available for your use. The `Chart.js` and `Chart.min.js` files include Chart.js and the accompanying color parsing library. If this version is used and you require the use of the time axis, [Moment.js](http://momentjs.com/) will need to be included before Chart.js. - -The `Chart.bundle.js` and `Chart.bundle.min.js` builds include Moment.js in a single file. This version should be used if you require time axes and want a single file to include, select this version. Do not use this build if your application already includes Moment.js. If you do, Moment.js will be included twice, increasing the page load time and potentially introducing version issues. - -### Usage - -To import Chart.js using an old-school script tag: - -```html - - -``` - -To import Chart.js using an awesome module loader: - -```javascript - -// Using CommonJS -var Chart = require('chart.js') -var myChart = new Chart({...}) - -// ES6 -import Chart from 'chart.js' -let myChart = new Chart({...}) - -// Using requirejs -require(['path/to/Chartjs'], function(Chart){ - var myChart = new Chart({...}) -}) - -``` - -### Creating a Chart - -To create a chart, we need to instantiate the `Chart` class. To do this, we need to pass in the node, jQuery instance, or 2d context of the canvas of where we want to draw the chart. Here's an example. - -```html - -``` - -```javascript -// Any of the following formats may be used -var ctx = document.getElementById("myChart"); -var ctx = document.getElementById("myChart").getContext("2d"); -var ctx = $("#myChart"); -var ctx = "myChart"; -``` - -Once you have the element or context, you're ready to instantiate a pre-defined chart-type or create your own! - -The following example instantiates a bar chart showing the number of votes for different colors and the y-axis starting at 0. - -```html - - -``` - -It's that easy to get started using Chart.js! From here you can explore the many options that can help you customise your charts with scales, tooltips, labels, colors, custom actions, and much more. - -There are many examples of Chart.js that are available in the `/samples` folder of `Chart.js.zip` that is attatched to every [release](https://github.com/chartjs/Chart.js/releases). diff --git a/system/templates/js/chart-js/docs/01-Chart-Configuration.md b/system/templates/js/chart-js/docs/01-Chart-Configuration.md deleted file mode 100644 index 865a7558..00000000 --- a/system/templates/js/chart-js/docs/01-Chart-Configuration.md +++ /dev/null @@ -1,518 +0,0 @@ ---- -title: Chart Configuration -anchor: chart-configuration ---- - -Chart.js provides a number of options for changing the behaviour of created charts. These configuration options can be changed on a per chart basis by passing in an options object when creating the chart. Alternatively, the global configuration can be changed which will be used by all charts created after that point. - -### Chart Data - -To display data, the chart must be passed a data object that contains all of the information needed by the chart. The data object can contain the following parameters - -Name | Type | Description ---- | --- | ---- -datasets | Array[object] | Contains data for each dataset. See the documentation for each chart type to determine the valid options that can be attached to the dataset -labels | Array[string] | Optional parameter that is used with the [category axis](#scales-category-scale). -xLabels | Array[string] | Optional parameter that is used with the category axis and is used if the axis is horizontal -yLabels | Array[string] | Optional parameter that is used with the category axis and is used if the axis is vertical - -### Creating a Chart with Options - -To create a chart with configuration options, simply pass an object containing your configuration to the constructor. In the example below, a line chart is created and configured to not be responsive. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - responsive: false - } -}); -``` - -### Global Configuration - -This concept was introduced in Chart.js 1.0 to keep configuration [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), and allow for changing options globally across chart types, avoiding the need to specify options for each instance, or the default for a particular chart type. - -Chart.js merges the options object passed to the chart with the global configuration using chart type defaults and scales defaults appropriately. This way you can be as specific as you would like in your individual chart configuration, while still changing the defaults for all chart types where applicable. The global general options are defined in `Chart.defaults.global`. The defaults for each chart type are discussed in the documentation for that chart type. - -The following example would set the hover mode to 'nearest' for all charts where this was not overridden by the chart type defaults or the options passed to the constructor on creation. - -```javascript -Chart.defaults.global.hover.mode = 'nearest'; - -// Hover mode is set to nearest because it was not overridden here -var chartInstanceHoverModeNearest = new Chart(ctx, { - type: 'line', - data: data, -}); - -// This chart would have the hover mode that was passed in -var chartInstanceDifferentHoverMode = new Chart(ctx, { - type: 'line', - data: data, - options: { - hover: { - // Overrides the global setting - mode: 'index' - } - } -}) -``` - -#### Global Font Settings - -There are 4 special global settings that can change all of the fonts on the chart. These options are in `Chart.defaults.global`. - -Name | Type | Default | Description ---- | --- | --- | --- -defaultFontColor | Color | '#666' | Default font color for all text -defaultFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Default font family for all text -defaultFontSize | Number | 12 | Default font size (in px) for text. Does not apply to radialLinear scale point labels -defaultFontStyle | String | 'normal' | Default font style. Does not apply to tooltip title or footer. Does not apply to chart title - -### Common Chart Configuration - -The following options are applicable to all charts. The can be set on the [global configuration](#chart-configuration-global-configuration), or they can be passed to the chart constructor. - -Name | Type | Default | Description ---- | --- | --- | --- -responsive | Boolean | true | Resizes the chart canvas when its container does. -responsiveAnimationDuration | Number | 0 | Duration in milliseconds it takes to animate to new size after a resize event. -maintainAspectRatio | Boolean | true | Maintain the original canvas aspect ratio `(width / height)` when resizing -events | Array[String] | `["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"]` | Events that the chart should listen to for tooltips and hovering -onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed the event and an array of active elements -legendCallback | Function | ` function (chart) { }` | Function to generate a legend. Receives the chart object to generate a legend from. Default implementation returns an HTML string. -onResize | Function | null | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size. - -### Layout Configuration - -The layout configuration is passed into the `options.layout` namespace. The global options for the chart layout is defined in `Chart.defaults.global.layout`. - -Name | Type | Default | Description ---- | --- | --- | --- -padding | Number or Object | 0 | The padding to add inside the chart. If this value is a number, it is applied to all sides of the chart (left, top, right, bottom). If this value is an object, the `left` property defines the left padding. Similarly the `right`, `top`, and `bottom` properties can also be specified. - - -### Title Configuration - -The title configuration is passed into the `options.title` namespace. The global options for the chart title is defined in `Chart.defaults.global.title`. - -Name | Type | Default | Description ---- | --- | --- | --- -display | Boolean | false | Display the title block -position | String | 'top' | Position of the title. Possible values are 'top', 'left', 'bottom' and 'right'. -fullWidth | Boolean | true | Marks that this box should take the full width of the canvas (pushing down other boxes) -fontSize | Number | 12 | Font size inherited from global configuration -fontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family inherited from global configuration -fontColor | Color | "#666" | Font color inherited from global configuration -fontStyle | String | 'bold' | Font styling of the title. -padding | Number | 10 | Number of pixels to add above and below the title text -text | String | '' | Title text - -#### Example Usage - -The example below would enable a title of 'Custom Chart Title' on the chart that is created. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - title: { - display: true, - text: 'Custom Chart Title' - } - } -}) -``` - -### Legend Configuration - -The legend configuration is passed into the `options.legend` namespace. The global options for the chart legend is defined in `Chart.defaults.global.legend`. - -Name | Type | Default | Description ---- | --- | --- | --- -display | Boolean | true | Is the legend displayed -position | String | 'top' | Position of the legend. Possible values are 'top', 'left', 'bottom' and 'right'. -fullWidth | Boolean | true | Marks that this box should take the full width of the canvas (pushing down other boxes) -onClick | Function | `function(event, legendItem) {}` | A callback that is called when a 'click' event is registered on top of a label item -onHover | Function | `function(event, legendItem) {}` | A callback that is called when a 'mousemove' event is registered on top of a label item -labels |Object|-| See the [Legend Label Configuration](#chart-configuration-legend-label-configuration) section below. -reverse | Boolean | false | Legend will show datasets in reverse order - -#### Legend Label Configuration - -The legend label configuration is nested below the legend configuration using the `labels` key. - -Name | Type | Default | Description ---- | --- | --- | --- -boxWidth | Number | 40 | Width of coloured box -fontSize | Number | 12 | Font size inherited from global configuration -fontStyle | String | "normal" | Font style inherited from global configuration -fontColor | Color | "#666" | Font color inherited from global configuration -fontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family inherited from global configuration -padding | Number | 10 | Padding between rows of colored boxes -generateLabels: | Function | `function(chart) { }` | Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See [Legend Item](#chart-configuration-legend-item-interface) for details. -filter | Function | null | Filters legend items out of the legend. Receives 2 parameters, a [Legend Item](#chart-configuration-legend-item-interface) and the chart data -usePointStyle | Boolean | false | Label style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case). - -#### Legend Item Interface - -Items passed to the legend `onClick` function are the ones returned from `labels.generateLabels`. These items must implement the following interface. - -```javascript -{ - // Label that will be displayed - text: String, - - // Fill style of the legend box - fillStyle: Color, - - // If true, this item represents a hidden dataset. Label will be rendered with a strike-through effect - hidden: Boolean, - - // For box border. See https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap - lineCap: String, - - // For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash - lineDash: Array[Number], - - // For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset - lineDashOffset: Number, - - // For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin - lineJoin: String, - - // Width of box border - lineWidth: Number, - - // Stroke style of the legend box - strokeStyle: Color - - // Point style of the legend box (only used if usePointStyle is true) - pointStyle: String -} -``` - -#### Example - -The following example will create a chart with the legend enabled and turn all of the text red in color. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'bar', - data: data, - options: { - legend: { - display: true, - labels: { - fontColor: 'rgb(255, 99, 132)' - } - } -} -}); -``` - -### Tooltip Configuration - -The tooltip configuration is passed into the `options.tooltips` namespace. The global options for the chart tooltips is defined in `Chart.defaults.global.tooltips`. - -Name | Type | Default | Description ---- | --- | --- | --- -enabled | Boolean | true | Are tooltips enabled -custom | Function | null | See [section](#advanced-usage-external-tooltips) below -mode | String | 'nearest' | Sets which elements appear in the tooltip. See [Interaction Modes](#interaction-modes) for details -intersect | Boolean | true | if true, the tooltip mode applies only when the mouse position intersects with an element. If false, the mode will be applied at all times. -position | String | 'average' | The mode for positioning the tooltip. 'average' mode will place the tooltip at the average position of the items displayed in the tooltip. 'nearest' will place the tooltip at the position of the element closest to the event position. New modes can be defined by adding functions to the Chart.Tooltip.positioners map. -itemSort | Function | undefined | Allows sorting of [tooltip items](#chart-configuration-tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort). This function can also accept a third parameter that is the data object passed to the chart. -filter | Function | undefined | Allows filtering of [tooltip items](#chart-configuration-tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.filter](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). This function can also accept a second parameter that is the data object passed to the chart. -backgroundColor | Color | 'rgba(0,0,0,0.8)' | Background color of the tooltip -titleFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for tooltip title inherited from global font family -titleFontSize | Number | 12 | Font size for tooltip title inherited from global font size -titleFontStyle | String | "bold" | -titleFontColor | Color | "#fff" | Font color for tooltip title -titleSpacing | Number | 2 | Spacing to add to top and bottom of each title line. -titleMarginBottom | Number | 6 | Margin to add on bottom of title section -bodyFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for tooltip items inherited from global font family -bodyFontSize | Number | 12 | Font size for tooltip items inherited from global font size -bodyFontStyle | String | "normal" | -bodyFontColor | Color | "#fff" | Font color for tooltip items. -bodySpacing | Number | 2 | Spacing to add to top and bottom of each tooltip item -footerFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for tooltip footer inherited from global font family. -footerFontSize | Number | 12 | Font size for tooltip footer inherited from global font size. -footerFontStyle | String | "bold" | Font style for tooltip footer. -footerFontColor | Color | "#fff" | Font color for tooltip footer. -footerSpacing | Number | 2 | Spacing to add to top and bottom of each footer line. -footerMarginTop | Number | 6 | Margin to add before drawing the footer -xPadding | Number | 6 | Padding to add on left and right of tooltip -yPadding | Number | 6 | Padding to add on top and bottom of tooltip -caretSize | Number | 5 | Size, in px, of the tooltip arrow -cornerRadius | Number | 6 | Radius of tooltip corner curves -multiKeyBackground | Color | "#fff" | Color to draw behind the colored boxes when multiple items are in the tooltip -displayColors | Boolean | true | if true, color boxes are shown in the tooltip -callbacks | Object | | See the [callbacks section](#chart-configuration-tooltip-callbacks) below - -#### Tooltip Callbacks - -The tooltip label configuration is nested below the tooltip configuration using the `callbacks` key. The tooltip has the following callbacks for providing text. For all functions, 'this' will be the tooltip object created from the Chart.Tooltip constructor. - -All functions are called with the same arguments: a [tooltip item](#chart-configuration-tooltip-item-interface) and the data object passed to the chart. All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text. - -Callback | Arguments | Description ---- | --- | --- -beforeTitle | `Array[tooltipItem], data` | Text to render before the title -title | `Array[tooltipItem], data` | Text to render as the title -afterTitle | `Array[tooltipItem], data` | Text to render after the title -beforeBody | `Array[tooltipItem], data` | Text to render before the body section -beforeLabel | `tooltipItem, data` | Text to render before an individual label -label | `tooltipItem, data` | Text to render for an individual item in the tooltip -labelColor | `tooltipItem, chartInstance` | Returns the colors to render for the tooltip item. Return as an object containing two parameters: `borderColor` and `backgroundColor`. -afterLabel | `tooltipItem, data` | Text to render after an individual label -afterBody | `Array[tooltipItem], data` | Text to render after the body section -beforeFooter | `Array[tooltipItem], data` | Text to render before the footer section -footer | `Array[tooltipItem], data` | Text to render as the footer -afterFooter | `Array[tooltipItem], data` | Text to render after the footer section -dataPoints | `Array[tooltipItem]` | List of matching point informations. - -#### Tooltip Item Interface - -The tooltip items passed to the tooltip callbacks implement the following interface. - -```javascript -{ - // X Value of the tooltip as a string - xLabel: String, - - // Y value of the tooltip as a string - yLabel: String, - - // Index of the dataset the item comes from - datasetIndex: Number, - - // Index of this data item in the dataset - index: Number, - - // X position of matching point - x: Number, - - // Y position of matching point - y: Number, -} -``` - -### Hover Configuration - -The hover configuration is passed into the `options.hover` namespace. The global hover configuration is at `Chart.defaults.global.hover`. - -Name | Type | Default | Description ---- | --- | --- | --- -mode | String | 'nearest' | Sets which elements appear in the tooltip. See [Interaction Modes](#interaction-modes) for details -intersect | Boolean | true | if true, the hover mode only applies when the mouse position intersects an item on the chart -animationDuration | Number | 400 | Duration in milliseconds it takes to animate hover style changes -onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed the event and an array of active elements (bars, points, etc) - -### Interaction Modes -When configuring interaction with the graph via hover or tooltips, a number of different modes are available. - -The following table details the modes and how they behave in conjunction with the `intersect` setting - -Mode | Behaviour ---- | --- -point | Finds all of the items that intersect the point -nearest | Gets the item that is nearest to the point. The nearest item is determined based on the distance to the center of the chart item (point, bar). If 2 or more items are at the same distance, the one with the smallest area is used. If `intersect` is true, this is only triggered when the mouse position intersects an item in the graph. This is very useful for combo charts where points are hidden behind bars. -single (deprecated) | Finds the first item that intersects the point and returns it. Behaves like 'nearest' mode with intersect = true. -label (deprecated) | See `'index'` mode -index | Finds item at the same index. If the `intersect` setting is true, the first intersecting item is used to determine the index in the data. If `intersect` false the nearest item is used to determine the index. -x-axis (deprecated) | Behaves like `'index'` mode with `intersect = false` -dataset | Finds items in the same dataset. If the `intersect` setting is true, the first intersecting item is used to determine the index in the data. If `intersect` false the nearest item is used to determine the index. -x | Returns all items that would intersect based on the `X` coordinate of the position only. Would be useful for a vertical cursor implementation. Note that this only applies to cartesian charts -y | Returns all items that would intersect based on the `Y` coordinate of the position. This would be useful for a horizontal cursor implementation. Note that this only applies to cartesian charts. - -### Animation Configuration - -The following animation options are available. The global options for are defined in `Chart.defaults.global.animation`. - -Name | Type | Default | Description ---- |:---:| --- | --- -duration | Number | 1000 | The number of milliseconds an animation takes. -easing | String | "easeOutQuart" | Easing function to use. Available options are: `'linear'`, `'easeInQuad'`, `'easeOutQuad'`, `'easeInOutQuad'`, `'easeInCubic'`, `'easeOutCubic'`, `'easeInOutCubic'`, `'easeInQuart'`, `'easeOutQuart'`, `'easeInOutQuart'`, `'easeInQuint'`, `'easeOutQuint'`, `'easeInOutQuint'`, `'easeInSine'`, `'easeOutSine'`, `'easeInOutSine'`, `'easeInExpo'`, `'easeOutExpo'`, `'easeInOutExpo'`, `'easeInCirc'`, `'easeOutCirc'`, `'easeInOutCirc'`, `'easeInElastic'`, `'easeOutElastic'`, `'easeInOutElastic'`, `'easeInBack'`, `'easeOutBack'`, `'easeInOutBack'`, `'easeInBounce'`, `'easeOutBounce'`, `'easeInOutBounce'`. See [Robert Penner's easing equations](http://robertpenner.com/easing/). -onProgress | Function | none | Callback called on each step of an animation. Passed a single argument, an object, containing the chart instance and an object with details of the animation. -onComplete | Function | none | Callback called at the end of an animation. Passed the same arguments as `onProgress` - -#### Animation Callbacks - -The `onProgress` and `onComplete` callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed an object that implements the following interface. An example usage of these callbacks can be found on [Github](https://github.com/chartjs/Chart.js/blob/master/samples/animation/progress-bar.html). This sample displays a progress bar showing how far along the animation is. - -```javascript -{ - // Chart object - chartInstance, - - // Contains details of the on-going animation - animationObject, -} -``` - -#### Animation Object - -The animation object passed to the callbacks is of type `Chart.Animation`. The object has the following parameters. - -```javascript -{ - // Current Animation frame number - currentStep: Number, - - // Number of animation frames - numSteps: Number, - - // Animation easing to use - easing: String, - - // Function that renders the chart - render: Function, - - // User callback - onAnimationProgress: Function, - - // User callback - onAnimationComplete: Function -} -``` - -### Element Configuration - -The global options for elements are defined in `Chart.defaults.global.elements`. - -Options can be configured for four different types of elements: arc, lines, points, and rectangles. When set, these options apply to all objects of that type unless specifically overridden by the configuration attached to a dataset. - -#### Arc Configuration - -Arcs are used in the polar area, doughnut and pie charts. They can be configured with the following options. The global arc options are stored in `Chart.defaults.global.elements.arc`. - -Name | Type | Default | Description ---- | --- | --- | --- -backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default fill color for arcs. Inherited from the global default -borderColor | Color | '#fff' | Default stroke color for arcs -borderWidth | Number | 2 | Default stroke width for arcs - -#### Line Configuration - -Line elements are used to represent the line in a line chart. The global line options are stored in `Chart.defaults.global.elements.line`. - -Name | Type | Default | Description ---- | --- | --- | --- -tension | Number | 0.4 | Default bezier curve tension. Set to `0` for no bezier curves. -backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default line fill color -borderWidth | Number | 3 | Default line stroke width -borderColor | Color | 'rgba(0,0,0,0.1)' | Default line stroke color -borderCapStyle | String | 'butt' | Default line cap style. See [MDN](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap) -borderDash | Array | `[]` | Default line dash. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash) -borderDashOffset | Number | 0.0 | Default line dash offset. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) -borderJoinStyle | String | 'miter' | Default line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin) -capBezierPoints | Boolean | true | If true, bezier control points are kept inside the chart. If false, no restriction is enforced. -fill | Boolean or String | true | If true, the fill is assumed to be to zero. String values are 'zero', 'top', and 'bottom' to fill to different locations. If `false`, no fill is added -stepped | Boolean | false | If true, the line is shown as a stepped line and 'tension' will be ignored - -#### Point Configuration - -Point elements are used to represent the points in a line chart or a bubble chart. The global point options are stored in `Chart.defaults.global.elements.point`. - -Name | Type | Default | Description ---- | --- | --- | --- -radius | Number | 3 | Default point radius -pointStyle | String | 'circle' | Default point style -backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default point fill color -borderWidth | Number | 1 | Default point stroke width -borderColor | Color | 'rgba(0,0,0,0.1)' | Default point stroke color -hitRadius | Number | 1 | Extra radius added to point radius for hit detection -hoverRadius | Number | 4 | Default point radius when hovered -hoverBorderWidth | Number | 1 | Default stroke width when hovered - -#### Rectangle Configuration - -Rectangle elements are used to represent the bars in a bar chart. The global rectangle options are stored in `Chart.defaults.global.elements.rectangle`. - -Name | Type | Default | Description ---- | --- | --- | --- -backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default bar fill color -borderWidth | Number | 0 | Default bar stroke width -borderColor | Color | 'rgba(0,0,0,0.1)' | Default bar stroke color -borderSkipped | String | 'bottom' | Default skipped (excluded) border for rectangle. Can be one of `bottom`, `left`, `top`, `right` - -### Colors - -When supplying colors to Chart options, you can use a number of formats. You can specify the color as a string in hexadecimal, RGB, or HSL notations. If a color is needed, but not specified, Chart.js will use the global default color. This color is stored at `Chart.defaults.global.defaultColor`. It is initially set to 'rgba(0, 0, 0, 0.1)'; - -You can also pass a [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient) object. You will need to create this before passing to the chart, but using it you can achieve some interesting effects. - -### Patterns - -An alternative option is to pass a [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern) object. For example, if you wanted to fill a dataset with a pattern from an image you could do the following. - -```javascript -var img = new Image(); -img.src = 'https://example.com/my_image.png'; -img.onload = function() { - var ctx = document.getElementById('canvas').getContext('2d'); - var fillPattern = ctx.createPattern(img, 'repeat'); - - var chart = new Chart(ctx, { - data: { - labels: ['Item 1', 'Item 2', 'Item 3'], - datasets: [{ - data: [10, 20, 30], - backgroundColor: fillPattern - }] - } - }) -} -``` - -Using pattern fills for data graphics can help viewers with vision deficiencies (e.g. color-blindness or partial sight) to [more easily understand your data](http://betweentwobrackets.com/data-graphics-and-colour-vision/). - -Using the [Patternomaly](https://github.com/ashiguruma/patternomaly) library you can generate patterns to fill datasets. - -```javascript -var chartData = { - datasets: [{ - data: [45, 25, 20, 10], - backgroundColor: [ - pattern.draw('square', '#ff6384'), - pattern.draw('circle', '#36a2eb'), - pattern.draw('diamond', '#cc65fe'), - pattern.draw('triangle', '#ffce56'), - ] - }], - labels: ['Red', 'Blue', 'Purple', 'Yellow'] -}; -``` - -### Mixed Chart Types - -When creating a chart, you have the option to overlay different chart types on top of each other as separate datasets. - -To do this, you must set a `type` for each dataset individually. You can create mixed chart types with bar and line chart types. - -When creating the chart you must set the overall `type` as `bar`. - -```javascript -var myChart = new Chart(ctx, { - type: 'bar', - data: { - labels: ['Item 1', 'Item 2', 'Item 3'], - datasets: [ - { - type: 'bar', - label: 'Bar Component', - data: [10, 20, 30], - }, - { - type: 'line', - label: 'Line Component', - data: [30, 20, 10], - } - ] - } -}); -``` diff --git a/system/templates/js/chart-js/docs/02-Scales.md b/system/templates/js/chart-js/docs/02-Scales.md deleted file mode 100644 index af7812ce..00000000 --- a/system/templates/js/chart-js/docs/02-Scales.md +++ /dev/null @@ -1,369 +0,0 @@ ---- -title: Scales -anchor: scales ---- - -Scales in v2.0 of Chart.js are significantly more powerful, but also different than those of v1.0. -* Multiple X & Y axes are supported. -* A built-in label auto-skip feature detects would-be overlapping ticks and labels and removes every nth label to keep things displaying normally. -* Scale titles are supported -* New scale types can be extended without writing an entirely new chart type - - -### Common Configuration - -Every scale extends a core scale class with the following options: - -Name | Type | Default | Description ---- | --- | --- | --- -type | String | Chart specific. | Type of scale being employed. Custom scales can be created and registered with a string key. Options: ["category"](#scales-category-scale), ["linear"](#scales-linear-scale), ["logarithmic"](#scales-logarithmic-scale), ["time"](#scales-time-scale), ["radialLinear"](#scales-radial-linear-scale) -display | Boolean | true | If true, show the scale including gridlines, ticks, and labels. Overrides *gridLines.display*, *scaleLabel.display*, and *ticks.display*. -position | String | "left" | Position of the scale. Possible values are 'top', 'left', 'bottom' and 'right'. -id | String | | The ID is used to link datasets and scale axes together. The properties `datasets.xAxisID` or `datasets.yAxisID` have to match the scale properties `scales.xAxes.id` or `scales.yAxes.id`. This is especially needed if multi-axes charts are used. -beforeUpdate | Function | undefined | Callback called before the update process starts. Passed a single argument, the scale instance. -beforeSetDimensions | Function | undefined | Callback that runs before dimensions are set. Passed a single argument, the scale instance. -afterSetDimensions | Function | undefined | Callback that runs after dimensions are set. Passed a single argument, the scale instance. -beforeDataLimits | Function | undefined | Callback that runs before data limits are determined. Passed a single argument, the scale instance. -afterDataLimits | Function | undefined | Callback that runs after data limits are determined. Passed a single argument, the scale instance. -beforeBuildTicks | Function | undefined | Callback that runs before ticks are created. Passed a single argument, the scale instance. -afterBuildTicks | Function | undefined | Callback that runs after ticks are created. Useful for filtering ticks. Passed a single argument, the scale instance. -beforeTickToLabelConversion | Function | undefined | Callback that runs before ticks are converted into strings. Passed a single argument, the scale instance. -afterTickToLabelConversion | Function | undefined | Callback that runs after ticks are converted into strings. Passed a single argument, the scale instance. -beforeCalculateTickRotation | Function | undefined | Callback that runs before tick rotation is determined. Passed a single argument, the scale instance. -afterCalculateTickRotation | Function | undefined | Callback that runs after tick rotation is determined. Passed a single argument, the scale instance. -beforeFit | Function | undefined | Callback that runs before the scale fits to the canvas. Passed a single argument, the scale instance. -afterFit | Function | undefined | Callback that runs after the scale fits to the canvas. Passed a single argument, the scale instance. -afterUpdate | Function | undefined | Callback that runs at the end of the update process. Passed a single argument, the scale instance. -**gridLines** | Object | - | See [grid line configuration](#grid-line-configuration) section. -**scaleLabel** | Object | | See [scale title configuration](#scale-title-configuration) section. -**ticks** | Object | | See [tick configuration](#tick-configuration) section. - -#### Grid Line Configuration - -The grid line configuration is nested under the scale configuration in the `gridLines` key. It defines options for the grid lines that run perpendicular to the axis. - -Name | Type | Default | Description ---- | --- | --- | --- -display | Boolean | true | -color | Color or Array[Color] | "rgba(0, 0, 0, 0.1)" | Color of the grid lines. -borderDash | Array[Number] | [] | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash) -borderDashOffset | Number | 0.0 | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) -lineWidth | Number or Array[Number] | 1 | Stroke width of grid lines -drawBorder | Boolean | true | If true draw border on the edge of the chart -drawOnChartArea | Boolean | true | If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn -drawTicks | Boolean | true | If true, draw lines beside the ticks in the axis area beside the chart. -tickMarkLength | Number | 10 | Length in pixels that the grid lines will draw into the axis area. -zeroLineWidth | Number | 1 | Stroke width of the grid line for the first index (index 0). -zeroLineColor | Color | "rgba(0, 0, 0, 0.25)" | Stroke color of the grid line for the first index (index 0). -offsetGridLines | Boolean | false | If true, labels are shifted to be between grid lines. This is used in the bar chart. - -#### Scale Title Configuration - -The scale label configuration is nested under the scale configuration in the `scaleLabel` key. It defines options for the scale title. - -Name | Type | Default | Description ---- | --- | --- | --- -display | Boolean | false | -labelString | String | "" | The text for the title. (i.e. "# of People", "Response Choices") -fontColor | Color | "#666" | Font color for the scale title. -fontFamily| String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for the scale title, follows CSS font-family options. -fontSize | Number | 12 | Font size for the scale title. -fontStyle | String | "normal" | Font style for the scale title, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit). - -#### Tick Configuration - -The tick configuration is nested under the scale configuration in the `ticks` key. It defines options for the tick marks that are generated by the axis. - -Name | Type | Default | Description ---- | --- | --- | --- -autoSkip | Boolean | true | If true, automatically calculates how many labels that can be shown and hides labels accordingly. Turn it off to show all labels no matter what -autoSkipPadding | Number | 0 | Padding between the ticks on the horizontal axis when `autoSkip` is enabled. *Note: Only applicable to horizontal scales.* -callback | Function | `function(value) { return helpers.isArray(value) ? value : '' + value; }` | Returns the string representation of the tick value as it should be displayed on the chart. See [callback](#scales-creating-custom-tick-formats) section below. -display | Boolean | true | If true, show the ticks. -fontColor | Color | "#666" | Font color for the tick labels. -fontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for the tick labels, follows CSS font-family options. -fontSize | Number | 12 | Font size for the tick labels. -fontStyle | String | "normal" | Font style for the tick labels, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit). -labelOffset | Number | 0 | Distance in pixels to offset the label from the centre point of the tick (in the y direction for the x axis, and the x direction for the y axis). *Note: this can cause labels at the edges to be cropped by the edge of the canvas* -maxRotation | Number | 90 | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.* -minRotation | Number | 0 | Minimum rotation for tick labels. *Note: Only applicable to horizontal scales.* -mirror | Boolean | false | Flips tick labels around axis, displaying the labels inside the chart instead of outside. *Note: Only applicable to vertical scales.* -padding | Number | 10 | Padding between the tick label and the axis. *Note: Only applicable to horizontal scales.* -reverse | Boolean | false | Reverses order of tick labels. - -#### Creating Custom Tick Formats - -The `callback` method may be used for advanced tick customization. In the following example, every label of the Y axis would be displayed in scientific notation. - -If the callback returns `null` or `undefined` the associated grid line will be hidden. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - yAxes: [{ - ticks: { - // Create scientific notation labels - callback: function(value, index, values) { - return value.toExponential(); - } - } - }] - } - } -}); -``` - -### Category Scale - -The category scale will be familiar to those who have used v1.0. Labels are drawn from one of the label arrays included in the chart data. If only `data.labels` is defined, this will be used. If `data.xLabels` is defined and the axis is horizontal, this will be used. Similarly, if `data.yLabels` is defined and the axis is vertical, this property will be used. Using both `xLabels` and `yLabels` together can create a chart that uses strings for both the X and Y axes. - -#### Configuration Options - -The category scale has the following additional options that can be set. - -Name | Type | Default | Description ---- | --- | --- | --- -ticks.min | String | - | The minimum item to display. Must be a value in the `labels` array -ticks.max | String | - | The maximum item to display. Must be a value in the `labels` array - -### Linear Scale - -The linear scale is use to chart numerical data. It can be placed on either the x or y axis. The scatter chart type automatically configures a line chart to use one of these scales for the x axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis. - -#### Configuration Options - -The following options are provided by the linear scale. They are all located in the `ticks` sub options. - -Name | Type | Default | Description ---- | --- | --- | --- -beginAtZero | Boolean | - | if true, scale will include 0 if it is not already included. -min | Number | - | User defined minimum number for the scale, overrides minimum value from data. -max | Number | - | User defined maximum number for the scale, overrides maximum value from data. -maxTicksLimit | Number | 11 | Maximum number of ticks and gridlines to show. If not defined, it will limit to 11 ticks but will show all gridlines. -fixedStepSize | Number | - | User defined fixed step size for the scale. If set, the scale ticks will be enumerated by multiple of stepSize, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm. -stepSize | Number | - | if defined, it can be used along with the min and the max to give a custom number of steps. See the example below. -suggestedMax | Number | - | User defined maximum number for the scale, overrides maximum value *except for if* it is lower than the maximum value. -suggestedMin | Number | - | User defined minimum number for the scale, overrides minimum value *except for if* it is higher than the minimum value. - -#### Example Configuration - -The following example creates a line chart with a vertical axis that goes from 0 to 5 in 0.5 sized steps. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - yAxes: [{ - ticks: { - max: 5, - min: 0, - stepSize: 0.5 - } - }] - } - } -}); -``` - -### Logarithmic Scale - -The logarithmic scale is use to chart numerical data. It can be placed on either the x or y axis. As the name suggests, logarithmic interpolation is used to determine where a value lies on the axis. - -#### Configuration Options - -The following options are provided by the logarithmic scale. They are all located in the `ticks` sub options. - -Name | Type | Default | Description ---- | --- | --- | --- -min | Number | - | User defined minimum number for the scale, overrides minimum value from data. -max | Number | - | User defined maximum number for the scale, overrides maximum value from data. - -#### Example Configuration - -The following example creates a chart with a logarithmic X axis that ranges from 1 to 1000. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - xAxes: [{ - type: 'logarithmic', - position: 'bottom', - ticks: { - min: 1, - max: 1000 - } - }] - } - } -}) -``` - -### Time Scale - -The time scale is used to display times and dates. It can only be placed on the X axis. When building its ticks, it will automatically calculate the most comfortable unit base on the size of the scale. - -#### Configuration Options - -The following options are provided by the time scale. They are all located in the `time` sub options. - -Name | Type | Default | Description ---- | --- | --- | --- -displayFormats | Object | - | See [Display Formats](#scales-display-formats) section below. -isoWeekday | Boolean | false | If true and the unit is set to 'week', iso weekdays will be used. -max | [Time](#scales-date-formats) | - | If defined, this will override the data maximum -min | [Time](#scales-date-formats) | - | If defined, this will override the data minimum -parser | String or Function | - | If defined as a string, it is interpreted as a custom format to be used by moment to parse the date. If this is a function, it must return a moment.js object given the appropriate data value. -round | String | - | If defined, dates will be rounded to the start of this unit. See [Time Units](#scales-time-units) below for the allowed units. -tooltipFormat | String | '' | The moment js format string to use for the tooltip. -unit | String | - | If defined, will force the unit to be a certain type. See [Time Units](#scales-time-units) section below for details. -unitStepSize | Number | 1 | The number of units between grid lines. -minUnit | String | 'millisecond' | The minimum display format to be used for a time unit - -#### Date Formats - -When providing data for the time scale, Chart.js supports all of the formats that Moment.js accepts. See [Moment.js docs](http://momentjs.com/docs/#/parsing/) for details. - -#### Display Formats - -The following display formats are used to configure how different time units are formed into strings for the axis tick marks. See [moment.js](http://momentjs.com/docs/#/displaying/format/) for the allowable format strings. - -Name | Default ---- | --- -millisecond | 'SSS [ms]' -second | 'h:mm:ss a' -minute | 'h:mm:ss a' -hour | 'MMM D, hA' -day | 'll' -week | 'll' -month | 'MMM YYYY' -quarter | '[Q]Q - YYYY' -year | 'YYYY' - -For example, to set the display format for the 'quarter' unit to show the month and year, the following config would be passed to the chart constructor. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - xAxes: [{ - type: 'time', - time: { - displayFormats: { - quarter: 'MMM YYYY' - } - } - }] - } - } -}) -``` - -#### Time Units - -The following time measurements are supported. The names can be passed as strings to the `time.unit` config option to force a certain unit. - -* millisecond -* second -* minute -* hour -* day -* week -* month -* quarter -* year - -For example, to create a chart with a time scale that always displayed units per month, the following config could be used. - -```javascript -var chartInstance = new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - xAxes: [{ - time: { - unit: 'month' - } - }] - } - } -}) -``` - -### Radial Linear Scale - -The radial linear scale is used specifically for the radar and polar area chart types. It overlays the chart area, rather than being positioned on one of the edges. - -#### Configuration Options - -The following additional configuration options are provided by the radial linear scale. - -Name | Type | Default | Description ---- | --- | --- | --- -lineArc | Boolean | false | If true, circular arcs are used else straight lines are used. The former is used by the polar area chart and the latter by the radar chart -angleLines | Object | - | See the Angle Line Options section below for details. -pointLabels | Object | - | See the Point Label Options section below for details. -ticks | Object | - | See the Ticks table below for options. - -#### Angle Line Options - -The following options are used to configure angled lines that radiate from the center of the chart to the point labels. They can be found in the `angleLines` sub options. Note that these options only apply if `lineArc` is false. - -Name | Type | Default | Description ---- | --- | --- | --- -display | Boolean | true | If true, angle lines are shown. -color | Color | 'rgba(0, 0, 0, 0.1)' | Color of angled lines -lineWidth | Number | 1 | Width of angled lines - -#### Point Label Options - -The following options are used to configure the point labels that are shown on the perimeter of the scale. They can be found in the `pointLabels` sub options. Note that these options only apply if `lineArc` is false. - -Name | Type | Default | Description ---- | --- | --- | --- -callback | Function | - | Callback function to transform data label to axis label -fontColor | Color | '#666' | Font color -fontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family to render -fontSize | Number | 10 | Font size in pixels -fontStyle | String | 'normal' | Font Style to use - - -#### Tick Options - -Name | Type | Default | Description ---- | --- | --- | --- -backdropColor | Color | 'rgba(255, 255, 255, 0.75)' | Color of label backdrops -backdropPaddingX | Number | 2 | Horizontal padding of label backdrop -backdropPaddingY | Number | 2 | Vertical padding of label backdrop -beginAtZero | Boolean | - | if true, scale will include 0 if it is not already included. -min | Number | - | User defined minimum number for the scale, overrides minimum value from data. -max | Number | - | User defined maximum number for the scale, overrides maximum value from data. -maxTicksLimit | Number | 11 | Maximum number of ticks and gridlines to show. If not defined, it will limit to 11 ticks but will show all gridlines. -showLabelBackdrop | Boolean | true | If true, draw a background behind the tick labels -fixedStepSize | Number | - | User defined fixed step size for the scale. If set, the scale ticks will be enumerated by multiple of stepSize, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm. -stepSize | Number | - | if defined, it can be used along with the min and the max to give a custom number of steps. See the example below. -suggestedMax | Number | - | User defined maximum number for the scale, overrides maximum value *except for if* it is lower than the maximum value. -suggestedMin | Number | - | User defined minimum number for the scale, overrides minimum value *except for if* it is higher than the minimum value. - -### Update Default Scale config - -The default configuration for a scale can be easily changed using the scale service. Pass in a partial configuration that will be merged with the current scale default configuration. - -For example, to set the minimum value of 0 for all linear scales, you would do the following. Any linear scales created after this time would now have a minimum of 0. -``` -Chart.scaleService.updateScaleDefaults('linear', { - ticks: { - min: 0 - } -}) -``` diff --git a/system/templates/js/chart-js/docs/03-Line-Chart.md b/system/templates/js/chart-js/docs/03-Line-Chart.md deleted file mode 100644 index 24b77cfe..00000000 --- a/system/templates/js/chart-js/docs/03-Line-Chart.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -title: Line Chart -anchor: line-chart ---- -### Introduction -A line chart is a way of plotting data points on a line. Often, it is used to show trend data, and the comparison of two data sets. - -
- -
- -### Example Usage -```javascript -var myLineChart = new Chart(ctx, { - type: 'line', - data: data, - options: options -}); -``` - -Alternatively a line chart can be created using syntax similar to the v1.0 syntax -```javascript -var myLineChart = Chart.Line(ctx, { - data: data, - options: options -}); -``` - -### Dataset Structure - -The following options can be included in a line chart dataset to configure options for that specific dataset. - -All point* properties can be specified as an array. If these are set to an array value, the first value applies to the first point, the second value to the second point, and so on. - -Property | Type | Usage ---- | --- | --- -data | See [data point](#line-chart-data-points) section | The data to plot in a line -label | `String` | The label for the dataset which appears in the legend and tooltips -xAxisID | `String` | The ID of the x axis to plot this dataset on -yAxisID | `String` | The ID of the y axis to plot this dataset on -fill | `Boolean` | If true, fill the area under the line -cubicInterpolationMode | `String` | Algorithm used to interpolate a smooth curve from the discrete data points. Options are 'default' and 'monotone'. The 'default' algorithm uses a custom weighted cubic interpolation, which produces pleasant curves for all types of datasets. The 'monotone' algorithm is more suited to `y = f(x)` datasets : it preserves monotonicity (or piecewise monotonicity) of the dataset being interpolated, and ensures local extremums (if any) stay at input data points. If left untouched (`undefined`), the global `options.elements.line.cubicInterpolationMode` property is used. -lineTension | `Number` | Bezier curve tension of the line. Set to 0 to draw straightlines. This option is ignored if monotone cubic interpolation is used. *Note* This was renamed from 'tension' but the old name still works. -backgroundColor | `Color` | The fill color under the line. See [Colors](#chart-configuration-colors) -borderWidth | `Number` | The width of the line in pixels -borderColor | `Color` | The color of the line. -borderCapStyle | `String` | Cap style of the line. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap) -borderDash | `Array` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash) -borderDashOffset | `Number` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) -borderJoinStyle | `String` | Line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin) -pointBorderColor | `Color or Array` | The border color for points. -pointBackgroundColor | `Color or Array` | The fill color for points -pointBorderWidth | `Number or Array` | The width of the point border in pixels -pointRadius | `Number or Array` | The radius of the point shape. If set to 0, nothing is rendered. -pointHoverRadius | `Number or Array` | The radius of the point when hovered -pointHitRadius | `Number or Array` | The pixel size of the non-displayed point that reacts to mouse events -pointHoverBackgroundColor | `Color or Array` | Point background color when hovered -pointHoverBorderColor | `Color or Array` | Point border color when hovered -pointHoverBorderWidth | `Number or Array` | Border width of point when hovered -pointStyle | `String, Array, Image, Array` | The style of point. Options are 'circle', 'triangle', 'rect', 'rectRounded', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'. If the option is an image, that image is drawn on the canvas using `drawImage`. -showLine | `Boolean` | If false, the line is not drawn for this dataset -spanGaps | `Boolean` | If true, lines will be drawn between points with no or null data -steppedLine | `Boolean` | If true, the line is shown as a stepped line and 'lineTension' will be ignored - -An example data object using these attributes is shown below. -```javascript -var data = { - labels: ["January", "February", "March", "April", "May", "June", "July"], - datasets: [ - { - label: "My First dataset", - fill: false, - lineTension: 0.1, - backgroundColor: "rgba(75,192,192,0.4)", - borderColor: "rgba(75,192,192,1)", - borderCapStyle: 'butt', - borderDash: [], - borderDashOffset: 0.0, - borderJoinStyle: 'miter', - pointBorderColor: "rgba(75,192,192,1)", - pointBackgroundColor: "#fff", - pointBorderWidth: 1, - pointHoverRadius: 5, - pointHoverBackgroundColor: "rgba(75,192,192,1)", - pointHoverBorderColor: "rgba(220,220,220,1)", - pointHoverBorderWidth: 2, - pointRadius: 1, - pointHitRadius: 10, - data: [65, 59, 80, 81, 56, 55, 40], - spanGaps: false, - } - ] -}; -``` - -The line chart usually requires an array of labels. This labels are shown on the X axis. There must be one label for each data point. More labels than datapoints are allowed, in which case the line ends at the last data point. -The data for line charts is broken up into an array of datasets. Each dataset has a colour for the fill, a colour for the line and colours for the points and strokes of the points. These colours are strings just like CSS. You can use RGBA, RGB, HEX or HSL notation. - -The label key on each dataset is optional, and can be used when generating a scale for the chart. - -When `spanGaps` is set to true, the gaps between points in sparse datasets are filled in. By default, it is off. - -### Data Points - -The data passed to the chart can be passed in two formats. The most common method is to pass the data array as an array of numbers. In this case, the `data.labels` array must be specified and must contain a label for each point or, in the case of labels to be displayed over multiple lines an array of labels (one for each line) i.e `[["June","2015"], "July"]`. - -The alternate is used for sparse datasets. Data is specified using an object containing `x` and `y` properties. This is used for scatter charts as documented below. - -### Scatter Line Charts - -Scatter line charts can be created by changing the X axis to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties. The example below creates a scatter chart with 3 points. - -```javascript -var scatterChart = new Chart(ctx, { - type: 'line', - data: { - datasets: [{ - label: 'Scatter Dataset', - data: [{ - x: -10, - y: 0 - }, { - x: 0, - y: 10 - }, { - x: 10, - y: 5 - }] - }] - }, - options: { - scales: { - xAxes: [{ - type: 'linear', - position: 'bottom' - }] - } - } -}); -``` - -### Chart Options - -These are the customisation options specific to Line charts. These options are merged with the [global chart configuration options](#chart-configuration-global-configuration), and form the options of the chart. - -Name | Type | Default | Description ---- | --- | --- | --- -showLines | Boolean | true | If false, the lines between points are not drawn -spanGaps | Boolean | false | If true, NaN data does not break the line - -You can override these for your `Chart` instance by passing a member `options` into the `Line` method. - -For example, we could have a line chart display without an X axis by doing the following. The config merge is smart enough to handle arrays so that you do not need to specify all axis settings to change one thing. - -```javascript -new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - xAxes: [{ - display: false - }] - } - } -}); -``` - -We can also change these defaults values for each Line type that is created, this object is available at `Chart.defaults.line`. - -### Stacked Charts - -Stacked area charts can be created by setting the Y axis to a stacked configuration. The following example would have stacked lines. - -```javascript -var stackedLine = new Chart(ctx, { - type: 'line', - data: data, - options: { - scales: { - yAxes: [{ - stacked: true - }] - } - } -}); -``` \ No newline at end of file diff --git a/system/templates/js/chart-js/docs/04-Bar-Chart.md b/system/templates/js/chart-js/docs/04-Bar-Chart.md deleted file mode 100644 index ef2cd3c1..00000000 --- a/system/templates/js/chart-js/docs/04-Bar-Chart.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: Bar Chart -anchor: bar-chart ---- - -### Introduction -A bar chart is a way of showing data as bars. - -It is sometimes used to show trend data, and the comparison of multiple data sets side by side. - -
- -
- -### Example Usage -```javascript -var myBarChart = new Chart(ctx, { - type: 'bar', - data: data, - options: options -}); -``` - -Or if you want horizontal bars. - -```javascript -var myBarChart = new Chart(ctx, { - type: 'horizontalBar', - data: data, - options: options -}); -``` - -### Dataset Structure -The following options can be included in a bar chart dataset to configure options for that specific dataset. - -Some properties can be specified as an array. If these are set to an array value, the first value applies to the first bar, the second value to the second bar, and so on. - -Property | Type | Usage ---- | --- | --- -data | `Array` | The data to plot as bars -label | `String` | The label for the dataset which appears in the legend and tooltips -xAxisID | `String` | The ID of the x axis to plot this dataset on -yAxisID | `String` | The ID of the y axis to plot this dataset on -backgroundColor | `Color or Array` | The fill color of the bars. See [Colors](#chart-configuration-colors) -borderColor | `Color or Array` | Bar border color -borderWidth | `Number or Array` | Border width of bar in pixels -borderSkipped | `String or Array` | Which edge to skip drawing the border for. Options are 'bottom', 'left', 'top', and 'right' -hoverBackgroundColor | `Color or Array` | Bar background color when hovered -hoverBorderColor | `Color or Array` | Bar border color when hovered -hoverBorderWidth | `Number or Array` | Border width of bar when hovered -stack | `String` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack) - -An example data object using these attributes is shown below. - -```javascript -var data = { - labels: ["January", "February", "March", "April", "May", "June", "July"], - datasets: [ - { - label: "My First dataset", - backgroundColor: [ - 'rgba(255, 99, 132, 0.2)', - 'rgba(54, 162, 235, 0.2)', - 'rgba(255, 206, 86, 0.2)', - 'rgba(75, 192, 192, 0.2)', - 'rgba(153, 102, 255, 0.2)', - 'rgba(255, 159, 64, 0.2)' - ], - borderColor: [ - 'rgba(255,99,132,1)', - 'rgba(54, 162, 235, 1)', - 'rgba(255, 206, 86, 1)', - 'rgba(75, 192, 192, 1)', - 'rgba(153, 102, 255, 1)', - 'rgba(255, 159, 64, 1)' - ], - borderWidth: 1, - data: [65, 59, 80, 81, 56, 55, 40], - } - ] -}; -``` -The bar chart has the a very similar data structure to the line chart, and has an array of datasets, each with colours and an array of data. -We have an array of labels too for display. In the example, we are showing the same data as the previous line chart example. - -### Chart Options - -These are the customisation options specific to Bar charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart. - -The default options for bar chart are defined in `Chart.defaults.bar`. - -Name | Type | Default | Description ---- |:---:| --- | --- -*hover*.mode | String | "label" | Label's hover mode. "label" is used since the x axis displays data by the index in the dataset. -scales | Object | - | - -*scales*.xAxes | Array | | The bar chart officially supports only 1 x-axis but uses an array to keep the API consistent. Use a scatter chart if you need multiple x axes. -*Options for xAxes* | | | -type | String | "Category" | As defined in [Scales](#scales-category-scale). -display | Boolean | true | If true, show the scale. -id | String | "x-axis-0" | Id of the axis so that data can bind to it -stacked | Boolean | false | If true, bars are stacked on the x-axis -barThickness | Number | | Manually set width of each bar in pixels. If not set, the bars are sized automatically. -categoryPercentage | Number | 0.8 | Percent (0-1) of the available width (the space between the gridlines for small datasets) for each data-point to use for the bars. [Read More](#bar-chart-barpercentage-vs-categorypercentage) -barPercentage | Number | 0.9 | Percent (0-1) of the available width each bar should be within the category percentage. 1.0 will take the whole category width and put the bars right next to each other. [Read More](#bar-chart-barpercentage-vs-categorypercentage) -gridLines | Object | [See Scales](#scales) | -*gridLines*.offsetGridLines | Boolean | true | If true, the bars for a particular data point fall between the grid lines. If false, the grid line will go right down the middle of the bars. -| | | -*scales*.yAxes | Array | `[{ type: "linear" }]` | -*Options for yAxes* | | | -type | String | "linear" | As defined in [Scales](#scales-linear-scale). -display | Boolean | true | If true, show the scale. -id | String | "y-axis-0" | Id of the axis so that data can bind to it. -stacked | Boolean | false | If true, bars are stacked on the y-axis -barThickness | Number | | Manually set height of each bar in pixels. If not set, the bars are sized automatically. - -You can override these for your `Chart` instance by passing a second argument into the `Bar` method as an object with the keys you want to override. - -For example, we could have a bar chart without a stroke on each bar by doing the following: - -```javascript -new Chart(ctx, { - type: "bar", - data: data, - options: { - scales: { - xAxes: [{ - stacked: true - }], - yAxes: [{ - stacked: true - }] - } - } -}); -// This will create a chart with all of the default options, merged from the global config, -// and the Bar chart defaults but this particular instance will have `stacked` set to true -// for both x and y axes. -``` - -We can also change these defaults values for each Bar type that is created, this object is available at `Chart.defaults.bar`. For horizontal bars, this object is available at `Chart.defaults.horizontalBar`. - -The default options for horizontal bar charts are defined in `Chart.defaults.horizontalBar` and are same as those of the bar chart, but with `xAxes` and `yAxes` swapped and the following additional options. - -Name | Type | Default | Description ---- |:---:| --- | --- -*Options for xAxes* | | | -position | String | "bottom" | -*Options for yAxes* | | | -position | String | "left" | - -### barPercentage vs categoryPercentage - -The following shows the relationship between the bar percentage option and the category percentage option. - -```text -// categoryPercentage: 1.0 -// barPercentage: 1.0 -Bar: | 1.0 | 1.0 | -Category: | 1.0 | -Sample: |===========| - -// categoryPercentage: 1.0 -// barPercentage: 0.5 -Bar: |.5| |.5| -Category: | 1.0 | -Sample: |==============| - -// categoryPercentage: 0.5 -// barPercentage: 1.0 -Bar: |1.||1.| -Category: | .5 | -Sample: |==============| -``` diff --git a/system/templates/js/chart-js/docs/05-Radar-Chart.md b/system/templates/js/chart-js/docs/05-Radar-Chart.md deleted file mode 100644 index 977574fa..00000000 --- a/system/templates/js/chart-js/docs/05-Radar-Chart.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -title: Radar Chart -anchor: radar-chart ---- - -### Introduction -A radar chart is a way of showing multiple data points and the variation between them. - -They are often useful for comparing the points of two or more different data sets. - -
- -
- -### Example Usage - -```javascript -var myRadarChart = new Chart(ctx, { - type: 'radar', - data: data, - options: options -}); -``` - -### Dataset Structure - -The following options can be included in a radar chart dataset to configure options for that specific dataset. - -All point* properties can be specified as an array. If these are set to an array value, the first value applies to the first point, the second value to the second point, and so on. - -Property | Type | Usage ---- | --- | --- -data | `Array` | The data to plot in a line -label | `String` | The label for the dataset which appears in the legend and tooltips -fill | `Boolean` | If true, fill the area under the line -lineTension | `Number` | Bezier curve tension of the line. Set to 0 to draw straightlines. *Note* This was renamed from 'tension' but the old name still works. -backgroundColor | `Color` | The fill color under the line. See [Colors](#chart-configuration-colors) -borderWidth | `Number` | The width of the line in pixels -borderColor | `Color` | The color of the line. -borderCapStyle | `String` | Cap style of the line. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap) -borderDash | `Array` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash) -borderDashOffset | `Number` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) -borderJoinStyle | `String` | Line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin) -pointBorderColor | `Color or Array` | The border color for points. -pointBackgroundColor | `Color or Array` | The fill color for points -pointBorderWidth | `Number or Array` | The width of the point border in pixels -pointRadius | `Number or Array` | The radius of the point shape. If set to 0, nothing is rendered. -pointHoverRadius | `Number or Array` | The radius of the point when hovered -pointHitRadius | `Number or Array` | The pixel size of the non-displayed point that reacts to mouse events -pointHoverBackgroundColor | `Color or Array` | Point background color when hovered -pointHoverBorderColor | `Color or Array` | Point border color when hovered -pointHoverBorderWidth | `Number or Array` | Border width of point when hovered -pointStyle | `String or Array` | The style of point. Options include 'circle', 'triangle', 'rect', 'rectRounded', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash' - -An example data object using these attributes is shown below. - -```javascript -var data = { - labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"], - datasets: [ - { - label: "My First dataset", - backgroundColor: "rgba(179,181,198,0.2)", - borderColor: "rgba(179,181,198,1)", - pointBackgroundColor: "rgba(179,181,198,1)", - pointBorderColor: "#fff", - pointHoverBackgroundColor: "#fff", - pointHoverBorderColor: "rgba(179,181,198,1)", - data: [65, 59, 90, 81, 56, 55, 40] - }, - { - label: "My Second dataset", - backgroundColor: "rgba(255,99,132,0.2)", - borderColor: "rgba(255,99,132,1)", - pointBackgroundColor: "rgba(255,99,132,1)", - pointBorderColor: "#fff", - pointHoverBackgroundColor: "#fff", - pointHoverBorderColor: "rgba(255,99,132,1)", - data: [28, 48, 40, 19, 96, 27, 100] - } - ] -}; -``` -For a radar chart, to provide context of what each point means, we include an array of strings that show around each point in the chart. -For the radar chart data, we have an array of datasets. Each of these is an object, with a fill colour, a stroke colour, a colour for the fill of each point, and a colour for the stroke of each point. We also have an array of data values. -The label key on each dataset is optional, and can be used when generating a scale for the chart. - - -### Chart Options - -These are the customisation options specific to Radar charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart. - -The default options for radar chart are defined in `Chart.defaults.radar`. - -Name | Type | Default | Description ---- | --- | --- | --- -scale | Object | [See Scales](#scales) and [Defaults for Radial Linear Scale](#scales-radial-linear-scale) | Options for the one scale used on the chart. Use this to style the ticks, labels, and grid lines. -*scale*.type | String |"radialLinear" | As defined in ["Radial Linear"](#scales-radial-linear-scale). -*elements*.line | Object | | Options for all line elements used on the chart, as defined in the global elements, duplicated here to show Radar chart specific defaults. -*elements.line*.lineTension | Number | 0 | Tension exhibited by lines when calculating splineCurve. Setting to 0 creates straight lines. -startAngle | Number | 0 | The number of degrees to rotate the chart clockwise. - -You can override these for your `Chart` instance by passing a second argument into the `Radar` method as an object with the keys you want to override. - -For example, we could have a radar chart without a point for each on piece of data by doing the following: - -```javascript -new Chart(ctx, { - type: "radar", - data: data, - options: { - scale: { - reverse: true, - ticks: { - beginAtZero: true - } - } - } -}); -// This will create a chart with all of the default options, merged from the global config, -// and the Radar chart defaults but this particular instance's scale will be reversed as -// well as the ticks beginning at zero. -``` - -We can also change these defaults values for each Radar type that is created, this object is available at `Chart.defaults.radar`. diff --git a/system/templates/js/chart-js/docs/06-Polar-Area-Chart.md b/system/templates/js/chart-js/docs/06-Polar-Area-Chart.md deleted file mode 100644 index 4f2d8960..00000000 --- a/system/templates/js/chart-js/docs/06-Polar-Area-Chart.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -title: Polar Area Chart -anchor: polar-area-chart ---- -### Introduction -Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value. - -This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context. - -
- -
- -### Example Usage - -```javascript -new Chart(ctx, { - data: data, - type: 'polarArea', - options: options -}); -``` - -### Dataset Structure - -The following options can be included in a polar area chart dataset to configure options for that specific dataset. - -Some properties are specified as arrays. The first value applies to the first bar, the second value to the second bar, and so on. - -Property | Type | Usage ---- | --- | --- -data | `Array` | The data to plot as arcs -label | `String` | The label for the dataset which appears in the legend and tooltips -backgroundColor | `Array` | The fill color of the arcs. See [Colors](#chart-configuration-colors) -borderColor | `Array` | Arc border color -borderWidth | `Array` | Border width of arcs in pixels -hoverBackgroundColor | `Array` | Arc background color when hovered -hoverBorderColor | `Array` | Arc border color when hovered -hoverBorderWidth | `Array` | Border width of arc when hovered - -An example data object using these attributes is shown below. - -```javascript -var data = { - datasets: [{ - data: [ - 11, - 16, - 7, - 3, - 14 - ], - backgroundColor: [ - "#FF6384", - "#4BC0C0", - "#FFCE56", - "#E7E9ED", - "#36A2EB" - ], - label: 'My dataset' // for legend - }], - labels: [ - "Red", - "Green", - "Yellow", - "Grey", - "Blue" - ] -}; -``` -As you can see, for the chart data you pass in an array of objects, with a value and a colour. The value attribute should be a number, while the color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL. - -### Chart Options - -These are the customisation options specific to Polar Area charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart. - -Name | Type | Default | Description ---- | --- | --- | --- -startAngle | Number | -0.5 * Math.PI | Sets the starting angle for the first item in a dataset -scale | Object | [See Scales](#scales) and [Defaults for Radial Linear Scale](#scales-radial-linear-scale) | Options for the one scale used on the chart. Use this to style the ticks, labels, and grid. -*scale*.type | String |"radialLinear" | As defined in ["Radial Linear"](#scales-radial-linear-scale). -*scale*.lineArc | Boolean | true | When true, lines are circular. -*animation*.animateRotate | Boolean |true | If true, will animate the rotation of the chart. -*animation*.animateScale | Boolean | true | If true, will animate scaling the chart. -*legend*.*labels*.generateLabels | Function | `function(data) {} ` | Returns labels for each the legend -*legend*.onClick | Function | function(event, legendItem) {} ` | Handles clicking an individual legend item -legendCallback | Function | `function(chart) ` | Generates the HTML legend via calls to `generateLegend` - -You can override these for your `Chart` instance by passing a second argument into the `PolarArea` method as an object with the keys you want to override. - -For example, we could have a polar area chart with a black stroke on each segment like so: - -```javascript -new Chart(ctx, { - data: data, - type: "polarArea", - options: { - elements: { - arc: { - borderColor: "#000000" - } - } - } -}); -// This will create a chart with all of the default options, merged from the global config, -// and the PolarArea chart defaults but this particular instance will have `elements.arc.borderColor` set to `"#000000"`. -``` - -We can also change these defaults values for each PolarArea type that is created, this object is available at `Chart.defaults.polarArea`. diff --git a/system/templates/js/chart-js/docs/07-Pie-Doughnut-Chart.md b/system/templates/js/chart-js/docs/07-Pie-Doughnut-Chart.md deleted file mode 100644 index 99830132..00000000 --- a/system/templates/js/chart-js/docs/07-Pie-Doughnut-Chart.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: Pie & Doughnut Charts -anchor: doughnut-pie-chart ---- -### Introduction -Pie and doughnut charts are probably the most commonly used charts there are. They are divided into segments, the arc of each segment shows the proportional value of each piece of data. - -They are excellent at showing the relational proportions between data. - -Pie and doughnut charts are effectively the same class in Chart.js, but have one different default value - their `cutoutPercentage`. This equates what percentage of the inner should be cut out. This defaults to `0` for pie charts, and `50` for doughnuts. - -They are also registered under two aliases in the `Chart` core. Other than their different default value, and different alias, they are exactly the same. - -
- -
- -
- -
-
- -### Example Usage - -```javascript -// For a pie chart -var myPieChart = new Chart(ctx,{ - type: 'pie', - data: data, - options: options -}); -``` - -```javascript -// And for a doughnut chart -var myDoughnutChart = new Chart(ctx, { - type: 'doughnut', - data: data, - options: options -}); -``` - -### Dataset Structure - -Property | Type | Usage ---- | --- | --- -data | `Array` | The data to plot as arcs -label | `String` | The label for the dataset which appears in the legend and tooltips -backgroundColor | `Array` | The fill color of the arcs. See [Colors](#chart-configuration-colors) -borderColor | `Array` | Arc border color -borderWidth | `Array` | Border width of arcs in pixels -hoverBackgroundColor | `Array` | Arc background color when hovered -hoverBorderColor | `Array` | Arc border color when hovered -hoverBorderWidth | `Array` | Border width of arc when hovered - -An example data object using these attributes is shown below. - -```javascript -var data = { - labels: [ - "Red", - "Blue", - "Yellow" - ], - datasets: [ - { - data: [300, 50, 100], - backgroundColor: [ - "#FF6384", - "#36A2EB", - "#FFCE56" - ], - hoverBackgroundColor: [ - "#FF6384", - "#36A2EB", - "#FFCE56" - ] - }] -}; -``` - -For a pie chart, datasets need to contain an array of data points. The data points should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each. You can also add an array of background colors. The color attributes should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL. - -### Chart Options - -These are the customisation options specific to Pie & Doughnut charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart. - -Name | Type | Default | Description ---- | --- | --- | --- -cutoutPercentage | Number | 50 - for doughnut, 0 - for pie | The percentage of the chart that is cut out of the middle. -rotation | Number | -0.5 * Math.PI | Starting angle to draw arcs from -circumference | Number | 2 * Math.PI | Sweep to allow arcs to cover -*animation*.animateRotate | Boolean |true | If true, will animate the rotation of the chart. -*animation*.animateScale | Boolean | false | If true, will animate scaling the Doughnut from the centre. -*legend*.*labels*.generateLabels | Function | `function(chart) {} ` | Returns a label for each item to be displayed on the legend. -*legend*.onClick | Function | function(event, legendItem) {} ` | Handles clicking an individual legend item - -You can override these for your `Chart` instance by passing a second argument into the `Doughnut` method as an object with the keys you want to override. - -For example, we could have a doughnut chart that animates by scaling out from the centre like so: - -```javascript -new Chart(ctx,{ - type:"doughnut", - options: { - animation:{ - animateScale:true - } - } -}); -// This will create a chart with all of the default options, merged from the global config, -// and the Doughnut chart defaults but this particular instance will have `animateScale` set to `true`. -``` - -We can also change these default values for each Doughnut type that is created, this object is available at `Chart.defaults.doughnut`. Pie charts also have a clone of these defaults available to change at `Chart.defaults.pie`, with the only difference being `cutoutPercentage` being set to 0. diff --git a/system/templates/js/chart-js/docs/08-Bubble-Chart.md b/system/templates/js/chart-js/docs/08-Bubble-Chart.md deleted file mode 100644 index 59b8b773..00000000 --- a/system/templates/js/chart-js/docs/08-Bubble-Chart.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Bubble Chart -anchor: bubble-chart ---- -### Introduction -A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles. - -
- -
-
- -### Example Usage - -```javascript -// For a bubble chart -var myBubbleChart = new Chart(ctx,{ - type: 'bubble', - data: data, - options: options -}); -``` - -### Dataset Structure - -Property | Type | Usage ---- | --- | --- -data | `Array` | The data to plot as bubbles. See [Data format](#bubble-chart-data-format) -label | `String` | The label for the dataset which appears in the legend and tooltips -backgroundColor | `Color Array` | The fill color of the bubbles. See [Colors](#chart-configuration-colors) -borderColor | `Color or Array` | The stroke color of the bubbles. -borderWidth | `Number or Array` | The stroke width of bubble in pixels. -hoverBackgroundColor | `Color or Array` | The fill color of the bubbles when hovered. -hoverBorderColor | `Color or Array` | The stroke color of the bubbles when hovered. -hoverBorderWidth | `Number or Array` | The stroke width of the bubbles when hovered. -hoverRadius | `Number or Array` | Additional radius to add to data radius on hover. - -An example data object using these attributes is shown below. This example creates a single dataset with 2 different bubbles. - -```javascript -var data = { - datasets: [ - { - label: 'First Dataset', - data: [ - { - x: 20, - y: 30, - r: 15 - }, - { - x: 40, - y: 10, - r: 10 - } - ], - backgroundColor:"#FF6384", - hoverBackgroundColor: "#FF6384", - }] -}; -``` - -### Data Object - -Data for the bubble chart is passed in the form of an object. The object must implement the following interface. It is important to note that the radius property, `r` is **not** scaled by the chart. It is the raw radius in pixels of the bubble that is drawn on the canvas. - -```javascript -{ - // X Value - x: , - - // Y Value - y: , - - // Radius of bubble. This is not scaled. - r: -} -``` - -### Chart Options - -The bubble chart has no unique configuration options. To configure options common to all of the bubbles, the point element options are used. - -For example, to give all bubbles a 1px wide black border, the following options would be used. - -```javascript -new Chart(ctx,{ - type:"bubble", - options: { - elements: { - points: { - borderWidth: 1, - borderColor: 'rgb(0, 0, 0)' - } - } - } -}); -``` - -We can also change the default values for the Bubble chart type. Doing so will give all bubble charts created after this point the new defaults. The default configuration for the bubble chart can be accessed at `Chart.defaults.bubble`. diff --git a/system/templates/js/chart-js/docs/09-Advanced.md b/system/templates/js/chart-js/docs/09-Advanced.md deleted file mode 100644 index 05642fca..00000000 --- a/system/templates/js/chart-js/docs/09-Advanced.md +++ /dev/null @@ -1,465 +0,0 @@ ---- -title: Advanced usage -anchor: advanced-usage ---- - - -### Prototype Methods - -For each chart, there are a set of global prototype methods on the shared `ChartType` which you may find useful. These are available on all charts created with Chart.js, but for the examples, let's use a line chart we've made. - -```javascript -// For example: -var myLineChart = new Chart(ctx, config); -``` - -#### .destroy() - -Use this to destroy any chart instances that are created. This will clean up any references stored to the chart object within Chart.js, along with any associated event listeners attached by Chart.js. -This must be called before the canvas is reused for a new chart. - -```javascript -// Destroys a specific chart instance -myLineChart.destroy(); -``` - -#### .update(duration, lazy) - -Triggers an update of the chart. This can be safely called after replacing the entire data object. This will update all scales, legends, and then re-render the chart. - -```javascript -// duration is the time for the animation of the redraw in milliseconds -// lazy is a boolean. if true, the animation can be interrupted by other animations -myLineChart.data.datasets[0].data[2] = 50; // Would update the first dataset's value of 'March' to be 50 -myLineChart.update(); // Calling update now animates the position of March from 90 to 50. -``` - -#### .reset() - -Reset the chart to it's state before the initial animation. A new animation can then be triggered using `update`. - -```javascript -myLineChart.reset(); -``` - -#### .render(duration, lazy) - -Triggers a redraw of all chart elements. Note, this does not update elements for new data. Use `.update()` in that case. - -```javascript -// duration is the time for the animation of the redraw in milliseconds -// lazy is a boolean. if true, the animation can be interrupted by other animations -myLineChart.render(duration, lazy); -``` - -#### .stop() - -Use this to stop any current animation loop. This will pause the chart during any current animation frame. Call `.render()` to re-animate. - -```javascript -// Stops the charts animation loop at its current frame -myLineChart.stop(); -// => returns 'this' for chainability -``` - -#### .resize() - -Use this to manually resize the canvas element. This is run each time the canvas container is resized, but you can call this method manually if you change the size of the canvas nodes container element. - -```javascript -// Resizes & redraws to fill its container element -myLineChart.resize(); -// => returns 'this' for chainability -``` - -#### .clear() - -Will clear the chart canvas. Used extensively internally between animation frames, but you might find it useful. - -```javascript -// Will clear the canvas that myLineChart is drawn on -myLineChart.clear(); -// => returns 'this' for chainability -``` - -#### .toBase64Image() - -This returns a base 64 encoded string of the chart in it's current state. - -```javascript -myLineChart.toBase64Image(); -// => returns png data url of the image on the canvas -``` - -#### .generateLegend() - -Returns an HTML string of a legend for that chart. The legend is generated from the `legendCallback` in the options. - -```javascript -myLineChart.generateLegend(); -// => returns HTML string of a legend for this chart -``` - -#### .getElementAtEvent(e) - -Calling `getElementAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the single element at the event position. If there are multiple items within range, only the first is returned - -```javascript -myLineChart.getElementAtEvent(e); -// => returns the first element at the event point. -``` - -#### .getElementsAtEvent(e) - -Looks for the element under the event point, then returns all elements at the same data index. This is used internally for 'label' mode highlighting. - -Calling `getElementsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the point elements that are at that the same position of that event. - -```javascript -canvas.onclick = function(evt){ - var activePoints = myLineChart.getElementsAtEvent(evt); - // => activePoints is an array of points on the canvas that are at the same position as the click event. -}; -``` - -This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application. - -#### .getDatasetAtEvent(e) - -Looks for the element under the event point, then returns all elements from that dataset. This is used internally for 'dataset' mode highlighting - -```javascript -myLineChart.getDatasetAtEvent(e); -// => returns an array of elements -``` - -#### .getDatasetMeta(index) - -Looks for the dataset that matches the current index and returns that metadata. This returned data has all of the metadata that is used to construct the chart. - -The `data` property of the metadata will contain information about each point, rectangle, etc. depending on the chart type. - -Extensive examples of usage are available in the [Chart.js tests](https://github.com/chartjs/Chart.js/tree/master/test). - -```javascript -var meta = myChart.getDatasetMeta(0); -var x = meta.data[0]._model.x -``` - -### External Tooltips - -You can enable custom tooltips in the global or chart configuration like so: - -```javascript -var myPieChart = new Chart(ctx, { - type: 'pie', - data: data, - options: { - tooltips: { - custom: function(tooltip) { - // tooltip will be false if tooltip is not visible or should be hidden - if (!tooltip) { - return; - } - - // Otherwise, tooltip will be an object with all tooltip properties like: - - // tooltip.caretSize - // tooltip.caretPadding - // tooltip.chart - // tooltip.cornerRadius - // tooltip.fillColor - // tooltip.font... - // tooltip.text - // tooltip.x - // tooltip.y - // tooltip.caretX - // tooltip.caretY - // etc... - } - } - } -}); -``` - -See `samples/tooltips/line-customTooltips.html` for examples on how to get started. - -### Writing New Scale Types - -Starting with Chart.js 2.0 scales can be individually extended. Scales should always derive from Chart.Scale. - -```javascript -var MyScale = Chart.Scale.extend({ - /* extensions ... */ -}); - -// MyScale is now derived from Chart.Scale -``` - -Once you have created your scale class, you need to register it with the global chart object so that it can be used. A default config for the scale may be provided when registering the constructor. The first parameter to the register function is a string key that is used later to identify which scale type to use for a chart. - -```javascript -Chart.scaleService.registerScaleType('myScale', MyScale, defaultConfigObject); -``` - -To use the new scale, simply pass in the string key to the config when creating a chart. - -```javascript -var lineChart = new Chart(ctx, { - data: data, - type: 'line', - options: { - scales: { - yAxes: [{ - type: 'myScale' // this is the same key that was passed to the registerScaleType function - }] - } - } -}) -``` - -#### Scale Properties - -Scale instances are given the following properties during the fitting process. - -```javascript -{ - left: Number, // left edge of the scale bounding box - right: Number, // right edge of the bounding box' - top: Number, - bottom: Number, - width: Number, // the same as right - left - height: Number, // the same as bottom - top - - // Margin on each side. Like css, this is outside the bounding box. - margins: { - left: Number, - right: Number, - top: Number, - bottom: Number, - }, - - // Amount of padding on the inside of the bounding box (like CSS) - paddingLeft: Number, - paddingRight: Number, - paddingTop: Number, - paddingBottom: Number, -} -``` - -#### Scale Interface -To work with Chart.js, custom scale types must implement the following interface. - -```javascript -{ - // Determines the data limits. Should set this.min and this.max to be the data max/min - determineDataLimits: function() {}, - - // Generate tick marks. this.chart is the chart instance. The data object can be accessed as this.chart.data - // buildTicks() should create a ticks array on the axis instance, if you intend to use any of the implementations from the base class - buildTicks: function() {}, - - // Get the value to show for the data at the given index of the the given dataset, ie this.chart.data.datasets[datasetIndex].data[index] - getLabelForIndex: function(index, datasetIndex) {}, - - // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value - // @param index: index into the ticks array - // @param includeOffset: if true, get the pixel halway between the given tick and the next - getPixelForTick: function(index, includeOffset) {}, - - // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value - // @param value : the value to get the pixel for - // @param index : index into the data array of the value - // @param datasetIndex : index of the dataset the value comes from - // @param includeOffset : if true, get the pixel halway between the given tick and the next - getPixelForValue: function(value, index, datasetIndex, includeOffset) {} - - // Get the value for a given pixel (x coordinate for horizontal axis, y coordinate for vertical axis) - // @param pixel : pixel value - getValueForPixel: function(pixel) {} -} -``` - -Optionally, the following methods may also be overwritten, but an implementation is already provided by the `Chart.Scale` base class. - -```javascript - // Transform the ticks array of the scale instance into strings. The default implementation simply calls this.options.ticks.callback(numericalTick, index, ticks); - convertTicksToLabels: function() {}, - - // Determine how much the labels will rotate by. The default implementation will only rotate labels if the scale is horizontal. - calculateTickRotation: function() {}, - - // Fits the scale into the canvas. - // this.maxWidth and this.maxHeight will tell you the maximum dimensions the scale instance can be. Scales should endeavour to be as efficient as possible with canvas space. - // this.margins is the amount of space you have on either side of your scale that you may expand in to. This is used already for calculating the best label rotation - // You must set this.minSize to be the size of your scale. It must be an object containing 2 properties: width and height. - // You must set this.width to be the width and this.height to be the height of the scale - fit: function() {}, - - // Draws the scale onto the canvas. this.(left|right|top|bottom) will have been populated to tell you the area on the canvas to draw in - // @param chartArea : an object containing four properties: left, right, top, bottom. This is the rectangle that lines, bars, etc will be drawn in. It may be used, for example, to draw grid lines. - draw: function(chartArea) {}, -``` - -The Core.Scale base class also has some utility functions that you may find useful. -```javascript -{ - // Returns true if the scale instance is horizontal - isHorizontal: function() {}, - - // Get the correct value from the value from this.chart.data.datasets[x].data[] - // If dataValue is an object, returns .x or .y depending on the return of isHorizontal() - // If the value is undefined, returns NaN - // Otherwise returns the value. - // Note that in all cases, the returned value is not guaranteed to be a Number - getRightValue: function(dataValue) {}, -} -``` - -### Writing New Chart Types - -Chart.js 2.0 introduces the concept of controllers for each dataset. Like scales, new controllers can be written as needed. - -```javascript -Chart.controllers.MyType = Chart.DatasetController.extend({ - -}); - - -// Now we can create a new instance of our chart, using the Chart.js API -new Chart(ctx, { - // this is the string the constructor was registered at, ie Chart.controllers.MyType - type: 'MyType', - data: data, - options: options -}); -``` - -#### Dataset Controller Interface - -Dataset controllers must implement the following interface. - -```javascript -{ - // Create elements for each piece of data in the dataset. Store elements in an array on the dataset as dataset.metaData - addElements: function() {}, - - // Create a single element for the data at the given index and reset its state - addElementAndReset: function(index) {}, - - // Draw the representation of the dataset - // @param ease : if specified, this number represents how far to transition elements. See the implementation of draw() in any of the provided controllers to see how this should be used - draw: function(ease) {}, - - // Remove hover styling from the given element - removeHoverStyle: function(element) {}, - - // Add hover styling to the given element - setHoverStyle: function(element) {}, - - // Update the elements in response to new data - // @param reset : if true, put the elements into a reset state so they can animate to their final values - update: function(reset) {}, -} -``` - -The following methods may optionally be overridden by derived dataset controllers -```javascript -{ - // Initializes the controller - initialize: function(chart, datasetIndex) {}, - - // Ensures that the dataset represented by this controller is linked to a scale. Overridden to helpers.noop in the polar area and doughnut controllers as these - // chart types using a single scale - linkScales: function() {}, - - // Called by the main chart controller when an update is triggered. The default implementation handles the number of data points changing and creating elements appropriately. - buildOrUpdateElements: function() {} -} -``` - -### Extending Existing Chart Types - -Extending or replacing an existing controller type is easy. Simply replace the constructor for one of the built in types with your own. - -The built in controller types are: -* `Chart.controllers.line` -* `Chart.controllers.bar` -* `Chart.controllers.radar` -* `Chart.controllers.doughnut` -* `Chart.controllers.polarArea` -* `Chart.controllers.bubble` - -#### Bar Controller -The bar controller has a special property that you should be aware of. To correctly calculate the width of a bar, the controller must determine the number of datasets that map to bars. To do this, the bar controller attaches a property `bar` to the dataset during initialization. If you are creating a replacement or updated bar controller, you should do the same. This will ensure that charts with regular bars and your new derived bars will work seamlessly. - -### Creating Plugins - -Starting with v2.1.0, you can create plugins for chart.js. To register your plugin, simply call `Chart.plugins.register` and pass your plugin in. -Plugins will be called at the following times -* Start of initialization -* End of initialization -* Start of update -* After the chart scales have calculated -* Start of datasets update -* End of datasets update -* End of update (before render occurs) -* Start of draw -* End of draw -* Before datasets draw -* After datasets draw -* Resize -* Before an animation is started -* When an event occurs on the canvas (mousemove, click, etc). This requires the `options.events` property handled - -Plugins should implement the `IPlugin` interface: -```javascript -{ - beforeInit: function(chartInstance) { }, - afterInit: function(chartInstance) { }, - - resize: function(chartInstance, newChartSize) { }, - - beforeUpdate: function(chartInstance) { }, - afterScaleUpdate: function(chartInstance) { } - beforeDatasetsUpdate: function(chartInstance) { } - afterDatasetsUpdate: function(chartInstance) { } - afterUpdate: function(chartInstance) { }, - - // This is called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw - // to do something on each animation frame - beforeRender: function(chartInstance) { }, - - // Easing is for animation - beforeDraw: function(chartInstance, easing) { }, - afterDraw: function(chartInstance, easing) { }, - // Before the datasets are drawn but after scales are drawn - beforeDatasetsDraw: function(chartInstance, easing) { }, - afterDatasetsDraw: function(chartInstance, easing) { }, - - destroy: function(chartInstance) { } - - // Called when an event occurs on the chart - beforeEvent: function(chartInstance, event) {} - afterEvent: function(chartInstance, event) {} -} -``` - -### Building Chart.js - -Chart.js uses gulp to build the library into a single JavaScript file. - -Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following: - -```bash -npm install -npm install -g gulp -``` - -This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner gulp. - -Now, we can run the `gulp build` task. - -```bash -gulp build -``` diff --git a/system/templates/js/chart-js/docs/10-Notes.md b/system/templates/js/chart-js/docs/10-Notes.md deleted file mode 100644 index 451a8a8c..00000000 --- a/system/templates/js/chart-js/docs/10-Notes.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: Notes -anchor: notes ---- -### Previous versions - -Version 2 has a completely different API than earlier versions. - -Most earlier version options have current equivalents or are the same. - -Please use the documentation that is available on [chartjs.org](http://www.chartjs.org/docs/) for the current version of Chart.js. - -Please note - documentation for previous versions are available on the GitHub repo. - -- [1.x Documentation](https://github.com/chartjs/Chart.js/tree/v1.1.1/docs) - -### Browser support - -Chart.js offers support for all browsers where canvas is supported. - -Browser support for the canvas element is available in all modern & major mobile browsers (http://caniuse.com/#feat=canvas). - -Thanks to BrowserStack for allowing our team to test on thousands of browsers. - - -### Bugs & issues - -Please report these on the GitHub page - at github.com/chartjs/Chart.js. If you could include a link to a simple jsbin or similar to demonstrate the issue, that'd be really helpful. - - -### Contributing - -New contributions to the library are welcome, but we ask that you please follow these guidelines: - -- Use tabs for indentation, not spaces. -- Only change the individual files in `/src`. -- Check that your code will pass `eslint` code standards, `gulp lint` will run this for you. -- Check that your code will pass tests, `gulp test` will run tests for you. -- Keep pull requests concise, and document new functionality in the relevant `.md` file. -- Consider whether your changes are useful for all users, or if creating a Chart.js plugin would be more appropriate. - -### License - -Chart.js is open source and available under the MIT license. - -### Charting Library Comparison - -Library Features - -| Feature | Chart.js | D3 | HighCharts | Chartist | -| ------- | -------- | --- | ---------- | -------- | -| Completely Free | ✓ | ✓ | | ✓ | -| Canvas | ✓ | | | | -| SVG | | ✓ | ✓ | ✓ | -| Built-in Charts | ✓ | | ✓ | ✓ | -| 8+ Chart Types | ✓ | ✓ | ✓ | | -| Extendable to Custom Charts | ✓ | ✓ | | | -| Supports Modern Browsers | ✓ | ✓ | ✓ | ✓ | -| Extensive Documentation | ✓ | ✓ | ✓ | ✓ | -| Open Source | ✓ | ✓ | ✓ | ✓ | - -Built in Chart Types - -| Type | Chart.js | HighCharts | Chartist | -| ---- | -------- | ---------- | -------- | -| Combined Types | ✓ | ✓ | | -| Line | ✓ | ✓ | ✓ | -| Bar | ✓ | ✓ | ✓ | -| Horizontal Bar | ✓ | ✓ | ✓ | -| Pie/Doughnut | ✓ | ✓ | ✓ | -| Polar Area | ✓ | ✓ | | -| Radar | ✓ | | | -| Scatter | ✓ | ✓ | ✓ | -| Bubble | ✓ | | | -| Gauges | | ✓ | | -| Maps (Heat/Tree/etc.) | | ✓ | | - -### Popular Plugins - -There are many plugins that add additional functionality to Chart.js. Some particularly notable ones are listed here. In addition, many plugins can be found on the [Chart.js GitHub organization](https://github.com/chartjs). - - - chartjs-plugin-annotation.js - Draw lines and boxes on chart area - - chartjs-plugin-deferred.js - Defer initial chart update until chart scrolls into viewport - - chartjs-plugin-draggable.js - Makes select chart elements draggable with the mouse - - chartjs-plugin-zoom.js - Enable zooming and panning on charts - - Chart.BarFunnel.js - Adds a bar funnel chart type - - Chart.LinearGauge.js - Adds a linear gauge chart type - - Chart.Smith.js - Adds a smith chart type - -### Popular Extensions - -There are many extensions which are available for use with popular frameworks. Some particularly notable ones are listed here. - -#### Angular - - angular-chart.js - - tc-angular-chartjs - - angular-chartjs - - Angular Chart-js Directive - -#### React - - react-chartjs2 - - react-chartjs-2 - -#### Django - - Django JChart - - Django Chartjs - -#### Ruby on Rails - - chartjs-ror - -#### Laravel - - laravel-chartjs - -#### Vue.js - - vue-chartjs diff --git a/system/templates/js/chart-js/docs/Chart.js b/system/templates/js/chart-js/docs/Chart.js deleted file mode 100755 index a25acef1..00000000 --- a/system/templates/js/chart-js/docs/Chart.js +++ /dev/null @@ -1,1443 +0,0 @@ -/*! - * Chart.js - * http://chartjs.org/ - * - * Copyright 2013 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ - -//Define the global Chart Variable as a class. -var Chart = function(context){ - - var chart = this; - - - //Easing functions adapted from Robert Penner's easing equations - //http://www.robertpenner.com/easing/ - - var animationOptions = { - linear : function (t){ - return t; - }, - easeInQuad: function (t) { - return t*t; - }, - easeOutQuad: function (t) { - return -1 *t*(t-2); - }, - easeInOutQuad: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t; - return -1/2 * ((--t)*(t-2) - 1); - }, - easeInCubic: function (t) { - return t*t*t; - }, - easeOutCubic: function (t) { - return 1*((t=t/1-1)*t*t + 1); - }, - easeInOutCubic: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t*t; - return 1/2*((t-=2)*t*t + 2); - }, - easeInQuart: function (t) { - return t*t*t*t; - }, - easeOutQuart: function (t) { - return -1 * ((t=t/1-1)*t*t*t - 1); - }, - easeInOutQuart: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t*t*t; - return -1/2 * ((t-=2)*t*t*t - 2); - }, - easeInQuint: function (t) { - return 1*(t/=1)*t*t*t*t; - }, - easeOutQuint: function (t) { - return 1*((t=t/1-1)*t*t*t*t + 1); - }, - easeInOutQuint: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t*t*t*t; - return 1/2*((t-=2)*t*t*t*t + 2); - }, - easeInSine: function (t) { - return -1 * Math.cos(t/1 * (Math.PI/2)) + 1; - }, - easeOutSine: function (t) { - return 1 * Math.sin(t/1 * (Math.PI/2)); - }, - easeInOutSine: function (t) { - return -1/2 * (Math.cos(Math.PI*t/1) - 1); - }, - easeInExpo: function (t) { - return (t==0) ? 1 : 1 * Math.pow(2, 10 * (t/1 - 1)); - }, - easeOutExpo: function (t) { - return (t==1) ? 1 : 1 * (-Math.pow(2, -10 * t/1) + 1); - }, - easeInOutExpo: function (t) { - if (t==0) return 0; - if (t==1) return 1; - if ((t/=1/2) < 1) return 1/2 * Math.pow(2, 10 * (t - 1)); - return 1/2 * (-Math.pow(2, -10 * --t) + 2); - }, - easeInCirc: function (t) { - if (t>=1) return t; - return -1 * (Math.sqrt(1 - (t/=1)*t) - 1); - }, - easeOutCirc: function (t) { - return 1 * Math.sqrt(1 - (t=t/1-1)*t); - }, - easeInOutCirc: function (t) { - if ((t/=1/2) < 1) return -1/2 * (Math.sqrt(1 - t*t) - 1); - return 1/2 * (Math.sqrt(1 - (t-=2)*t) + 1); - }, - easeInElastic: function (t) { - var s=1.70158;var p=0;var a=1; - if (t==0) return 0; if ((t/=1)==1) return 1; if (!p) p=1*.3; - if (a < Math.abs(1)) { a=1; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (1/a); - return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )); - }, - easeOutElastic: function (t) { - var s=1.70158;var p=0;var a=1; - if (t==0) return 0; if ((t/=1)==1) return 1; if (!p) p=1*.3; - if (a < Math.abs(1)) { a=1; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (1/a); - return a*Math.pow(2,-10*t) * Math.sin( (t*1-s)*(2*Math.PI)/p ) + 1; - }, - easeInOutElastic: function (t) { - var s=1.70158;var p=0;var a=1; - if (t==0) return 0; if ((t/=1/2)==2) return 1; if (!p) p=1*(.3*1.5); - if (a < Math.abs(1)) { a=1; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (1/a); - if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )); - return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )*.5 + 1; - }, - easeInBack: function (t) { - var s = 1.70158; - return 1*(t/=1)*t*((s+1)*t - s); - }, - easeOutBack: function (t) { - var s = 1.70158; - return 1*((t=t/1-1)*t*((s+1)*t + s) + 1); - }, - easeInOutBack: function (t) { - var s = 1.70158; - if ((t/=1/2) < 1) return 1/2*(t*t*(((s*=(1.525))+1)*t - s)); - return 1/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2); - }, - easeInBounce: function (t) { - return 1 - animationOptions.easeOutBounce (1-t); - }, - easeOutBounce: function (t) { - if ((t/=1) < (1/2.75)) { - return 1*(7.5625*t*t); - } else if (t < (2/2.75)) { - return 1*(7.5625*(t-=(1.5/2.75))*t + .75); - } else if (t < (2.5/2.75)) { - return 1*(7.5625*(t-=(2.25/2.75))*t + .9375); - } else { - return 1*(7.5625*(t-=(2.625/2.75))*t + .984375); - } - }, - easeInOutBounce: function (t) { - if (t < 1/2) return animationOptions.easeInBounce (t*2) * .5; - return animationOptions.easeOutBounce (t*2-1) * .5 + 1*.5; - } - }; - - //Variables global to the chart - var width = context.canvas.width; - var height = context.canvas.height; - - - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - if (window.devicePixelRatio) { - context.canvas.style.width = width + "px"; - context.canvas.style.height = height + "px"; - context.canvas.height = height * window.devicePixelRatio; - context.canvas.width = width * window.devicePixelRatio; - context.scale(window.devicePixelRatio, window.devicePixelRatio); - } - - this.PolarArea = function(data,options){ - - chart.PolarArea.defaults = { - scaleOverlay : true, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleShowLine : true, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : true, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowLabelBackdrop : true, - scaleBackdropColor : "rgba(255,255,255,0.75)", - scaleBackdropPaddingY : 2, - scaleBackdropPaddingX : 2, - segmentShowStroke : true, - segmentStrokeColor : "#fff", - segmentStrokeWidth : 2, - animation : true, - animationSteps : 100, - animationEasing : "easeOutBounce", - animateRotate : true, - animateScale : false, - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.PolarArea.defaults,options) : chart.PolarArea.defaults; - - return new PolarArea(data,config,context); - }; - - this.Radar = function(data,options){ - - chart.Radar.defaults = { - scaleOverlay : false, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleShowLine : true, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : false, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowLabelBackdrop : true, - scaleBackdropColor : "rgba(255,255,255,0.75)", - scaleBackdropPaddingY : 2, - scaleBackdropPaddingX : 2, - angleShowLineOut : true, - angleLineColor : "rgba(0,0,0,.1)", - angleLineWidth : 1, - pointLabelFontFamily : "'Arial'", - pointLabelFontStyle : "normal", - pointLabelFontSize : 12, - pointLabelFontColor : "#666", - pointDot : true, - pointDotRadius : 3, - pointDotStrokeWidth : 1, - datasetStroke : true, - datasetStrokeWidth : 2, - datasetFill : true, - animation : true, - animationSteps : 60, - animationEasing : "easeOutQuart", - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.Radar.defaults,options) : chart.Radar.defaults; - - return new Radar(data,config,context); - }; - - this.Pie = function(data,options){ - chart.Pie.defaults = { - segmentShowStroke : true, - segmentStrokeColor : "#fff", - segmentStrokeWidth : 2, - animation : true, - animationSteps : 100, - animationEasing : "easeOutBounce", - animateRotate : true, - animateScale : false, - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.Pie.defaults,options) : chart.Pie.defaults; - - return new Pie(data,config,context); - }; - - this.Doughnut = function(data,options){ - - chart.Doughnut.defaults = { - segmentShowStroke : true, - segmentStrokeColor : "#fff", - segmentStrokeWidth : 2, - percentageInnerCutout : 50, - animation : true, - animationSteps : 100, - animationEasing : "easeOutBounce", - animateRotate : true, - animateScale : false, - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.Doughnut.defaults,options) : chart.Doughnut.defaults; - - return new Doughnut(data,config,context); - - }; - - this.Line = function(data,options){ - - chart.Line.defaults = { - scaleOverlay : false, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : true, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowGridLines : true, - scaleGridLineColor : "rgba(0,0,0,.05)", - scaleGridLineWidth : 1, - bezierCurve : true, - pointDot : true, - pointDotRadius : 4, - pointDotStrokeWidth : 2, - datasetStroke : true, - datasetStrokeWidth : 2, - datasetFill : true, - animation : true, - animationSteps : 60, - animationEasing : "easeOutQuart", - onAnimationComplete : null - }; - var config = (options) ? mergeChartConfig(chart.Line.defaults,options) : chart.Line.defaults; - - return new Line(data,config,context); - } - - this.Bar = function(data,options){ - chart.Bar.defaults = { - scaleOverlay : false, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : true, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowGridLines : true, - scaleGridLineColor : "rgba(0,0,0,.05)", - scaleGridLineWidth : 1, - barShowStroke : true, - barStrokeWidth : 2, - barValueSpacing : 5, - barDatasetSpacing : 1, - animation : true, - animationSteps : 60, - animationEasing : "easeOutQuart", - onAnimationComplete : null - }; - var config = (options) ? mergeChartConfig(chart.Bar.defaults,options) : chart.Bar.defaults; - - return new Bar(data,config,context); - } - - var clear = function(c){ - c.clearRect(0, 0, width, height); - }; - - var PolarArea = function(data,config,ctx){ - var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString; - - - calculateDrawingSizes(); - - valueBounds = getValueBounds(); - - labelTemplateString = (config.scaleShowLabels)? config.scaleLabel : null; - - //Check and set the scale - if (!config.scaleOverride){ - - calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString); - } - else { - calculatedScale = { - steps : config.scaleSteps, - stepValue : config.scaleStepWidth, - graphMin : config.scaleStartValue, - labels : [] - } - for (var i=0; i upperValue) {upperValue = data[i].value;} - if (data[i].value < lowerValue) {lowerValue = data[i].value;} - }; - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - } - - var Radar = function (data,config,ctx) { - var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString; - - //If no labels are defined set to an empty array, so referencing length for looping doesn't blow up. - if (!data.labels) data.labels = []; - - calculateDrawingSizes(); - - var valueBounds = getValueBounds(); - - labelTemplateString = (config.scaleShowLabels)? config.scaleLabel : null; - - //Check and set the scale - if (!config.scaleOverride){ - - calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString); - } - else { - calculatedScale = { - steps : config.scaleSteps, - stepValue : config.scaleStepWidth, - graphMin : config.scaleStartValue, - labels : [] - } - for (var i=0; i Math.PI){ - ctx.textAlign = "right"; - } - else{ - ctx.textAlign = "left"; - } - - ctx.textBaseline = "middle"; - - ctx.fillText(data.labels[k],opposite,-adjacent); - - } - ctx.restore(); - }; - function calculateDrawingSizes(){ - maxSize = (Min([width,height])/2); - - labelHeight = config.scaleFontSize*2; - - var labelLength = 0; - for (var i=0; ilabelLength) labelLength = textMeasurement; - } - - //Figure out whats the largest - the height of the text or the width of what's there, and minus it from the maximum usable size. - maxSize -= Max([labelLength,((config.pointLabelFontSize/2)*1.5)]); - - maxSize -= config.pointLabelFontSize; - maxSize = CapValue(maxSize, null, 0); - scaleHeight = maxSize; - //If the label height is less than 5, set it to 5 so we don't have lines on top of each other. - labelHeight = Default(labelHeight,5); - }; - function getValueBounds() { - var upperValue = Number.MIN_VALUE; - var lowerValue = Number.MAX_VALUE; - - for (var i=0; i upperValue){upperValue = data.datasets[i].data[j]} - if (data.datasets[i].data[j] < lowerValue){lowerValue = data.datasets[i].data[j]} - } - } - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - } - - var Pie = function(data,config,ctx){ - var segmentTotal = 0; - - //In case we have a canvas that is not a square. Minus 5 pixels as padding round the edge. - var pieRadius = Min([height/2,width/2]) - 5; - - for (var i=0; i 0){ - ctx.save(); - ctx.textAlign = "right"; - } - else{ - ctx.textAlign = "center"; - } - ctx.fillStyle = config.scaleFontColor; - for (var i=0; i 0){ - ctx.translate(yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize); - ctx.rotate(-(rotateLabels * (Math.PI/180))); - ctx.fillText(data.labels[i], 0,0); - ctx.restore(); - } - - else{ - ctx.fillText(data.labels[i], yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize+3); - } - - ctx.beginPath(); - ctx.moveTo(yAxisPosX + i * valueHop, xAxisPosY+3); - - //Check i isnt 0, so we dont go over the Y axis twice. - if(config.scaleShowGridLines && i>0){ - ctx.lineWidth = config.scaleGridLineWidth; - ctx.strokeStyle = config.scaleGridLineColor; - ctx.lineTo(yAxisPosX + i * valueHop, 5); - } - else{ - ctx.lineTo(yAxisPosX + i * valueHop, xAxisPosY+3); - } - ctx.stroke(); - } - - //Y axis - ctx.lineWidth = config.scaleLineWidth; - ctx.strokeStyle = config.scaleLineColor; - ctx.beginPath(); - ctx.moveTo(yAxisPosX,xAxisPosY+5); - ctx.lineTo(yAxisPosX,5); - ctx.stroke(); - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - for (var j=0; j longestText)? measuredText : longestText; - } - //Add a little extra padding from the y axis - longestText +=10; - } - xAxisLength = width - longestText - widestXLabel; - valueHop = Math.floor(xAxisLength/(data.labels.length-1)); - - yAxisPosX = width-widestXLabel/2-xAxisLength; - xAxisPosY = scaleHeight + config.scaleFontSize/2; - } - function calculateDrawingSizes(){ - maxSize = height; - - //Need to check the X axis first - measure the length of each text metric, and figure out if we need to rotate by 45 degrees. - ctx.font = config.scaleFontStyle + " " + config.scaleFontSize+"px " + config.scaleFontFamily; - widestXLabel = 1; - for (var i=0; i widestXLabel)? textLength : widestXLabel; - } - if (width/data.labels.length < widestXLabel){ - rotateLabels = 45; - if (width/data.labels.length < Math.cos(rotateLabels) * widestXLabel){ - rotateLabels = 90; - maxSize -= widestXLabel; - } - else{ - maxSize -= Math.sin(rotateLabels) * widestXLabel; - } - } - else{ - maxSize -= config.scaleFontSize; - } - - //Add a little padding between the x line and the text - maxSize -= 5; - - - labelHeight = config.scaleFontSize; - - maxSize -= labelHeight; - //Set 5 pixels greater than the font size to allow for a little padding from the X axis. - - scaleHeight = maxSize; - - //Then get the area above we can safely draw on. - - } - function getValueBounds() { - var upperValue = Number.MIN_VALUE; - var lowerValue = Number.MAX_VALUE; - for (var i=0; i upperValue) { upperValue = data.datasets[i].data[j] }; - if ( data.datasets[i].data[j] < lowerValue) { lowerValue = data.datasets[i].data[j] }; - } - }; - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - - - } - - var Bar = function(data,config,ctx){ - var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString, valueHop,widestXLabel, xAxisLength,yAxisPosX,xAxisPosY,barWidth, rotateLabels = 0; - - calculateDrawingSizes(); - - valueBounds = getValueBounds(); - //Check and set the scale - labelTemplateString = (config.scaleShowLabels)? config.scaleLabel : ""; - if (!config.scaleOverride){ - - calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString); - } - else { - calculatedScale = { - steps : config.scaleSteps, - stepValue : config.scaleStepWidth, - graphMin : config.scaleStartValue, - labels : [] - } - for (var i=0; i 0){ - ctx.save(); - ctx.textAlign = "right"; - } - else{ - ctx.textAlign = "center"; - } - ctx.fillStyle = config.scaleFontColor; - for (var i=0; i 0){ - ctx.translate(yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize); - ctx.rotate(-(rotateLabels * (Math.PI/180))); - ctx.fillText(data.labels[i], 0,0); - ctx.restore(); - } - - else{ - ctx.fillText(data.labels[i], yAxisPosX + i*valueHop + valueHop/2,xAxisPosY + config.scaleFontSize+3); - } - - ctx.beginPath(); - ctx.moveTo(yAxisPosX + (i+1) * valueHop, xAxisPosY+3); - - //Check i isnt 0, so we dont go over the Y axis twice. - ctx.lineWidth = config.scaleGridLineWidth; - ctx.strokeStyle = config.scaleGridLineColor; - ctx.lineTo(yAxisPosX + (i+1) * valueHop, 5); - ctx.stroke(); - } - - //Y axis - ctx.lineWidth = config.scaleLineWidth; - ctx.strokeStyle = config.scaleLineColor; - ctx.beginPath(); - ctx.moveTo(yAxisPosX,xAxisPosY+5); - ctx.lineTo(yAxisPosX,5); - ctx.stroke(); - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - for (var j=0; j longestText)? measuredText : longestText; - } - //Add a little extra padding from the y axis - longestText +=10; - } - xAxisLength = width - longestText - widestXLabel; - valueHop = Math.floor(xAxisLength/(data.labels.length)); - - barWidth = (valueHop - config.scaleGridLineWidth*2 - (config.barValueSpacing*2) - (config.barDatasetSpacing*data.datasets.length-1) - ((config.barStrokeWidth/2)*data.datasets.length-1))/data.datasets.length; - - yAxisPosX = width-widestXLabel/2-xAxisLength; - xAxisPosY = scaleHeight + config.scaleFontSize/2; - } - function calculateDrawingSizes(){ - maxSize = height; - - //Need to check the X axis first - measure the length of each text metric, and figure out if we need to rotate by 45 degrees. - ctx.font = config.scaleFontStyle + " " + config.scaleFontSize+"px " + config.scaleFontFamily; - widestXLabel = 1; - for (var i=0; i widestXLabel)? textLength : widestXLabel; - } - if (width/data.labels.length < widestXLabel){ - rotateLabels = 45; - if (width/data.labels.length < Math.cos(rotateLabels) * widestXLabel){ - rotateLabels = 90; - maxSize -= widestXLabel; - } - else{ - maxSize -= Math.sin(rotateLabels) * widestXLabel; - } - } - else{ - maxSize -= config.scaleFontSize; - } - - //Add a little padding between the x line and the text - maxSize -= 5; - - - labelHeight = config.scaleFontSize; - - maxSize -= labelHeight; - //Set 5 pixels greater than the font size to allow for a little padding from the X axis. - - scaleHeight = maxSize; - - //Then get the area above we can safely draw on. - - } - function getValueBounds() { - var upperValue = Number.MIN_VALUE; - var lowerValue = Number.MAX_VALUE; - for (var i=0; i upperValue) { upperValue = data.datasets[i].data[j] }; - if ( data.datasets[i].data[j] < lowerValue) { lowerValue = data.datasets[i].data[j] }; - } - }; - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - } - - function calculateOffset(val,calculatedScale,scaleHop){ - var outerValue = calculatedScale.steps * calculatedScale.stepValue; - var adjustedValue = val - calculatedScale.graphMin; - var scalingFactor = CapValue(adjustedValue/outerValue,1,0); - return (scaleHop*calculatedScale.steps) * scalingFactor; - } - - function animationLoop(config,drawScale,drawData,ctx){ - var animFrameAmount = (config.animation)? 1/CapValue(config.animationSteps,Number.MAX_VALUE,1) : 1, - easingFunction = animationOptions[config.animationEasing], - percentAnimComplete =(config.animation)? 0 : 1; - - - - if (typeof drawScale !== "function") drawScale = function(){}; - - requestAnimFrame(animLoop); - - function animateFrame(){ - var easeAdjustedAnimationPercent =(config.animation)? CapValue(easingFunction(percentAnimComplete),null,0) : 1; - clear(ctx); - if(config.scaleOverlay){ - drawData(easeAdjustedAnimationPercent); - drawScale(); - } else { - drawScale(); - drawData(easeAdjustedAnimationPercent); - } - } - function animLoop(){ - //We need to check if the animation is incomplete (less than 1), or complete (1). - percentAnimComplete += animFrameAmount; - animateFrame(); - //Stop the loop continuing forever - if (percentAnimComplete <= 1){ - requestAnimFrame(animLoop); - } - else{ - if (typeof config.onAnimationComplete == "function") config.onAnimationComplete(); - } - - } - - } - - //Declare global functions to be called within this namespace here. - - - // shim layer with setTimeout fallback - var requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - window.setTimeout(callback, 1000 / 60); - }; - })(); - - function calculateScale(drawingHeight,maxSteps,minSteps,maxValue,minValue,labelTemplateString){ - var graphMin,graphMax,graphRange,stepValue,numberOfSteps,valueRange,rangeOrderOfMagnitude,decimalNum; - - valueRange = maxValue - minValue; - - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange); - - graphMin = Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); - - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); - - graphRange = graphMax - graphMin; - - stepValue = Math.pow(10, rangeOrderOfMagnitude); - - numberOfSteps = Math.round(graphRange / stepValue); - - //Compare number of steps to the max and min for that size graph, and add in half steps if need be. - while(numberOfSteps < minSteps || numberOfSteps > maxSteps) { - if (numberOfSteps < minSteps){ - stepValue /= 2; - numberOfSteps = Math.round(graphRange/stepValue); - } - else{ - stepValue *=2; - numberOfSteps = Math.round(graphRange/stepValue); - } - }; - - - - //Create an array of all the labels by interpolating the string. - - var labels = []; - - if(labelTemplateString){ - //Fix floating point errors by setting to fixed the on the same decimal as the stepValue. - for (var i=1; i maxValue ) { - return maxValue; - } - } - if(isNumber(minValue)){ - if ( valueToCap < minValue ){ - return minValue; - } - } - return valueToCap; - } - function getDecimalPlaces (num){ - var numberOfDecimalPlaces; - if (num%1!=0){ - return num.toString().split(".")[1].length - } - else{ - return 0; - } - - } - - function mergeChartConfig(defaults,userDefined){ - var returnObj = {}; - for (var attrname in defaults) { returnObj[attrname] = defaults[attrname]; } - for (var attrname in userDefined) { returnObj[attrname] = userDefined[attrname]; } - return returnObj; - } - - //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/ - var cache = {}; - - function tmpl(str, data){ - // Figure out if we're getting a template, or if we need to - // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] || - tmpl(document.getElementById(str).innerHTML) : - - // Generate a reusable function that will serve as a template - // generator (and which will be cached). - new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + - - // Introduce the data as local variables using with(){} - "with(obj){p.push('" + - - // Convert the template into pure JavaScript - str - .replace(/[\r\t\n]/g, " ") - .split("<%").join("\t") - .replace(/((^|%>)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") - + "');}return p.join('');"); - - // Provide some basic currying to the user - return data ? fn( data ) : fn; - }; -} - - - diff --git a/system/templates/js/chart-js/docs/index.html b/system/templates/js/chart-js/docs/index.html deleted file mode 100755 index ef6f522c..00000000 --- a/system/templates/js/chart-js/docs/index.html +++ /dev/null @@ -1,766 +0,0 @@ - - - - Chart.js Documentation - - - - - - - - -
-
-
-
- - -
-

Chart.js Documentation

-

Everything you need to know to create great looking charts using Chart.js

-
-

Getting started

-

Include Chart.js

-

First we need to include the Chart.js library on the page. The library occupies a global variable of Chart.

-
<script src="Chart.js"></script>
-

Creating a chart

-

To create a chart, we need to instantiate the Chart class. To do this, we need to pass in the 2d context of where we want to draw the chart. Here's an example.

-
<canvas id="myChart" width="400" height="400"></canvas>
-
//Get the context of the canvas element we want to select
-var ctx = document.getElementById("myChart").getContext("2d");
-var myNewChart = new Chart(ctx).PolarArea(data);
-

We can also get the context of our canvas with jQuery. To do this, we need to get the DOM node out of the jQuery collection, and call the getContext("2d") method on that.

-
//Get context with jQuery - using jQuery's .get() method.
-var ctx = $("#myChart").get(0).getContext("2d");
-//This will get the first returned node in the jQuery collection.
-var myNewChart = new Chart(ctx);
-

After we've instantiated the Chart class on the canvas we want to draw on, Chart.js will handle the scaling for retina displays.

-

With the Chart class set up, we can go on to create one of the charts Chart.js has available. In the example below, we would be drawing a Polar area chart.

-
new Chart(ctx).PolarArea(data,options);
-

We call a method of the name of the chart we want to create. We pass in the data for that chart type, and the options for that chart as parameters. Chart.js will merge the options you pass in with the default options for that chart type.

-
- -
-

Line chart

-

Introduction

-

A line chart is a way of plotting data points on a line.

-

Often, it is used to show trend data, and the comparison of two data sets.

-

Example usage

- -
new Chart(ctx).Line(data,options);
-

Data structure

-
var data = {
-	labels : ["January","February","March","April","May","June","July"],
-	datasets : [
-		{
-			fillColor : "rgba(220,220,220,0.5)",
-			strokeColor : "rgba(220,220,220,1)",
-			pointColor : "rgba(220,220,220,1)",
-			pointStrokeColor : "#fff",
-			data : [65,59,90,81,56,55,40]
-		},
-		{
-			fillColor : "rgba(151,187,205,0.5)",
-			strokeColor : "rgba(151,187,205,1)",
-			pointColor : "rgba(151,187,205,1)",
-			pointStrokeColor : "#fff",
-			data : [28,48,40,19,96,27,100]
-		}
-	]
-}
-

The line chart requires an array of labels for each of the data points. This is show on the X axis.

-

The data for line charts is broken up into an array of datasets. Each dataset has a colour for the fill, a colour for the line and colours for the points and strokes of the points. These colours are strings just like CSS. You can use RGBA, RGB, HEX or HSL notation.

- -

Chart options

-
Line.defaults = {
-				
-	//Boolean - If we show the scale above the chart data			
-	scaleOverlay : false,
-	
-	//Boolean - If we want to override with a hard coded scale
-	scaleOverride : false,
-	
-	//** Required if scaleOverride is true **
-	//Number - The number of steps in a hard coded scale
-	scaleSteps : null,
-	//Number - The value jump in the hard coded scale
-	scaleStepWidth : null,
-	//Number - The scale starting value
-	scaleStartValue : null,
-
-	//String - Colour of the scale line	
-	scaleLineColor : "rgba(0,0,0,.1)",
-	
-	//Number - Pixel width of the scale line	
-	scaleLineWidth : 1,
-
-	//Boolean - Whether to show labels on the scale	
-	scaleShowLabels : true,
-	
-	//Interpolated JS string - can access value
-	scaleLabel : "<%=value%>",
-	
-	//String - Scale label font declaration for the scale label
-	scaleFontFamily : "'Arial'",
-	
-	//Number - Scale label font size in pixels	
-	scaleFontSize : 12,
-	
-	//String - Scale label font weight style	
-	scaleFontStyle : "normal",
-	
-	//String - Scale label font colour	
-	scaleFontColor : "#666",	
-	
-	///Boolean - Whether grid lines are shown across the chart
-	scaleShowGridLines : true,
-	
-	//String - Colour of the grid lines
-	scaleGridLineColor : "rgba(0,0,0,.05)",
-	
-	//Number - Width of the grid lines
-	scaleGridLineWidth : 1,	
-	
-	//Boolean - Whether the line is curved between points
-	bezierCurve : true,
-	
-	//Boolean - Whether to show a dot for each point
-	pointDot : true,
-	
-	//Number - Radius of each point dot in pixels
-	pointDotRadius : 3,
-	
-	//Number - Pixel width of point dot stroke
-	pointDotStrokeWidth : 1,
-	
-	//Boolean - Whether to show a stroke for datasets
-	datasetStroke : true,
-	
-	//Number - Pixel width of dataset stroke
-	datasetStrokeWidth : 2,
-	
-	//Boolean - Whether to fill the dataset with a colour
-	datasetFill : true,
-	
-	//Boolean - Whether to animate the chart
-	animation : true,
-
-	//Number - Number of animation steps
-	animationSteps : 60,
-	
-	//String - Animation easing effect
-	animationEasing : "easeOutQuart",
-
-	//Function - Fires when the animation is complete
-	onAnimationComplete : null
-	
-}
-
- -
-

Bar chart

-

Introduction

-

A bar chart is a way of showing data as bars.

-

It is sometimes used to show trend data, and the comparison of multiple data sets side by side.

-

Example usage

- -
new Chart(ctx).Bar(data,options);
-

Data structure

-
var data = {
-	labels : ["January","February","March","April","May","June","July"],
-	datasets : [
-		{
-			fillColor : "rgba(220,220,220,0.5)",
-			strokeColor : "rgba(220,220,220,1)",
-			data : [65,59,90,81,56,55,40]
-		},
-		{
-			fillColor : "rgba(151,187,205,0.5)",
-			strokeColor : "rgba(151,187,205,1)",
-			data : [28,48,40,19,96,27,100]
-		}
-	]
-}
-

The bar chart has the a very similar data structure to the line chart, and has an array of datasets, each with colours and an array of data. Again, colours are in CSS format.

-

We have an array of labels too for display. In the example, we are showing the same data as the previous line chart example.

- -

Chart options

-
Bar.defaults = {
-				
-	//Boolean - If we show the scale above the chart data			
-	scaleOverlay : false,
-	
-	//Boolean - If we want to override with a hard coded scale
-	scaleOverride : false,
-	
-	//** Required if scaleOverride is true **
-	//Number - The number of steps in a hard coded scale
-	scaleSteps : null,
-	//Number - The value jump in the hard coded scale
-	scaleStepWidth : null,
-	//Number - The scale starting value
-	scaleStartValue : null,
-
-	//String - Colour of the scale line	
-	scaleLineColor : "rgba(0,0,0,.1)",
-	
-	//Number - Pixel width of the scale line	
-	scaleLineWidth : 1,
-
-	//Boolean - Whether to show labels on the scale	
-	scaleShowLabels : true,
-	
-	//Interpolated JS string - can access value
-	scaleLabel : "<%=value%>",
-	
-	//String - Scale label font declaration for the scale label
-	scaleFontFamily : "'Arial'",
-	
-	//Number - Scale label font size in pixels	
-	scaleFontSize : 12,
-	
-	//String - Scale label font weight style	
-	scaleFontStyle : "normal",
-	
-	//String - Scale label font colour	
-	scaleFontColor : "#666",	
-	
-	///Boolean - Whether grid lines are shown across the chart
-	scaleShowGridLines : true,
-	
-	//String - Colour of the grid lines
-	scaleGridLineColor : "rgba(0,0,0,.05)",
-	
-	//Number - Width of the grid lines
-	scaleGridLineWidth : 1,	
-
-	//Boolean - If there is a stroke on each bar	
-	barShowStroke : true,
-	
-	//Number - Pixel width of the bar stroke	
-	barStrokeWidth : 2,
-	
-	//Number - Spacing between each of the X value sets
-	barValueSpacing : 5,
-	
-	//Number - Spacing between data sets within X values
-	barDatasetSpacing : 1,
-	
-	//Boolean - Whether to animate the chart
-	animation : true,
-
-	//Number - Number of animation steps
-	animationSteps : 60,
-	
-	//String - Animation easing effect
-	animationEasing : "easeOutQuart",
-
-	//Function - Fires when the animation is complete
-	onAnimationComplete : null
-	
-}
-
- -
-

Radar chart

-

Introduction

-

A radar chart is a way of showing multiple data points and the variation between them.

-

They are often useful for comparing the points of two or more different data sets

-

Example usage

- -
new Chart(ctx).Radar(data,options);
-

Data structure

-
var data = {
-	labels : ["Eating","Drinking","Sleeping","Designing","Coding","Partying","Running"],
-	datasets : [
-		{
-			fillColor : "rgba(220,220,220,0.5)",
-			strokeColor : "rgba(220,220,220,1)",
-			pointColor : "rgba(220,220,220,1)",
-			pointStrokeColor : "#fff",
-			data : [65,59,90,81,56,55,40]
-		},
-		{
-			fillColor : "rgba(151,187,205,0.5)",
-			strokeColor : "rgba(151,187,205,1)",
-			pointColor : "rgba(151,187,205,1)",
-			pointStrokeColor : "#fff",
-			data : [28,48,40,19,96,27,100]
-		}
-	]
-}
-

For a radar chart, usually you will want to show a label on each point of the chart, so we include an array of strings that we show around each point in the chart. If you do not want this, you can either not include the array of labels, or choose to hide them in the chart options.

-

For the radar chart data, we have an array of datasets. Each of these is an object, with a fill colour, a stroke colour, a colour for the fill of each point, and a colour for the stroke of each point. We also have an array of data values.

- -

Chart options

-
Radar.defaults = {
-				
-	//Boolean - If we show the scale above the chart data			
-	scaleOverlay : false,
-	
-	//Boolean - If we want to override with a hard coded scale
-	scaleOverride : false,
-	
-	//** Required if scaleOverride is true **
-	//Number - The number of steps in a hard coded scale
-	scaleSteps : null,
-	//Number - The value jump in the hard coded scale
-	scaleStepWidth : null,
-	//Number - The centre starting value
-	scaleStartValue : null,
-	
-	//Boolean - Whether to show lines for each scale point
-	scaleShowLine : true,
-
-	//String - Colour of the scale line	
-	scaleLineColor : "rgba(0,0,0,.1)",
-	
-	//Number - Pixel width of the scale line	
-	scaleLineWidth : 1,
-
-	//Boolean - Whether to show labels on the scale	
-	scaleShowLabels : false,
-	
-	//Interpolated JS string - can access value
-	scaleLabel : "<%=value%>",
-	
-	//String - Scale label font declaration for the scale label
-	scaleFontFamily : "'Arial'",
-	
-	//Number - Scale label font size in pixels	
-	scaleFontSize : 12,
-	
-	//String - Scale label font weight style	
-	scaleFontStyle : "normal",
-	
-	//String - Scale label font colour	
-	scaleFontColor : "#666",
-	
-	//Boolean - Show a backdrop to the scale label
-	scaleShowLabelBackdrop : true,
-	
-	//String - The colour of the label backdrop	
-	scaleBackdropColor : "rgba(255,255,255,0.75)",
-	
-	//Number - The backdrop padding above & below the label in pixels
-	scaleBackdropPaddingY : 2,
-	
-	//Number - The backdrop padding to the side of the label in pixels	
-	scaleBackdropPaddingX : 2,
-	
-	//Boolean - Whether we show the angle lines out of the radar
-	angleShowLineOut : true,
-	
-	//String - Colour of the angle line
-	angleLineColor : "rgba(0,0,0,.1)",
-	
-	//Number - Pixel width of the angle line
-	angleLineWidth : 1,			
-	
-	//String - Point label font declaration
-	pointLabelFontFamily : "'Arial'",
-	
-	//String - Point label font weight
-	pointLabelFontStyle : "normal",
-	
-	//Number - Point label font size in pixels	
-	pointLabelFontSize : 12,
-	
-	//String - Point label font colour	
-	pointLabelFontColor : "#666",
-	
-	//Boolean - Whether to show a dot for each point
-	pointDot : true,
-	
-	//Number - Radius of each point dot in pixels
-	pointDotRadius : 3,
-	
-	//Number - Pixel width of point dot stroke
-	pointDotStrokeWidth : 1,
-	
-	//Boolean - Whether to show a stroke for datasets
-	datasetStroke : true,
-	
-	//Number - Pixel width of dataset stroke
-	datasetStrokeWidth : 2,
-	
-	//Boolean - Whether to fill the dataset with a colour
-	datasetFill : true,
-	
-	//Boolean - Whether to animate the chart
-	animation : true,
-
-	//Number - Number of animation steps
-	animationSteps : 60,
-	
-	//String - Animation easing effect
-	animationEasing : "easeOutQuart",
-
-	//Function - Fires when the animation is complete
-	onAnimationComplete : null
-	
-}
-
- -
-

Polar area chart

-

Introduction

-

Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.

-

This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.

-

Example usage

- -
new Chart(ctx).PolarArea(data,options);
-

Data structure

-
var data = [
-	{
-		value : 30,
-		color: "#D97041"
-	},
-	{
-		value : 90,
-		color: "#C7604C"
-	},
-	{
-		value : 24,
-		color: "#21323D"
-	},
-	{
-		value : 58,
-		color: "#9D9B7F"
-	},
-	{
-		value : 82,
-		color: "#7D4F6D"
-	},
-	{
-		value : 8,
-		color: "#584A5E"
-	}
-]
-

As you can see, for the chart data you pass in an array of objects, with a value and a colour. The value attribute should be a number, while the color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.

-

Chart options

-

These are the default chart options. By passing in an object with any of these attributes, Chart.js will merge these objects and the graph accordingly. Explanations of each option are commented in the code below.

-
PolarArea.defaults = {
-				
-	//Boolean - Whether we show the scale above or below the chart segments
-	scaleOverlay : true,
-	
-	//Boolean - If we want to override with a hard coded scale
-	scaleOverride : false,
-	
-	//** Required if scaleOverride is true **
-	//Number - The number of steps in a hard coded scale
-	scaleSteps : null,
-	//Number - The value jump in the hard coded scale
-	scaleStepWidth : null,
-	//Number - The centre starting value
-	scaleStartValue : null,
-	
-	//Boolean - Show line for each value in the scale
-	scaleShowLine : true,
-	
-	//String - The colour of the scale line
-	scaleLineColor : "rgba(0,0,0,.1)",
-	
-	//Number - The width of the line - in pixels
-	scaleLineWidth : 1,
-	
-	//Boolean - whether we should show text labels
-	scaleShowLabels : true,
-	
-	//Interpolated JS string - can access value
-	scaleLabel : "<%=value%>",
-	
-	//String - Scale label font declaration for the scale label
-	scaleFontFamily : "'Arial'",
-	
-	//Number - Scale label font size in pixels	
-	scaleFontSize : 12,
-	
-	//String - Scale label font weight style	
-	scaleFontStyle : "normal",
-	
-	//String - Scale label font colour	
-	scaleFontColor : "#666",
-	
-	//Boolean - Show a backdrop to the scale label
-	scaleShowLabelBackdrop : true,
-	
-	//String - The colour of the label backdrop	
-	scaleBackdropColor : "rgba(255,255,255,0.75)",
-	
-	//Number - The backdrop padding above & below the label in pixels
-	scaleBackdropPaddingY : 2,
-	
-	//Number - The backdrop padding to the side of the label in pixels	
-	scaleBackdropPaddingX : 2,
-
-	//Boolean - Stroke a line around each segment in the chart
-	segmentShowStroke : true,
-	
-	//String - The colour of the stroke on each segement.
-	segmentStrokeColor : "#fff",
-	
-	//Number - The width of the stroke value in pixels	
-	segmentStrokeWidth : 2,
-	
-	//Boolean - Whether to animate the chart or not
-	animation : true,
-	
-	//Number - Amount of animation steps
-	animationSteps : 100,
-	
-	//String - Animation easing effect.
-	animationEasing : "easeOutBounce",
-
-	//Boolean - Whether to animate the rotation of the chart
-	animateRotate : true,
-	
-	//Boolean - Whether to animate scaling the chart from the centre
-	animateScale : false,
-
-	//Function - This will fire when the animation of the chart is complete.
-	onAnimationComplete : null
-}
-
-
-

Pie chart

-

Introduction

-

Pie charts are probably the most commonly used chart there are. They are divided into segments, the arc of each segment shows a the proportional value of each piece of data.

-

They are excellent at showing the relational proportions between data.

-

Example usage

- -
new Chart(ctx).Pie(data,options);
-

Data structure

-
var data = [
-	{
-		value: 30,
-		color:"#F38630"
-	},
-	{
-		value : 50,
-		color : "#E0E4CC"
-	},
-	{
-		value : 100,
-		color : "#69D2E7"
-	}			
-]
-

For a pie chart, you must pass in an array of objects with a value and a color property. The value attribute should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each. The color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.

-

Chart options

-

These are the default options for the Pie chart. Pass in an object with any of these attributes to override them. -

Pie.defaults = {
-	//Boolean - Whether we should show a stroke on each segment
-	segmentShowStroke : true,
-	
-	//String - The colour of each segment stroke
-	segmentStrokeColor : "#fff",
-	
-	//Number - The width of each segment stroke
-	segmentStrokeWidth : 2,
-	
-	//Boolean - Whether we should animate the chart	
-	animation : true,
-	
-	//Number - Amount of animation steps
-	animationSteps : 100,
-	
-	//String - Animation easing effect
-	animationEasing : "easeOutBounce",
-	
-	//Boolean - Whether we animate the rotation of the Pie
-	animateRotate : true,
-
-	//Boolean - Whether we animate scaling the Pie from the centre
-	animateScale : false,
-	
-	//Function - Will fire on animation completion.
-	onAnimationComplete : null
-}
-
-
-

Doughnut chart

-

Introduction

-

Doughnut charts are similar to pie charts, however they have the centre cut out, and are therefore shaped more like a doughnut than a pie!

-

They are aso excellent at showing the relational proportions between data.

-

Example usage

- -
new Chart(ctx).Doughnut(data,options);
-

Data structure

-
var data = [
-	{
-		value: 30,
-		color:"#F7464A"
-	},
-	{
-		value : 50,
-		color : "#E2EAE9"
-	},
-	{
-		value : 100,
-		color : "#D4CCC5"
-	},
-	{
-		value : 40,
-		color : "#949FB1"
-	},
-	{
-		value : 120,
-		color : "#4D5360"
-	}
-
-]
-

For a doughnut chart, you must pass in an array of objects with a value and a color property. The value attribute should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each. The color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.

-

Chart options

-

These are the default options for the doughnut chart. Pass in an object with any of these attributes to override them. -

Doughnut.defaults = {
-	//Boolean - Whether we should show a stroke on each segment
-	segmentShowStroke : true,
-	
-	//String - The colour of each segment stroke
-	segmentStrokeColor : "#fff",
-	
-	//Number - The width of each segment stroke
-	segmentStrokeWidth : 2,
-	
-	//The percentage of the chart that we cut out of the middle.
-	percentageInnerCutout : 50,
-	
-	//Boolean - Whether we should animate the chart	
-	animation : true,
-	
-	//Number - Amount of animation steps
-	animationSteps : 100,
-	
-	//String - Animation easing effect
-	animationEasing : "easeOutBounce",
-	
-	//Boolean - Whether we animate the rotation of the Doughnut
-	animateRotate : true,
-
-	//Boolean - Whether we animate scaling the Doughnut from the centre
-	animateScale : false,
-	
-	//Function - Will fire on animation completion.
-	onAnimationComplete : null
-}
-
-
-

General issues

-

Chart interactivity

-

If you are looking to add interaction as a layer to charts, Chart.js is not the library for you. A better option would be using SVG, as this will let you attach event listeners to any of the elements in the chart, as these are all DOM nodes.

-

Chart.js uses the canvas element, which is a single DOM node, similar in characteristics to a static image. This does mean that it has a wider scope for compatibility, and less memory implications than SVG based charting solutions. The canvas element also allows for saving the contents as a base 64 string, allowing saving the chart as an image.

-

In SVG, all of the lines, data points and everything you see is a DOM node. As a result of this, complex charts with a lot of intricacies, or many charts on the page will often see dips in performance when scrolling or generating the chart, especially when there are multiple on the page. SVG also has relatively poor mobile support, with Android not supporting SVG at all before version 3.0, and iOS before 5.0. (caniuse.com/svg-html5).

-

Browser support

-

Browser support for the canvas element is available in all modern & major mobile browsers (caniuse.com/canvas).

-

For IE8 & below, I would recommend using the polyfill ExplorerCanvas - available at https://code.google.com/p/explorercanvas/. It falls back to Internet explorer's format VML when canvas support is not available. Example use:

-
<head>
-	<!--[if lte IE 8]>
-		<script src="excanvas.js"></script>
-	<![endif]-->
-</head>
-

Usually I would recommend feature detection to choose whether or not to load a polyfill, rather than IE conditional comments, however in this case, VML is a Microsoft proprietary format, so it will only work in IE.

-

Some important points to note in my experience using ExplorerCanvas as a fallback.

-
    -
  • Initialise charts on load rather than DOMContentReady when using the library, as sometimes a race condition will occur, and it will result in an error when trying to get the 2d context of a canvas.
  • -
  • New VML DOM elements are being created for each animation frame and there is no hardware acceleration. As a result animation is usually slow and jerky, with flashing text. It is a good idea to dynamically turn off animation based on canvas support. I recommend using the excellent Modernizr to do this.
  • -
  • When declaring fonts, the library explorercanvas requires the font name to be in single quotes inside the string. For example, instead of your scaleFontFamily property being simply "Arial", explorercanvas support, use "'Arial'" instead. Chart.js does this for default values.
  • - -
-

Bugs & issues

-

Please report these on the Github page - at github.com/nnnick/Chart.js.

-

New contributions to the library are welcome.

-

License

-

Chart.js is open source and available under the MIT license.

-
-
-
- - - - diff --git a/system/templates/js/chart-js/docs/prettify.css b/system/templates/js/chart-js/docs/prettify.css deleted file mode 100755 index 22e0d02f..00000000 --- a/system/templates/js/chart-js/docs/prettify.css +++ /dev/null @@ -1,38 +0,0 @@ -/* Pretty printing styles. Used with prettify.js. */ -/* Vim sunburst theme by David Leibovic */ - -pre .str, code .str { color: #65B042; } /* string - green */ -pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */ -pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */ -pre .typ, code .typ { color: #89bdff; } /* type - light blue */ -pre .lit, code .lit { color: #3387CC; } /* literal - blue */ -pre .pun, code .pun { color: #fff; } /* punctuation - white */ -pre .pln, code .pln { color: #fff; } /* plaintext - white */ -pre .tag, code .tag { color: #89bdff; } /* html/xml tag - light blue */ -pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name - khaki */ -pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */ -pre .dec, code .dec { color: #3387CC; } /* decimal - blue */ - -pre.prettyprint, code.prettyprint { - background-color: #000; - -moz-border-radius: 8px; - -webkit-border-radius: 8px; - -o-border-radius: 8px; - -ms-border-radius: 8px; - -khtml-border-radius: 8px; - border-radius: 8px; -} - -pre.prettyprint { - width: 95%; - margin: 1em auto; - padding: 1em; - white-space: pre-wrap; -} - - -/* Specify class=linenums on a pre to get line numbering */ -ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */ -li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } -/* Alternate shading for lines */ -li.L1,li.L3,li.L5,li.L7,li.L9 { } diff --git a/system/templates/js/chart-js/docs/prettify.js b/system/templates/js/chart-js/docs/prettify.js deleted file mode 100755 index 0f7ffa0c..00000000 --- a/system/templates/js/chart-js/docs/prettify.js +++ /dev/null @@ -1,28 +0,0 @@ -var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; -(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= -[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), -l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, -q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, -q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, -"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), -a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} -for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], -"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], -H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], -J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ -I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), -["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", -/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), -["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", -hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}p - - - Animation Callbacks - - - - - - -
- - -
-
-
- - - - - \ No newline at end of file diff --git a/system/templates/js/chart-js/samples/bar.html b/system/templates/js/chart-js/samples/bar.html deleted file mode 100755 index bf150db8..00000000 --- a/system/templates/js/chart-js/samples/bar.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - Bar Chart - - - - - - - - - - - diff --git a/system/templates/js/chart-js/samples/bar/bar-horizontal.html b/system/templates/js/chart-js/samples/bar/bar-horizontal.html deleted file mode 100644 index affcc334..00000000 --- a/system/templates/js/chart-js/samples/bar/bar-horizontal.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Horizontal Bar Chart - - - - - - -
- -
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/bar/bar-multi-axis.html b/system/templates/js/chart-js/samples/bar/bar-multi-axis.html deleted file mode 100644 index b35e8905..00000000 --- a/system/templates/js/chart-js/samples/bar/bar-multi-axis.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - Bar Chart Multi Axis - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/bar/bar-stacked-group.html b/system/templates/js/chart-js/samples/bar/bar-stacked-group.html deleted file mode 100644 index 074e3eac..00000000 --- a/system/templates/js/chart-js/samples/bar/bar-stacked-group.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - Stacked Bar Chart with Groups - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/bar/bar-stacked.html b/system/templates/js/chart-js/samples/bar/bar-stacked.html deleted file mode 100644 index f80b1b6e..00000000 --- a/system/templates/js/chart-js/samples/bar/bar-stacked.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - Stacked Bar Chart - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/bar/bar.html b/system/templates/js/chart-js/samples/bar/bar.html deleted file mode 100644 index d2fc4aca..00000000 --- a/system/templates/js/chart-js/samples/bar/bar.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Bar Chart - - - - - - -
- -
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/bubble.html b/system/templates/js/chart-js/samples/bubble.html deleted file mode 100644 index d62d6375..00000000 --- a/system/templates/js/chart-js/samples/bubble.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Bubble Chart - - - - - - -
- -
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/combo-bar-line.html b/system/templates/js/chart-js/samples/combo-bar-line.html deleted file mode 100644 index c8b5a08f..00000000 --- a/system/templates/js/chart-js/samples/combo-bar-line.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Combo Bar-Line Chart - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/data_labelling.html b/system/templates/js/chart-js/samples/data_labelling.html deleted file mode 100644 index 939e517a..00000000 --- a/system/templates/js/chart-js/samples/data_labelling.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - Labelling Data Points - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/doughnut.html b/system/templates/js/chart-js/samples/doughnut.html deleted file mode 100644 index 51b98a82..00000000 --- a/system/templates/js/chart-js/samples/doughnut.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Doughnut Chart - - - - - - -
- -
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/legend/pointstyle.html b/system/templates/js/chart-js/samples/legend/pointstyle.html deleted file mode 100644 index 727c7a6d..00000000 --- a/system/templates/js/chart-js/samples/legend/pointstyle.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - Legend Point Style - - - - - - -
-
- -
-
- -
-
- - - - diff --git a/system/templates/js/chart-js/samples/legend/positions.html b/system/templates/js/chart-js/samples/legend/positions.html deleted file mode 100644 index 97bc70fa..00000000 --- a/system/templates/js/chart-js/samples/legend/positions.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Legend Positions - - - - - - -
-
- -
-
- -
-
- -
-
- -
-
- - - - diff --git a/system/templates/js/chart-js/samples/line.html b/system/templates/js/chart-js/samples/line.html deleted file mode 100755 index 4c673445..00000000 --- a/system/templates/js/chart-js/samples/line.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - Line Chart - - - - - - - - - - - diff --git a/system/templates/js/chart-js/samples/line/different-point-sizes.html b/system/templates/js/chart-js/samples/line/different-point-sizes.html deleted file mode 100644 index ed52cf0a..00000000 --- a/system/templates/js/chart-js/samples/line/different-point-sizes.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - Different Point Sizes - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/line/interpolation-modes.html b/system/templates/js/chart-js/samples/line/interpolation-modes.html deleted file mode 100644 index ff75210a..00000000 --- a/system/templates/js/chart-js/samples/line/interpolation-modes.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - Line Chart - Cubic interpolation mode - - - - - - -
- -
-
-
- - - - - \ No newline at end of file diff --git a/system/templates/js/chart-js/samples/line/line-multi-axis.html b/system/templates/js/chart-js/samples/line/line-multi-axis.html deleted file mode 100644 index debdf369..00000000 --- a/system/templates/js/chart-js/samples/line/line-multi-axis.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Line Chart Multiple Axes - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/line/line-skip-points.html b/system/templates/js/chart-js/samples/line/line-skip-points.html deleted file mode 100644 index bb8c8c4c..00000000 --- a/system/templates/js/chart-js/samples/line/line-skip-points.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Line Chart - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/line/line-stacked-area.html b/system/templates/js/chart-js/samples/line/line-stacked-area.html deleted file mode 100644 index 041c9a84..00000000 --- a/system/templates/js/chart-js/samples/line/line-stacked-area.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - - Line Chart - - - - - - -
- -
-
-
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/line/line-stepped.html b/system/templates/js/chart-js/samples/line/line-stepped.html deleted file mode 100644 index ff1bf2a6..00000000 --- a/system/templates/js/chart-js/samples/line/line-stepped.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - Stepped Line Chart - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/line/line-styles.html b/system/templates/js/chart-js/samples/line/line-styles.html deleted file mode 100644 index 0ac3aabd..00000000 --- a/system/templates/js/chart-js/samples/line/line-styles.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - Line Styles - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/line/line.html b/system/templates/js/chart-js/samples/line/line.html deleted file mode 100644 index 68ae7e5f..00000000 --- a/system/templates/js/chart-js/samples/line/line.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - Line Chart - - - - - - -
- -
-
-
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/line/point-styles.html b/system/templates/js/chart-js/samples/line/point-styles.html deleted file mode 100644 index 0056e749..00000000 --- a/system/templates/js/chart-js/samples/line/point-styles.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - Line Chart - - - - - - -
-
- - - - diff --git a/system/templates/js/chart-js/samples/pie.html b/system/templates/js/chart-js/samples/pie.html deleted file mode 100644 index c299af96..00000000 --- a/system/templates/js/chart-js/samples/pie.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Pie Chart - - - - - -
- -
- - - - - - - diff --git a/system/templates/js/chart-js/samples/polar-area.html b/system/templates/js/chart-js/samples/polar-area.html deleted file mode 100644 index 48fe984a..00000000 --- a/system/templates/js/chart-js/samples/polar-area.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - Polar Area Chart - - - - - - -
- -
- - - - - - - diff --git a/system/templates/js/chart-js/samples/polarArea.html b/system/templates/js/chart-js/samples/polarArea.html deleted file mode 100755 index dcc055b6..00000000 --- a/system/templates/js/chart-js/samples/polarArea.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - Polar Area Chart - - - - - - - - - - - diff --git a/system/templates/js/chart-js/samples/radar.html b/system/templates/js/chart-js/samples/radar.html deleted file mode 100755 index 0ffdad91..00000000 --- a/system/templates/js/chart-js/samples/radar.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - Radar Chart - - - - - - - - - - - diff --git a/system/templates/js/chart-js/samples/radar/radar-skip-points.html b/system/templates/js/chart-js/samples/radar/radar-skip-points.html deleted file mode 100644 index ab29b3a0..00000000 --- a/system/templates/js/chart-js/samples/radar/radar-skip-points.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - Radar Chart - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/radar/radar.html b/system/templates/js/chart-js/samples/radar/radar.html deleted file mode 100644 index 586e2df7..00000000 --- a/system/templates/js/chart-js/samples/radar/radar.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - Radar Chart - - - - - - -
- -
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/scales/display-settings.html b/system/templates/js/chart-js/samples/scales/display-settings.html deleted file mode 100644 index 0c2dc114..00000000 --- a/system/templates/js/chart-js/samples/scales/display-settings.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - Suggested Min/Max Settings - - - - - - -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/filtering-labels.html b/system/templates/js/chart-js/samples/scales/filtering-labels.html deleted file mode 100644 index 4af89025..00000000 --- a/system/templates/js/chart-js/samples/scales/filtering-labels.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - Chart with xAxis Filtering - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/gridlines.html b/system/templates/js/chart-js/samples/scales/gridlines.html deleted file mode 100644 index 76bb1f00..00000000 --- a/system/templates/js/chart-js/samples/scales/gridlines.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Suggested Min/Max Settings - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/line-non-numeric-y.html b/system/templates/js/chart-js/samples/scales/line-non-numeric-y.html deleted file mode 100644 index 07e319b7..00000000 --- a/system/templates/js/chart-js/samples/scales/line-non-numeric-y.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - Line Chart - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/linear/min-max-settings.html b/system/templates/js/chart-js/samples/scales/linear/min-max-settings.html deleted file mode 100644 index 868bc7b1..00000000 --- a/system/templates/js/chart-js/samples/scales/linear/min-max-settings.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Min/Max Settings - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/linear/step-size.html b/system/templates/js/chart-js/samples/scales/linear/step-size.html deleted file mode 100644 index ced0b6c3..00000000 --- a/system/templates/js/chart-js/samples/scales/linear/step-size.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - Line Chart - - - - - - -
- -
-
-
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/scales/linear/suggested-min-max-settings.html b/system/templates/js/chart-js/samples/scales/linear/suggested-min-max-settings.html deleted file mode 100644 index 18059548..00000000 --- a/system/templates/js/chart-js/samples/scales/linear/suggested-min-max-settings.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - Suggested Min/Max Settings - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/logarithmic/line-logarithmic.html b/system/templates/js/chart-js/samples/scales/logarithmic/line-logarithmic.html deleted file mode 100644 index 2c961abd..00000000 --- a/system/templates/js/chart-js/samples/scales/logarithmic/line-logarithmic.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Logarithmic Line Chart - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/scales/logarithmic/scatter-logX.html b/system/templates/js/chart-js/samples/scales/logarithmic/scatter-logX.html deleted file mode 100644 index a4bd577c..00000000 --- a/system/templates/js/chart-js/samples/scales/logarithmic/scatter-logX.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Scatter Chart - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/multiline-labels.html b/system/templates/js/chart-js/samples/scales/multiline-labels.html deleted file mode 100644 index b7bb041e..00000000 --- a/system/templates/js/chart-js/samples/scales/multiline-labels.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Line Chart - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/scales/time/combo-time-scale.html b/system/templates/js/chart-js/samples/scales/time/combo-time-scale.html deleted file mode 100644 index 873e40d1..00000000 --- a/system/templates/js/chart-js/samples/scales/time/combo-time-scale.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - Line Chart - Combo Time Scale - - - - - - - -
- -
-
-
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/scales/time/line-time-point-data.html b/system/templates/js/chart-js/samples/scales/time/line-time-point-data.html deleted file mode 100644 index d880515f..00000000 --- a/system/templates/js/chart-js/samples/scales/time/line-time-point-data.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Time Scale Point Data - - - - - - - -
- -
-
-
- - - - - - - diff --git a/system/templates/js/chart-js/samples/scales/time/line-time-scale.html b/system/templates/js/chart-js/samples/scales/time/line-time-scale.html deleted file mode 100644 index b1645e0d..00000000 --- a/system/templates/js/chart-js/samples/scales/time/line-time-scale.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Line Chart - - - - - - - -
- -
-
-
- - - - - - - - - diff --git a/system/templates/js/chart-js/samples/scatter/scatter-multi-axis.html b/system/templates/js/chart-js/samples/scatter/scatter-multi-axis.html deleted file mode 100644 index aedcd3da..00000000 --- a/system/templates/js/chart-js/samples/scatter/scatter-multi-axis.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Scatter Chart Multi Axis - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/scatter/scatter.html b/system/templates/js/chart-js/samples/scatter/scatter.html deleted file mode 100644 index b8ac32b8..00000000 --- a/system/templates/js/chart-js/samples/scatter/scatter.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - Scatter Chart - - - - - - -
- -
- - - - - diff --git a/system/templates/js/chart-js/samples/sixup.html b/system/templates/js/chart-js/samples/sixup.html deleted file mode 100755 index 37b957e7..00000000 --- a/system/templates/js/chart-js/samples/sixup.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - Doughnut Chart - - - - - -
- - - - - - -
- - - - - diff --git a/system/templates/js/chart-js/samples/tooltips/dataPoints-customTooltips.html b/system/templates/js/chart-js/samples/tooltips/dataPoints-customTooltips.html deleted file mode 100644 index b9e98167..00000000 --- a/system/templates/js/chart-js/samples/tooltips/dataPoints-customTooltips.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - Custom Tooltips using Data Points - - - - - - - -
- -
-
-
- - - - diff --git a/system/templates/js/chart-js/samples/tooltips/interaction-modes.html b/system/templates/js/chart-js/samples/tooltips/interaction-modes.html deleted file mode 100644 index 17cacf42..00000000 --- a/system/templates/js/chart-js/samples/tooltips/interaction-modes.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - Tooltip Interaction Modes - - - - - - -
-
- - - - diff --git a/system/templates/js/chart-js/samples/tooltips/line-customTooltips.html b/system/templates/js/chart-js/samples/tooltips/line-customTooltips.html deleted file mode 100644 index 97f543b2..00000000 --- a/system/templates/js/chart-js/samples/tooltips/line-customTooltips.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - - Line Chart with Custom Tooltips - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/tooltips/pie-customTooltips.html b/system/templates/js/chart-js/samples/tooltips/pie-customTooltips.html deleted file mode 100644 index 4eedd6a3..00000000 --- a/system/templates/js/chart-js/samples/tooltips/pie-customTooltips.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - Pie Chart with Custom Tooltips - - - - - - - -
- -
- -
-
-
- - - - - diff --git a/system/templates/js/chart-js/samples/tooltips/position-modes.html b/system/templates/js/chart-js/samples/tooltips/position-modes.html deleted file mode 100644 index 696584b0..00000000 --- a/system/templates/js/chart-js/samples/tooltips/position-modes.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Tooltip Interaction Modes - - - - - - -
-
- - - - diff --git a/system/templates/js/chart-js/samples/tooltips/tooltip-callbacks.html b/system/templates/js/chart-js/samples/tooltips/tooltip-callbacks.html deleted file mode 100644 index 590edd1a..00000000 --- a/system/templates/js/chart-js/samples/tooltips/tooltip-callbacks.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - Tooltip Hooks - - - - - - -
- -
- - - - diff --git a/system/templates/js/chart-js/samples/utils.js b/system/templates/js/chart-js/samples/utils.js deleted file mode 100644 index 34965ce6..00000000 --- a/system/templates/js/chart-js/samples/utils.js +++ /dev/null @@ -1,13 +0,0 @@ -window.chartColors = { - red: 'rgb(255, 99, 132)', - orange: 'rgb(255, 159, 64)', - yellow: 'rgb(255, 205, 86)', - green: 'rgb(75, 192, 192)', - blue: 'rgb(54, 162, 235)', - purple: 'rgb(153, 102, 255)', - grey: 'rgb(231,233,237)' -}; - -window.randomScalingFactor = function() { - return (Math.random() > 0.5 ? 1.0 : -1.0) * Math.round(Math.random() * 100); -} \ No newline at end of file diff --git a/system/templates/js/chart-js/scripts/release.sh b/system/templates/js/chart-js/scripts/release.sh deleted file mode 100755 index 03c7c646..00000000 --- a/system/templates/js/chart-js/scripts/release.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -e - -if [ "$TRAVIS_BRANCH" != "release" ]; then - echo "Skipping release because this is not the 'release' branch" - exit 0 -fi - -# Travis executes this script from the repository root, so at the same level than package.json -VERSION=$(node -p -e "require('./package.json').version") - -# Make sure that the associated tag doesn't already exist -GITTAG=$(git ls-remote origin refs/tags/v$VERSION) -if [ "$GITTAG" != "" ]; then - echo "Tag for package.json version already exists, aborting release" - exit 1 -fi - -git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git -git config --global user.email "$GITHUB_AUTH_EMAIL" -git config --global user.name "Chart.js" -git checkout --detach --quiet -git add -f dist/*.js bower.json -git commit -m "Release $VERSION" -git tag -a "v$VERSION" -m "Version $VERSION" -git push -q auth-origin refs/tags/v$VERSION 2>/dev/null -git remote rm auth-origin -git checkout -f @{-1} diff --git a/system/templates/js/chart-js/site/assets/6charts.png b/system/templates/js/chart-js/site/assets/6charts.png deleted file mode 100755 index 17dc2dd1..00000000 Binary files a/system/templates/js/chart-js/site/assets/6charts.png and /dev/null differ diff --git a/system/templates/js/chart-js/site/assets/Chart.js b/system/templates/js/chart-js/site/assets/Chart.js deleted file mode 100755 index a25acef1..00000000 --- a/system/templates/js/chart-js/site/assets/Chart.js +++ /dev/null @@ -1,1443 +0,0 @@ -/*! - * Chart.js - * http://chartjs.org/ - * - * Copyright 2013 Nick Downie - * Released under the MIT license - * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md - */ - -//Define the global Chart Variable as a class. -var Chart = function(context){ - - var chart = this; - - - //Easing functions adapted from Robert Penner's easing equations - //http://www.robertpenner.com/easing/ - - var animationOptions = { - linear : function (t){ - return t; - }, - easeInQuad: function (t) { - return t*t; - }, - easeOutQuad: function (t) { - return -1 *t*(t-2); - }, - easeInOutQuad: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t; - return -1/2 * ((--t)*(t-2) - 1); - }, - easeInCubic: function (t) { - return t*t*t; - }, - easeOutCubic: function (t) { - return 1*((t=t/1-1)*t*t + 1); - }, - easeInOutCubic: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t*t; - return 1/2*((t-=2)*t*t + 2); - }, - easeInQuart: function (t) { - return t*t*t*t; - }, - easeOutQuart: function (t) { - return -1 * ((t=t/1-1)*t*t*t - 1); - }, - easeInOutQuart: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t*t*t; - return -1/2 * ((t-=2)*t*t*t - 2); - }, - easeInQuint: function (t) { - return 1*(t/=1)*t*t*t*t; - }, - easeOutQuint: function (t) { - return 1*((t=t/1-1)*t*t*t*t + 1); - }, - easeInOutQuint: function (t) { - if ((t/=1/2) < 1) return 1/2*t*t*t*t*t; - return 1/2*((t-=2)*t*t*t*t + 2); - }, - easeInSine: function (t) { - return -1 * Math.cos(t/1 * (Math.PI/2)) + 1; - }, - easeOutSine: function (t) { - return 1 * Math.sin(t/1 * (Math.PI/2)); - }, - easeInOutSine: function (t) { - return -1/2 * (Math.cos(Math.PI*t/1) - 1); - }, - easeInExpo: function (t) { - return (t==0) ? 1 : 1 * Math.pow(2, 10 * (t/1 - 1)); - }, - easeOutExpo: function (t) { - return (t==1) ? 1 : 1 * (-Math.pow(2, -10 * t/1) + 1); - }, - easeInOutExpo: function (t) { - if (t==0) return 0; - if (t==1) return 1; - if ((t/=1/2) < 1) return 1/2 * Math.pow(2, 10 * (t - 1)); - return 1/2 * (-Math.pow(2, -10 * --t) + 2); - }, - easeInCirc: function (t) { - if (t>=1) return t; - return -1 * (Math.sqrt(1 - (t/=1)*t) - 1); - }, - easeOutCirc: function (t) { - return 1 * Math.sqrt(1 - (t=t/1-1)*t); - }, - easeInOutCirc: function (t) { - if ((t/=1/2) < 1) return -1/2 * (Math.sqrt(1 - t*t) - 1); - return 1/2 * (Math.sqrt(1 - (t-=2)*t) + 1); - }, - easeInElastic: function (t) { - var s=1.70158;var p=0;var a=1; - if (t==0) return 0; if ((t/=1)==1) return 1; if (!p) p=1*.3; - if (a < Math.abs(1)) { a=1; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (1/a); - return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )); - }, - easeOutElastic: function (t) { - var s=1.70158;var p=0;var a=1; - if (t==0) return 0; if ((t/=1)==1) return 1; if (!p) p=1*.3; - if (a < Math.abs(1)) { a=1; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (1/a); - return a*Math.pow(2,-10*t) * Math.sin( (t*1-s)*(2*Math.PI)/p ) + 1; - }, - easeInOutElastic: function (t) { - var s=1.70158;var p=0;var a=1; - if (t==0) return 0; if ((t/=1/2)==2) return 1; if (!p) p=1*(.3*1.5); - if (a < Math.abs(1)) { a=1; var s=p/4; } - else var s = p/(2*Math.PI) * Math.asin (1/a); - if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )); - return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*1-s)*(2*Math.PI)/p )*.5 + 1; - }, - easeInBack: function (t) { - var s = 1.70158; - return 1*(t/=1)*t*((s+1)*t - s); - }, - easeOutBack: function (t) { - var s = 1.70158; - return 1*((t=t/1-1)*t*((s+1)*t + s) + 1); - }, - easeInOutBack: function (t) { - var s = 1.70158; - if ((t/=1/2) < 1) return 1/2*(t*t*(((s*=(1.525))+1)*t - s)); - return 1/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2); - }, - easeInBounce: function (t) { - return 1 - animationOptions.easeOutBounce (1-t); - }, - easeOutBounce: function (t) { - if ((t/=1) < (1/2.75)) { - return 1*(7.5625*t*t); - } else if (t < (2/2.75)) { - return 1*(7.5625*(t-=(1.5/2.75))*t + .75); - } else if (t < (2.5/2.75)) { - return 1*(7.5625*(t-=(2.25/2.75))*t + .9375); - } else { - return 1*(7.5625*(t-=(2.625/2.75))*t + .984375); - } - }, - easeInOutBounce: function (t) { - if (t < 1/2) return animationOptions.easeInBounce (t*2) * .5; - return animationOptions.easeOutBounce (t*2-1) * .5 + 1*.5; - } - }; - - //Variables global to the chart - var width = context.canvas.width; - var height = context.canvas.height; - - - //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale. - if (window.devicePixelRatio) { - context.canvas.style.width = width + "px"; - context.canvas.style.height = height + "px"; - context.canvas.height = height * window.devicePixelRatio; - context.canvas.width = width * window.devicePixelRatio; - context.scale(window.devicePixelRatio, window.devicePixelRatio); - } - - this.PolarArea = function(data,options){ - - chart.PolarArea.defaults = { - scaleOverlay : true, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleShowLine : true, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : true, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowLabelBackdrop : true, - scaleBackdropColor : "rgba(255,255,255,0.75)", - scaleBackdropPaddingY : 2, - scaleBackdropPaddingX : 2, - segmentShowStroke : true, - segmentStrokeColor : "#fff", - segmentStrokeWidth : 2, - animation : true, - animationSteps : 100, - animationEasing : "easeOutBounce", - animateRotate : true, - animateScale : false, - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.PolarArea.defaults,options) : chart.PolarArea.defaults; - - return new PolarArea(data,config,context); - }; - - this.Radar = function(data,options){ - - chart.Radar.defaults = { - scaleOverlay : false, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleShowLine : true, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : false, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowLabelBackdrop : true, - scaleBackdropColor : "rgba(255,255,255,0.75)", - scaleBackdropPaddingY : 2, - scaleBackdropPaddingX : 2, - angleShowLineOut : true, - angleLineColor : "rgba(0,0,0,.1)", - angleLineWidth : 1, - pointLabelFontFamily : "'Arial'", - pointLabelFontStyle : "normal", - pointLabelFontSize : 12, - pointLabelFontColor : "#666", - pointDot : true, - pointDotRadius : 3, - pointDotStrokeWidth : 1, - datasetStroke : true, - datasetStrokeWidth : 2, - datasetFill : true, - animation : true, - animationSteps : 60, - animationEasing : "easeOutQuart", - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.Radar.defaults,options) : chart.Radar.defaults; - - return new Radar(data,config,context); - }; - - this.Pie = function(data,options){ - chart.Pie.defaults = { - segmentShowStroke : true, - segmentStrokeColor : "#fff", - segmentStrokeWidth : 2, - animation : true, - animationSteps : 100, - animationEasing : "easeOutBounce", - animateRotate : true, - animateScale : false, - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.Pie.defaults,options) : chart.Pie.defaults; - - return new Pie(data,config,context); - }; - - this.Doughnut = function(data,options){ - - chart.Doughnut.defaults = { - segmentShowStroke : true, - segmentStrokeColor : "#fff", - segmentStrokeWidth : 2, - percentageInnerCutout : 50, - animation : true, - animationSteps : 100, - animationEasing : "easeOutBounce", - animateRotate : true, - animateScale : false, - onAnimationComplete : null - }; - - var config = (options)? mergeChartConfig(chart.Doughnut.defaults,options) : chart.Doughnut.defaults; - - return new Doughnut(data,config,context); - - }; - - this.Line = function(data,options){ - - chart.Line.defaults = { - scaleOverlay : false, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : true, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowGridLines : true, - scaleGridLineColor : "rgba(0,0,0,.05)", - scaleGridLineWidth : 1, - bezierCurve : true, - pointDot : true, - pointDotRadius : 4, - pointDotStrokeWidth : 2, - datasetStroke : true, - datasetStrokeWidth : 2, - datasetFill : true, - animation : true, - animationSteps : 60, - animationEasing : "easeOutQuart", - onAnimationComplete : null - }; - var config = (options) ? mergeChartConfig(chart.Line.defaults,options) : chart.Line.defaults; - - return new Line(data,config,context); - } - - this.Bar = function(data,options){ - chart.Bar.defaults = { - scaleOverlay : false, - scaleOverride : false, - scaleSteps : null, - scaleStepWidth : null, - scaleStartValue : null, - scaleLineColor : "rgba(0,0,0,.1)", - scaleLineWidth : 1, - scaleShowLabels : true, - scaleLabel : "<%=value%>", - scaleFontFamily : "'Arial'", - scaleFontSize : 12, - scaleFontStyle : "normal", - scaleFontColor : "#666", - scaleShowGridLines : true, - scaleGridLineColor : "rgba(0,0,0,.05)", - scaleGridLineWidth : 1, - barShowStroke : true, - barStrokeWidth : 2, - barValueSpacing : 5, - barDatasetSpacing : 1, - animation : true, - animationSteps : 60, - animationEasing : "easeOutQuart", - onAnimationComplete : null - }; - var config = (options) ? mergeChartConfig(chart.Bar.defaults,options) : chart.Bar.defaults; - - return new Bar(data,config,context); - } - - var clear = function(c){ - c.clearRect(0, 0, width, height); - }; - - var PolarArea = function(data,config,ctx){ - var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString; - - - calculateDrawingSizes(); - - valueBounds = getValueBounds(); - - labelTemplateString = (config.scaleShowLabels)? config.scaleLabel : null; - - //Check and set the scale - if (!config.scaleOverride){ - - calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString); - } - else { - calculatedScale = { - steps : config.scaleSteps, - stepValue : config.scaleStepWidth, - graphMin : config.scaleStartValue, - labels : [] - } - for (var i=0; i upperValue) {upperValue = data[i].value;} - if (data[i].value < lowerValue) {lowerValue = data[i].value;} - }; - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - } - - var Radar = function (data,config,ctx) { - var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString; - - //If no labels are defined set to an empty array, so referencing length for looping doesn't blow up. - if (!data.labels) data.labels = []; - - calculateDrawingSizes(); - - var valueBounds = getValueBounds(); - - labelTemplateString = (config.scaleShowLabels)? config.scaleLabel : null; - - //Check and set the scale - if (!config.scaleOverride){ - - calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString); - } - else { - calculatedScale = { - steps : config.scaleSteps, - stepValue : config.scaleStepWidth, - graphMin : config.scaleStartValue, - labels : [] - } - for (var i=0; i Math.PI){ - ctx.textAlign = "right"; - } - else{ - ctx.textAlign = "left"; - } - - ctx.textBaseline = "middle"; - - ctx.fillText(data.labels[k],opposite,-adjacent); - - } - ctx.restore(); - }; - function calculateDrawingSizes(){ - maxSize = (Min([width,height])/2); - - labelHeight = config.scaleFontSize*2; - - var labelLength = 0; - for (var i=0; ilabelLength) labelLength = textMeasurement; - } - - //Figure out whats the largest - the height of the text or the width of what's there, and minus it from the maximum usable size. - maxSize -= Max([labelLength,((config.pointLabelFontSize/2)*1.5)]); - - maxSize -= config.pointLabelFontSize; - maxSize = CapValue(maxSize, null, 0); - scaleHeight = maxSize; - //If the label height is less than 5, set it to 5 so we don't have lines on top of each other. - labelHeight = Default(labelHeight,5); - }; - function getValueBounds() { - var upperValue = Number.MIN_VALUE; - var lowerValue = Number.MAX_VALUE; - - for (var i=0; i upperValue){upperValue = data.datasets[i].data[j]} - if (data.datasets[i].data[j] < lowerValue){lowerValue = data.datasets[i].data[j]} - } - } - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - } - - var Pie = function(data,config,ctx){ - var segmentTotal = 0; - - //In case we have a canvas that is not a square. Minus 5 pixels as padding round the edge. - var pieRadius = Min([height/2,width/2]) - 5; - - for (var i=0; i 0){ - ctx.save(); - ctx.textAlign = "right"; - } - else{ - ctx.textAlign = "center"; - } - ctx.fillStyle = config.scaleFontColor; - for (var i=0; i 0){ - ctx.translate(yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize); - ctx.rotate(-(rotateLabels * (Math.PI/180))); - ctx.fillText(data.labels[i], 0,0); - ctx.restore(); - } - - else{ - ctx.fillText(data.labels[i], yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize+3); - } - - ctx.beginPath(); - ctx.moveTo(yAxisPosX + i * valueHop, xAxisPosY+3); - - //Check i isnt 0, so we dont go over the Y axis twice. - if(config.scaleShowGridLines && i>0){ - ctx.lineWidth = config.scaleGridLineWidth; - ctx.strokeStyle = config.scaleGridLineColor; - ctx.lineTo(yAxisPosX + i * valueHop, 5); - } - else{ - ctx.lineTo(yAxisPosX + i * valueHop, xAxisPosY+3); - } - ctx.stroke(); - } - - //Y axis - ctx.lineWidth = config.scaleLineWidth; - ctx.strokeStyle = config.scaleLineColor; - ctx.beginPath(); - ctx.moveTo(yAxisPosX,xAxisPosY+5); - ctx.lineTo(yAxisPosX,5); - ctx.stroke(); - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - for (var j=0; j longestText)? measuredText : longestText; - } - //Add a little extra padding from the y axis - longestText +=10; - } - xAxisLength = width - longestText - widestXLabel; - valueHop = Math.floor(xAxisLength/(data.labels.length-1)); - - yAxisPosX = width-widestXLabel/2-xAxisLength; - xAxisPosY = scaleHeight + config.scaleFontSize/2; - } - function calculateDrawingSizes(){ - maxSize = height; - - //Need to check the X axis first - measure the length of each text metric, and figure out if we need to rotate by 45 degrees. - ctx.font = config.scaleFontStyle + " " + config.scaleFontSize+"px " + config.scaleFontFamily; - widestXLabel = 1; - for (var i=0; i widestXLabel)? textLength : widestXLabel; - } - if (width/data.labels.length < widestXLabel){ - rotateLabels = 45; - if (width/data.labels.length < Math.cos(rotateLabels) * widestXLabel){ - rotateLabels = 90; - maxSize -= widestXLabel; - } - else{ - maxSize -= Math.sin(rotateLabels) * widestXLabel; - } - } - else{ - maxSize -= config.scaleFontSize; - } - - //Add a little padding between the x line and the text - maxSize -= 5; - - - labelHeight = config.scaleFontSize; - - maxSize -= labelHeight; - //Set 5 pixels greater than the font size to allow for a little padding from the X axis. - - scaleHeight = maxSize; - - //Then get the area above we can safely draw on. - - } - function getValueBounds() { - var upperValue = Number.MIN_VALUE; - var lowerValue = Number.MAX_VALUE; - for (var i=0; i upperValue) { upperValue = data.datasets[i].data[j] }; - if ( data.datasets[i].data[j] < lowerValue) { lowerValue = data.datasets[i].data[j] }; - } - }; - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - - - } - - var Bar = function(data,config,ctx){ - var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString, valueHop,widestXLabel, xAxisLength,yAxisPosX,xAxisPosY,barWidth, rotateLabels = 0; - - calculateDrawingSizes(); - - valueBounds = getValueBounds(); - //Check and set the scale - labelTemplateString = (config.scaleShowLabels)? config.scaleLabel : ""; - if (!config.scaleOverride){ - - calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString); - } - else { - calculatedScale = { - steps : config.scaleSteps, - stepValue : config.scaleStepWidth, - graphMin : config.scaleStartValue, - labels : [] - } - for (var i=0; i 0){ - ctx.save(); - ctx.textAlign = "right"; - } - else{ - ctx.textAlign = "center"; - } - ctx.fillStyle = config.scaleFontColor; - for (var i=0; i 0){ - ctx.translate(yAxisPosX + i*valueHop,xAxisPosY + config.scaleFontSize); - ctx.rotate(-(rotateLabels * (Math.PI/180))); - ctx.fillText(data.labels[i], 0,0); - ctx.restore(); - } - - else{ - ctx.fillText(data.labels[i], yAxisPosX + i*valueHop + valueHop/2,xAxisPosY + config.scaleFontSize+3); - } - - ctx.beginPath(); - ctx.moveTo(yAxisPosX + (i+1) * valueHop, xAxisPosY+3); - - //Check i isnt 0, so we dont go over the Y axis twice. - ctx.lineWidth = config.scaleGridLineWidth; - ctx.strokeStyle = config.scaleGridLineColor; - ctx.lineTo(yAxisPosX + (i+1) * valueHop, 5); - ctx.stroke(); - } - - //Y axis - ctx.lineWidth = config.scaleLineWidth; - ctx.strokeStyle = config.scaleLineColor; - ctx.beginPath(); - ctx.moveTo(yAxisPosX,xAxisPosY+5); - ctx.lineTo(yAxisPosX,5); - ctx.stroke(); - - ctx.textAlign = "right"; - ctx.textBaseline = "middle"; - for (var j=0; j longestText)? measuredText : longestText; - } - //Add a little extra padding from the y axis - longestText +=10; - } - xAxisLength = width - longestText - widestXLabel; - valueHop = Math.floor(xAxisLength/(data.labels.length)); - - barWidth = (valueHop - config.scaleGridLineWidth*2 - (config.barValueSpacing*2) - (config.barDatasetSpacing*data.datasets.length-1) - ((config.barStrokeWidth/2)*data.datasets.length-1))/data.datasets.length; - - yAxisPosX = width-widestXLabel/2-xAxisLength; - xAxisPosY = scaleHeight + config.scaleFontSize/2; - } - function calculateDrawingSizes(){ - maxSize = height; - - //Need to check the X axis first - measure the length of each text metric, and figure out if we need to rotate by 45 degrees. - ctx.font = config.scaleFontStyle + " " + config.scaleFontSize+"px " + config.scaleFontFamily; - widestXLabel = 1; - for (var i=0; i widestXLabel)? textLength : widestXLabel; - } - if (width/data.labels.length < widestXLabel){ - rotateLabels = 45; - if (width/data.labels.length < Math.cos(rotateLabels) * widestXLabel){ - rotateLabels = 90; - maxSize -= widestXLabel; - } - else{ - maxSize -= Math.sin(rotateLabels) * widestXLabel; - } - } - else{ - maxSize -= config.scaleFontSize; - } - - //Add a little padding between the x line and the text - maxSize -= 5; - - - labelHeight = config.scaleFontSize; - - maxSize -= labelHeight; - //Set 5 pixels greater than the font size to allow for a little padding from the X axis. - - scaleHeight = maxSize; - - //Then get the area above we can safely draw on. - - } - function getValueBounds() { - var upperValue = Number.MIN_VALUE; - var lowerValue = Number.MAX_VALUE; - for (var i=0; i upperValue) { upperValue = data.datasets[i].data[j] }; - if ( data.datasets[i].data[j] < lowerValue) { lowerValue = data.datasets[i].data[j] }; - } - }; - - var maxSteps = Math.floor((scaleHeight / (labelHeight*0.66))); - var minSteps = Math.floor((scaleHeight / labelHeight*0.5)); - - return { - maxValue : upperValue, - minValue : lowerValue, - maxSteps : maxSteps, - minSteps : minSteps - }; - - - } - } - - function calculateOffset(val,calculatedScale,scaleHop){ - var outerValue = calculatedScale.steps * calculatedScale.stepValue; - var adjustedValue = val - calculatedScale.graphMin; - var scalingFactor = CapValue(adjustedValue/outerValue,1,0); - return (scaleHop*calculatedScale.steps) * scalingFactor; - } - - function animationLoop(config,drawScale,drawData,ctx){ - var animFrameAmount = (config.animation)? 1/CapValue(config.animationSteps,Number.MAX_VALUE,1) : 1, - easingFunction = animationOptions[config.animationEasing], - percentAnimComplete =(config.animation)? 0 : 1; - - - - if (typeof drawScale !== "function") drawScale = function(){}; - - requestAnimFrame(animLoop); - - function animateFrame(){ - var easeAdjustedAnimationPercent =(config.animation)? CapValue(easingFunction(percentAnimComplete),null,0) : 1; - clear(ctx); - if(config.scaleOverlay){ - drawData(easeAdjustedAnimationPercent); - drawScale(); - } else { - drawScale(); - drawData(easeAdjustedAnimationPercent); - } - } - function animLoop(){ - //We need to check if the animation is incomplete (less than 1), or complete (1). - percentAnimComplete += animFrameAmount; - animateFrame(); - //Stop the loop continuing forever - if (percentAnimComplete <= 1){ - requestAnimFrame(animLoop); - } - else{ - if (typeof config.onAnimationComplete == "function") config.onAnimationComplete(); - } - - } - - } - - //Declare global functions to be called within this namespace here. - - - // shim layer with setTimeout fallback - var requestAnimFrame = (function(){ - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - window.setTimeout(callback, 1000 / 60); - }; - })(); - - function calculateScale(drawingHeight,maxSteps,minSteps,maxValue,minValue,labelTemplateString){ - var graphMin,graphMax,graphRange,stepValue,numberOfSteps,valueRange,rangeOrderOfMagnitude,decimalNum; - - valueRange = maxValue - minValue; - - rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange); - - graphMin = Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); - - graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude); - - graphRange = graphMax - graphMin; - - stepValue = Math.pow(10, rangeOrderOfMagnitude); - - numberOfSteps = Math.round(graphRange / stepValue); - - //Compare number of steps to the max and min for that size graph, and add in half steps if need be. - while(numberOfSteps < minSteps || numberOfSteps > maxSteps) { - if (numberOfSteps < minSteps){ - stepValue /= 2; - numberOfSteps = Math.round(graphRange/stepValue); - } - else{ - stepValue *=2; - numberOfSteps = Math.round(graphRange/stepValue); - } - }; - - - - //Create an array of all the labels by interpolating the string. - - var labels = []; - - if(labelTemplateString){ - //Fix floating point errors by setting to fixed the on the same decimal as the stepValue. - for (var i=1; i maxValue ) { - return maxValue; - } - } - if(isNumber(minValue)){ - if ( valueToCap < minValue ){ - return minValue; - } - } - return valueToCap; - } - function getDecimalPlaces (num){ - var numberOfDecimalPlaces; - if (num%1!=0){ - return num.toString().split(".")[1].length - } - else{ - return 0; - } - - } - - function mergeChartConfig(defaults,userDefined){ - var returnObj = {}; - for (var attrname in defaults) { returnObj[attrname] = defaults[attrname]; } - for (var attrname in userDefined) { returnObj[attrname] = userDefined[attrname]; } - return returnObj; - } - - //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/ - var cache = {}; - - function tmpl(str, data){ - // Figure out if we're getting a template, or if we need to - // load the template - and be sure to cache the result. - var fn = !/\W/.test(str) ? - cache[str] = cache[str] || - tmpl(document.getElementById(str).innerHTML) : - - // Generate a reusable function that will serve as a template - // generator (and which will be cached). - new Function("obj", - "var p=[],print=function(){p.push.apply(p,arguments);};" + - - // Introduce the data as local variables using with(){} - "with(obj){p.push('" + - - // Convert the template into pure JavaScript - str - .replace(/[\r\t\n]/g, " ") - .split("<%").join("\t") - .replace(/((^|%>)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") - + "');}return p.join('');"); - - // Provide some basic currying to the user - return data ? fn( data ) : fn; - }; -} - - - diff --git a/system/templates/js/chart-js/site/assets/effects.js b/system/templates/js/chart-js/site/assets/effects.js deleted file mode 100755 index 19361f23..00000000 --- a/system/templates/js/chart-js/site/assets/effects.js +++ /dev/null @@ -1,320 +0,0 @@ -$(window).load(function() { - var lineChartData = { - labels : ["January","February","March","April","May","June","July"], - datasets : [ - { - fillColor : "rgba(220,220,220,0.5)", - strokeColor : "rgba(220,220,220,1)", - pointColor : "rgba(220,220,220,1)", - pointStrokeColor : "#fff", - data : [65,59,90,81,56,55,40] - }, - { - fillColor : "rgba(151,187,205,0.5)", - strokeColor : "rgba(151,187,205,1)", - pointColor : "rgba(151,187,205,1)", - pointStrokeColor : "#fff", - data : [28,48,40,19,96,27,100] - } - ] - }; - - var barChartData = { - labels : ["January","February","March","April","May","June","July"], - datasets : [ - { - fillColor : "rgba(220,220,220,0.5)", - strokeColor : "rgba(220,220,220,1)", - data : [65,59,90,81,56,55,40] - }, - { - fillColor : "rgba(151,187,205,0.5)", - strokeColor : "rgba(151,187,205,1)", - data : [28,48,40,19,96,27,100] - } - ] - - }; - - var radarChartData = { - labels : ["A","B","C","D","E","F","G"], - datasets : [ - { - fillColor : "rgba(220,220,220,0.5)", - strokeColor : "rgba(220,220,220,1)", - pointColor : "rgba(220,220,220,1)", - pointStrokeColor : "#fff", - data : [65,59,90,81,56,55,40] - }, - { - fillColor : "rgba(151,187,205,0.5)", - strokeColor : "rgba(151,187,205,1)", - pointColor : "rgba(151,187,205,1)", - pointStrokeColor : "#fff", - data : [28,48,40,19,96,27,100] - } - ] - - }; - var pieChartData = [ - { - value: 30, - color:"#F38630" - }, - { - value : 50, - color : "#E0E4CC" - }, - { - value : 100, - color : "#69D2E7" - } - - ]; - var polarAreaChartData = [ - { - value : 62, - color: "#D97041" - }, - { - value : 70, - color: "#C7604C" - }, - { - value : 41, - color: "#21323D" - }, - { - value : 24, - color: "#9D9B7F" - }, - { - value : 55, - color: "#7D4F6D" - }, - { - value : 18, - color: "#584A5E" - } - ]; - var doughnutChartData = [ - { - value: 30, - color:"#F7464A" - }, - { - value : 50, - color : "#46BFBD" - }, - { - value : 100, - color : "#FDB45C" - }, - { - value : 40, - color : "#949FB1" - }, - { - value : 120, - color : "#4D5360" - } - - ]; - - var globalGraphSettings = {animation : Modernizr.canvas}; - - setIntroChart(); - - function setIntroChart(){ - var ctx = document.getElementById("introChart").getContext("2d"); - - new Chart(ctx).Line(lineChartData,{animation: Modernizr.canvas, scaleShowLabels : false, scaleFontColor : "#767C8D"}); - }; - - function showLineChart(){ - var ctx = document.getElementById("lineChartCanvas").getContext("2d"); - new Chart(ctx).Line(lineChartData,globalGraphSettings); - }; - function showBarChart(){ - var ctx = document.getElementById("barChartCanvas").getContext("2d"); - new Chart(ctx).Bar(barChartData,globalGraphSettings); - }; - function showRadarChart(){ - var ctx = document.getElementById("radarChartCanvas").getContext("2d"); - new Chart(ctx).Radar(radarChartData,globalGraphSettings); - } - function showPolarAreaChart(){ - var ctx = document.getElementById("polarAreaChartCanvas").getContext("2d"); - new Chart(ctx).PolarArea(polarAreaChartData,globalGraphSettings); - } - function showPieChart(){ - var ctx = document.getElementById("pieChartCanvas").getContext("2d"); - new Chart(ctx).Pie(pieChartData,globalGraphSettings); - }; - function showDoughnutChart(){ - var ctx = document.getElementById("doughnutChartCanvas").getContext("2d"); - new Chart(ctx).Doughnut(doughnutChartData,globalGraphSettings); - }; - - var graphInitDelay = 300; - - //Set up each of the inview events here. - $("#lineChart").on("inview",function(){ - var $this = $(this); - $this.removeClass("hidden").off("inview"); - setTimeout(showLineChart,graphInitDelay); - }); - $("#barChart").on("inview",function(){ - var $this = $(this); - $this.removeClass("hidden").off("inview"); - setTimeout(showBarChart,graphInitDelay); - }); - - $("#radarChart").on("inview",function(){ - var $this = $(this); - $this.removeClass("hidden").off("inview"); - setTimeout(showRadarChart,graphInitDelay); - }); - $("#pieChart").on("inview",function(){ - var $this = $(this); - $this.removeClass("hidden").off("inview"); - setTimeout(showPieChart,graphInitDelay); - }); - $("#polarAreaChart").on("inview",function(){ - var $this = $(this); - $this.removeClass("hidden").off("inview"); - setTimeout(showPolarAreaChart,graphInitDelay); - }); - $("#doughnutChart").on("inview",function(){ - var $this = $(this); - $this.removeClass("hidden").off("inview"); - setTimeout(showDoughnutChart,graphInitDelay); - }); - - }); - - /** - * author Christopher Blum - * - based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/ - * - forked from http://github.com/zuk/jquery.inview/ - */ - (function ($) { - var inviewObjects = {}, viewportSize, viewportOffset, - d = document, w = window, documentElement = d.documentElement, expando = $.expando; - - $.event.special.inview = { - add: function(data) { - inviewObjects[data.guid + "-" + this[expando]] = { data: data, $element: $(this) }; - }, - - remove: function(data) { - try { delete inviewObjects[data.guid + "-" + this[expando]]; } catch(e) {} - } - }; - - function getViewportSize() { - var mode, domObject, size = { height: w.innerHeight, width: w.innerWidth }; - - // if this is correct then return it. iPad has compat Mode, so will - // go into check clientHeight/clientWidth (which has the wrong value). - if (!size.height) { - mode = d.compatMode; - if (mode || !$.support.boxModel) { // IE, Gecko - domObject = mode === 'CSS1Compat' ? - documentElement : // Standards - d.body; // Quirks - size = { - height: domObject.clientHeight, - width: domObject.clientWidth - }; - } - } - - return size; - } - - function getViewportOffset() { - return { - top: w.pageYOffset || documentElement.scrollTop || d.body.scrollTop, - left: w.pageXOffset || documentElement.scrollLeft || d.body.scrollLeft - }; - } - - function checkInView() { - var $elements = $(), elementsLength, i = 0; - - $.each(inviewObjects, function(i, inviewObject) { - var selector = inviewObject.data.selector, - $element = inviewObject.$element; - $elements = $elements.add(selector ? $element.find(selector) : $element); - }); - - elementsLength = $elements.length; - if (elementsLength) { - viewportSize = viewportSize || getViewportSize(); - viewportOffset = viewportOffset || getViewportOffset(); - - for (; i viewportOffset.top && - elementOffset.top < viewportOffset.top + viewportSize.height && - elementOffset.left + elementSize.width > viewportOffset.left && - elementOffset.left < viewportOffset.left + viewportSize.width) { - visiblePartX = (viewportOffset.left > elementOffset.left ? - 'right' : (viewportOffset.left + viewportSize.width) < (elementOffset.left + elementSize.width) ? - 'left' : 'both'); - visiblePartY = (viewportOffset.top > elementOffset.top ? - 'bottom' : (viewportOffset.top + viewportSize.height) < (elementOffset.top + elementSize.height) ? - 'top' : 'both'); - visiblePartsMerged = visiblePartX + "-" + visiblePartY; - if (!inView || inView !== visiblePartsMerged) { - $element.data('inview', visiblePartsMerged).trigger('inview', [true, visiblePartX, visiblePartY]); - } - } else if (inView) { - $element.data('inview', false).trigger('inview', [false]); - } - } - } - } - - $(w).bind("scroll resize", function() { - viewportSize = viewportOffset = null; - }); - - // IE < 9 scrolls to focused elements without firing the "scroll" event - if (!documentElement.addEventListener && documentElement.attachEvent) { - documentElement.attachEvent("onfocusin", function() { - viewportOffset = null; - }); - } - - // Use setInterval in order to also make sure this captures elements within - // "overflow:scroll" elements or elements that appeared in the dom tree due to - // dom manipulation and reflow - // old: $(window).scroll(checkInView); - // - // By the way, iOS (iPad, iPhone, ...) seems to not execute, or at least delays - // intervals while the user scrolls. Therefore the inview event might fire a bit late there - setInterval(checkInView, 250); - })(jQuery); \ No newline at end of file diff --git a/system/templates/js/chart-js/site/assets/excanvas.js b/system/templates/js/chart-js/site/assets/excanvas.js deleted file mode 100755 index 00b316ca..00000000 --- a/system/templates/js/chart-js/site/assets/excanvas.js +++ /dev/null @@ -1,1416 +0,0 @@ -// Copyright 2006 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -// Known Issues: -// -// * Patterns only support repeat. -// * Radial gradient are not implemented. The VML version of these look very -// different from the canvas one. -// * Clipping paths are not implemented. -// * Coordsize. The width and height attribute have higher priority than the -// width and height style values which isn't correct. -// * Painting mode isn't implemented. -// * Canvas width/height should is using content-box by default. IE in -// Quirks mode will draw the canvas using border-box. Either change your -// doctype to HTML5 -// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype) -// or use Box Sizing Behavior from WebFX -// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html) -// * Non uniform scaling does not correctly scale strokes. -// * Optimize. There is always room for speed improvements. - -// Only add this code if we do not already have a canvas implementation -if (!document.createElement('canvas').getContext) { - -(function() { - - // alias some functions to make (compiled) code shorter - var m = Math; - var mr = m.round; - var ms = m.sin; - var mc = m.cos; - var abs = m.abs; - var sqrt = m.sqrt; - - // this is used for sub pixel precision - var Z = 10; - var Z2 = Z / 2; - - var IE_VERSION = +navigator.userAgent.match(/MSIE ([\d.]+)?/)[1]; - - /** - * This funtion is assigned to the elements as element.getContext(). - * @this {HTMLElement} - * @return {CanvasRenderingContext2D_} - */ - function getContext() { - return this.context_ || - (this.context_ = new CanvasRenderingContext2D_(this)); - } - - var slice = Array.prototype.slice; - - /** - * Binds a function to an object. The returned function will always use the - * passed in {@code obj} as {@code this}. - * - * Example: - * - * g = bind(f, obj, a, b) - * g(c, d) // will do f.call(obj, a, b, c, d) - * - * @param {Function} f The function to bind the object to - * @param {Object} obj The object that should act as this when the function - * is called - * @param {*} var_args Rest arguments that will be used as the initial - * arguments when the function is called - * @return {Function} A new function that has bound this - */ - function bind(f, obj, var_args) { - var a = slice.call(arguments, 2); - return function() { - return f.apply(obj, a.concat(slice.call(arguments))); - }; - } - - function encodeHtmlAttribute(s) { - return String(s).replace(/&/g, '&').replace(/"/g, '"'); - } - - function addNamespace(doc, prefix, urn) { - if (!doc.namespaces[prefix]) { - doc.namespaces.add(prefix, urn, '#default#VML'); - } - } - - function addNamespacesAndStylesheet(doc) { - addNamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml'); - addNamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office'); - - // Setup default CSS. Only add one style sheet per document - if (!doc.styleSheets['ex_canvas_']) { - var ss = doc.createStyleSheet(); - ss.owningElement.id = 'ex_canvas_'; - ss.cssText = 'canvas{display:inline-block;overflow:hidden;' + - // default size is 300x150 in Gecko and Opera - 'text-align:left;width:300px;height:150px}'; - } - } - - // Add namespaces and stylesheet at startup. - addNamespacesAndStylesheet(document); - - var G_vmlCanvasManager_ = { - init: function(opt_doc) { - var doc = opt_doc || document; - // Create a dummy element so that IE will allow canvas elements to be - // recognized. - doc.createElement('canvas'); - doc.attachEvent('onreadystatechange', bind(this.init_, this, doc)); - }, - - init_: function(doc) { - // find all canvas elements - var els = doc.getElementsByTagName('canvas'); - for (var i = 0; i < els.length; i++) { - this.initElement(els[i]); - } - }, - - /** - * Public initializes a canvas element so that it can be used as canvas - * element from now on. This is called automatically before the page is - * loaded but if you are creating elements using createElement you need to - * make sure this is called on the element. - * @param {HTMLElement} el The canvas element to initialize. - * @return {HTMLElement} the element that was created. - */ - initElement: function(el) { - if (!el.getContext) { - el.getContext = getContext; - - // Add namespaces and stylesheet to document of the element. - addNamespacesAndStylesheet(el.ownerDocument); - - // Remove fallback content. There is no way to hide text nodes so we - // just remove all childNodes. We could hide all elements and remove - // text nodes but who really cares about the fallback content. - el.innerHTML = ''; - - // do not use inline function because that will leak memory - el.attachEvent('onpropertychange', onPropertyChange); - el.attachEvent('onresize', onResize); - - var attrs = el.attributes; - if (attrs.width && attrs.width.specified) { - // TODO: use runtimeStyle and coordsize - // el.getContext().setWidth_(attrs.width.nodeValue); - el.style.width = attrs.width.nodeValue + 'px'; - } else { - el.width = el.clientWidth; - } - if (attrs.height && attrs.height.specified) { - // TODO: use runtimeStyle and coordsize - // el.getContext().setHeight_(attrs.height.nodeValue); - el.style.height = attrs.height.nodeValue + 'px'; - } else { - el.height = el.clientHeight; - } - //el.getContext().setCoordsize_() - } - return el; - } - }; - - function onPropertyChange(e) { - var el = e.srcElement; - - switch (e.propertyName) { - case 'width': - el.getContext().clearRect(); - el.style.width = el.attributes.width.nodeValue + 'px'; - // In IE8 this does not trigger onresize. - el.firstChild.style.width = el.clientWidth + 'px'; - break; - case 'height': - el.getContext().clearRect(); - el.style.height = el.attributes.height.nodeValue + 'px'; - el.firstChild.style.height = el.clientHeight + 'px'; - break; - } - } - - function onResize(e) { - var el = e.srcElement; - if (el.firstChild) { - el.firstChild.style.width = el.clientWidth + 'px'; - el.firstChild.style.height = el.clientHeight + 'px'; - } - } - - G_vmlCanvasManager_.init(); - - // precompute "00" to "FF" - var decToHex = []; - for (var i = 0; i < 16; i++) { - for (var j = 0; j < 16; j++) { - decToHex[i * 16 + j] = i.toString(16) + j.toString(16); - } - } - - function createMatrixIdentity() { - return [ - [1, 0, 0], - [0, 1, 0], - [0, 0, 1] - ]; - } - - function matrixMultiply(m1, m2) { - var result = createMatrixIdentity(); - - for (var x = 0; x < 3; x++) { - for (var y = 0; y < 3; y++) { - var sum = 0; - - for (var z = 0; z < 3; z++) { - sum += m1[x][z] * m2[z][y]; - } - - result[x][y] = sum; - } - } - return result; - } - - function copyState(o1, o2) { - o2.fillStyle = o1.fillStyle; - o2.lineCap = o1.lineCap; - o2.lineJoin = o1.lineJoin; - o2.lineWidth = o1.lineWidth; - o2.miterLimit = o1.miterLimit; - o2.shadowBlur = o1.shadowBlur; - o2.shadowColor = o1.shadowColor; - o2.shadowOffsetX = o1.shadowOffsetX; - o2.shadowOffsetY = o1.shadowOffsetY; - o2.strokeStyle = o1.strokeStyle; - o2.globalAlpha = o1.globalAlpha; - o2.font = o1.font; - o2.textAlign = o1.textAlign; - o2.textBaseline = o1.textBaseline; - o2.arcScaleX_ = o1.arcScaleX_; - o2.arcScaleY_ = o1.arcScaleY_; - o2.lineScale_ = o1.lineScale_; - } - - var colorData = { - aliceblue: '#F0F8FF', - antiquewhite: '#FAEBD7', - aquamarine: '#7FFFD4', - azure: '#F0FFFF', - beige: '#F5F5DC', - bisque: '#FFE4C4', - black: '#000000', - blanchedalmond: '#FFEBCD', - blueviolet: '#8A2BE2', - brown: '#A52A2A', - burlywood: '#DEB887', - cadetblue: '#5F9EA0', - chartreuse: '#7FFF00', - chocolate: '#D2691E', - coral: '#FF7F50', - cornflowerblue: '#6495ED', - cornsilk: '#FFF8DC', - crimson: '#DC143C', - cyan: '#00FFFF', - darkblue: '#00008B', - darkcyan: '#008B8B', - darkgoldenrod: '#B8860B', - darkgray: '#A9A9A9', - darkgreen: '#006400', - darkgrey: '#A9A9A9', - darkkhaki: '#BDB76B', - darkmagenta: '#8B008B', - darkolivegreen: '#556B2F', - darkorange: '#FF8C00', - darkorchid: '#9932CC', - darkred: '#8B0000', - darksalmon: '#E9967A', - darkseagreen: '#8FBC8F', - darkslateblue: '#483D8B', - darkslategray: '#2F4F4F', - darkslategrey: '#2F4F4F', - darkturquoise: '#00CED1', - darkviolet: '#9400D3', - deeppink: '#FF1493', - deepskyblue: '#00BFFF', - dimgray: '#696969', - dimgrey: '#696969', - dodgerblue: '#1E90FF', - firebrick: '#B22222', - floralwhite: '#FFFAF0', - forestgreen: '#228B22', - gainsboro: '#DCDCDC', - ghostwhite: '#F8F8FF', - gold: '#FFD700', - goldenrod: '#DAA520', - grey: '#808080', - greenyellow: '#ADFF2F', - honeydew: '#F0FFF0', - hotpink: '#FF69B4', - indianred: '#CD5C5C', - indigo: '#4B0082', - ivory: '#FFFFF0', - khaki: '#F0E68C', - lavender: '#E6E6FA', - lavenderblush: '#FFF0F5', - lawngreen: '#7CFC00', - lemonchiffon: '#FFFACD', - lightblue: '#ADD8E6', - lightcoral: '#F08080', - lightcyan: '#E0FFFF', - lightgoldenrodyellow: '#FAFAD2', - lightgreen: '#90EE90', - lightgrey: '#D3D3D3', - lightpink: '#FFB6C1', - lightsalmon: '#FFA07A', - lightseagreen: '#20B2AA', - lightskyblue: '#87CEFA', - lightslategray: '#778899', - lightslategrey: '#778899', - lightsteelblue: '#B0C4DE', - lightyellow: '#FFFFE0', - limegreen: '#32CD32', - linen: '#FAF0E6', - magenta: '#FF00FF', - mediumaquamarine: '#66CDAA', - mediumblue: '#0000CD', - mediumorchid: '#BA55D3', - mediumpurple: '#9370DB', - mediumseagreen: '#3CB371', - mediumslateblue: '#7B68EE', - mediumspringgreen: '#00FA9A', - mediumturquoise: '#48D1CC', - mediumvioletred: '#C71585', - midnightblue: '#191970', - mintcream: '#F5FFFA', - mistyrose: '#FFE4E1', - moccasin: '#FFE4B5', - navajowhite: '#FFDEAD', - oldlace: '#FDF5E6', - olivedrab: '#6B8E23', - orange: '#FFA500', - orangered: '#FF4500', - orchid: '#DA70D6', - palegoldenrod: '#EEE8AA', - palegreen: '#98FB98', - paleturquoise: '#AFEEEE', - palevioletred: '#DB7093', - papayawhip: '#FFEFD5', - peachpuff: '#FFDAB9', - peru: '#CD853F', - pink: '#FFC0CB', - plum: '#DDA0DD', - powderblue: '#B0E0E6', - rosybrown: '#BC8F8F', - royalblue: '#4169E1', - saddlebrown: '#8B4513', - salmon: '#FA8072', - sandybrown: '#F4A460', - seagreen: '#2E8B57', - seashell: '#FFF5EE', - sienna: '#A0522D', - skyblue: '#87CEEB', - slateblue: '#6A5ACD', - slategray: '#708090', - slategrey: '#708090', - snow: '#FFFAFA', - springgreen: '#00FF7F', - steelblue: '#4682B4', - tan: '#D2B48C', - thistle: '#D8BFD8', - tomato: '#FF6347', - turquoise: '#40E0D0', - violet: '#EE82EE', - wheat: '#F5DEB3', - whitesmoke: '#F5F5F5', - yellowgreen: '#9ACD32' - }; - - - function getRgbHslContent(styleString) { - var start = styleString.indexOf('(', 3); - var end = styleString.indexOf(')', start + 1); - var parts = styleString.substring(start + 1, end).split(','); - // add alpha if needed - if (parts.length != 4 || styleString.charAt(3) != 'a') { - parts[3] = 1; - } - return parts; - } - - function percent(s) { - return parseFloat(s) / 100; - } - - function clamp(v, min, max) { - return Math.min(max, Math.max(min, v)); - } - - function hslToRgb(parts){ - var r, g, b, h, s, l; - h = parseFloat(parts[0]) / 360 % 360; - if (h < 0) - h++; - s = clamp(percent(parts[1]), 0, 1); - l = clamp(percent(parts[2]), 0, 1); - if (s == 0) { - r = g = b = l; // achromatic - } else { - var q = l < 0.5 ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - r = hueToRgb(p, q, h + 1 / 3); - g = hueToRgb(p, q, h); - b = hueToRgb(p, q, h - 1 / 3); - } - - return '#' + decToHex[Math.floor(r * 255)] + - decToHex[Math.floor(g * 255)] + - decToHex[Math.floor(b * 255)]; - } - - function hueToRgb(m1, m2, h) { - if (h < 0) - h++; - if (h > 1) - h--; - - if (6 * h < 1) - return m1 + (m2 - m1) * 6 * h; - else if (2 * h < 1) - return m2; - else if (3 * h < 2) - return m1 + (m2 - m1) * (2 / 3 - h) * 6; - else - return m1; - } - - var processStyleCache = {}; - - function processStyle(styleString) { - if (styleString in processStyleCache) { - return processStyleCache[styleString]; - } - - var str, alpha = 1; - - styleString = String(styleString); - if (styleString.charAt(0) == '#') { - str = styleString; - } else if (/^rgb/.test(styleString)) { - var parts = getRgbHslContent(styleString); - var str = '#', n; - for (var i = 0; i < 3; i++) { - if (parts[i].indexOf('%') != -1) { - n = Math.floor(percent(parts[i]) * 255); - } else { - n = +parts[i]; - } - str += decToHex[clamp(n, 0, 255)]; - } - alpha = +parts[3]; - } else if (/^hsl/.test(styleString)) { - var parts = getRgbHslContent(styleString); - str = hslToRgb(parts); - alpha = parts[3]; - } else { - str = colorData[styleString] || styleString; - } - return processStyleCache[styleString] = {color: str, alpha: alpha}; - } - - var DEFAULT_STYLE = { - style: 'normal', - variant: 'normal', - weight: 'normal', - size: 10, - family: 'sans-serif' - }; - - // Internal text style cache - var fontStyleCache = {}; - - function processFontStyle(styleString) { - if (fontStyleCache[styleString]) { - return fontStyleCache[styleString]; - } - - var el = document.createElement('div'); - var style = el.style; - try { - style.font = styleString; - } catch (ex) { - // Ignore failures to set to invalid font. - } - - return fontStyleCache[styleString] = { - style: style.fontStyle || DEFAULT_STYLE.style, - variant: style.fontVariant || DEFAULT_STYLE.variant, - weight: style.fontWeight || DEFAULT_STYLE.weight, - size: style.fontSize || DEFAULT_STYLE.size, - family: style.fontFamily || DEFAULT_STYLE.family - }; - } - - function getComputedStyle(style, element) { - var computedStyle = {}; - - for (var p in style) { - computedStyle[p] = style[p]; - } - - // Compute the size - var canvasFontSize = parseFloat(element.currentStyle.fontSize), - fontSize = parseFloat(style.size); - - if (typeof style.size == 'number') { - computedStyle.size = style.size; - } else if (style.size.indexOf('px') != -1) { - computedStyle.size = fontSize; - } else if (style.size.indexOf('em') != -1) { - computedStyle.size = canvasFontSize * fontSize; - } else if(style.size.indexOf('%') != -1) { - computedStyle.size = (canvasFontSize / 100) * fontSize; - } else if (style.size.indexOf('pt') != -1) { - computedStyle.size = fontSize / .75; - } else { - computedStyle.size = canvasFontSize; - } - - // Different scaling between normal text and VML text. This was found using - // trial and error to get the same size as non VML text. - computedStyle.size *= 0.981; - - return computedStyle; - } - - function buildStyle(style) { - return style.style + ' ' + style.variant + ' ' + style.weight + ' ' + - style.size + 'px ' + style.family; - } - - var lineCapMap = { - 'butt': 'flat', - 'round': 'round' - }; - - function processLineCap(lineCap) { - return lineCapMap[lineCap] || 'square'; - } - - /** - * This class implements CanvasRenderingContext2D interface as described by - * the WHATWG. - * @param {HTMLElement} canvasElement The element that the 2D context should - * be associated with - */ - function CanvasRenderingContext2D_(canvasElement) { - this.m_ = createMatrixIdentity(); - - this.mStack_ = []; - this.aStack_ = []; - this.currentPath_ = []; - - // Canvas context properties - this.strokeStyle = '#000'; - this.fillStyle = '#000'; - - this.lineWidth = 1; - this.lineJoin = 'miter'; - this.lineCap = 'butt'; - this.miterLimit = Z * 1; - this.globalAlpha = 1; - this.font = '10px sans-serif'; - this.textAlign = 'left'; - this.textBaseline = 'alphabetic'; - this.canvas = canvasElement; - - var cssText = 'width:' + canvasElement.clientWidth + 'px;height:' + - canvasElement.clientHeight + 'px;overflow:hidden;position:absolute'; - var el = canvasElement.ownerDocument.createElement('div'); - el.style.cssText = cssText; - canvasElement.appendChild(el); - - var overlayEl = el.cloneNode(false); - // Use a non transparent background. - overlayEl.style.backgroundColor = 'red'; - overlayEl.style.filter = 'alpha(opacity=0)'; - canvasElement.appendChild(overlayEl); - - this.element_ = el; - this.arcScaleX_ = 1; - this.arcScaleY_ = 1; - this.lineScale_ = 1; - } - - var contextPrototype = CanvasRenderingContext2D_.prototype; - contextPrototype.clearRect = function() { - if (this.textMeasureEl_) { - this.textMeasureEl_.removeNode(true); - this.textMeasureEl_ = null; - } - this.element_.innerHTML = ''; - }; - - contextPrototype.beginPath = function() { - // TODO: Branch current matrix so that save/restore has no effect - // as per safari docs. - this.currentPath_ = []; - }; - - contextPrototype.moveTo = function(aX, aY) { - var p = getCoords(this, aX, aY); - this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y}); - this.currentX_ = p.x; - this.currentY_ = p.y; - }; - - contextPrototype.lineTo = function(aX, aY) { - var p = getCoords(this, aX, aY); - this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y}); - - this.currentX_ = p.x; - this.currentY_ = p.y; - }; - - contextPrototype.bezierCurveTo = function(aCP1x, aCP1y, - aCP2x, aCP2y, - aX, aY) { - var p = getCoords(this, aX, aY); - var cp1 = getCoords(this, aCP1x, aCP1y); - var cp2 = getCoords(this, aCP2x, aCP2y); - bezierCurveTo(this, cp1, cp2, p); - }; - - // Helper function that takes the already fixed cordinates. - function bezierCurveTo(self, cp1, cp2, p) { - self.currentPath_.push({ - type: 'bezierCurveTo', - cp1x: cp1.x, - cp1y: cp1.y, - cp2x: cp2.x, - cp2y: cp2.y, - x: p.x, - y: p.y - }); - self.currentX_ = p.x; - self.currentY_ = p.y; - } - - contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) { - // the following is lifted almost directly from - // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes - - var cp = getCoords(this, aCPx, aCPy); - var p = getCoords(this, aX, aY); - - var cp1 = { - x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_), - y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_) - }; - var cp2 = { - x: cp1.x + (p.x - this.currentX_) / 3.0, - y: cp1.y + (p.y - this.currentY_) / 3.0 - }; - - bezierCurveTo(this, cp1, cp2, p); - }; - - contextPrototype.arc = function(aX, aY, aRadius, - aStartAngle, aEndAngle, aClockwise) { - aRadius *= Z; - var arcType = aClockwise ? 'at' : 'wa'; - - var xStart = aX + mc(aStartAngle) * aRadius - Z2; - var yStart = aY + ms(aStartAngle) * aRadius - Z2; - - var xEnd = aX + mc(aEndAngle) * aRadius - Z2; - var yEnd = aY + ms(aEndAngle) * aRadius - Z2; - - // IE won't render arches drawn counter clockwise if xStart == xEnd. - if (xStart == xEnd && !aClockwise) { - xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something - // that can be represented in binary - } - - var p = getCoords(this, aX, aY); - var pStart = getCoords(this, xStart, yStart); - var pEnd = getCoords(this, xEnd, yEnd); - - this.currentPath_.push({type: arcType, - x: p.x, - y: p.y, - radius: aRadius, - xStart: pStart.x, - yStart: pStart.y, - xEnd: pEnd.x, - yEnd: pEnd.y}); - - }; - - contextPrototype.rect = function(aX, aY, aWidth, aHeight) { - this.moveTo(aX, aY); - this.lineTo(aX + aWidth, aY); - this.lineTo(aX + aWidth, aY + aHeight); - this.lineTo(aX, aY + aHeight); - this.closePath(); - }; - - contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) { - var oldPath = this.currentPath_; - this.beginPath(); - - this.moveTo(aX, aY); - this.lineTo(aX + aWidth, aY); - this.lineTo(aX + aWidth, aY + aHeight); - this.lineTo(aX, aY + aHeight); - this.closePath(); - this.stroke(); - - this.currentPath_ = oldPath; - }; - - contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) { - var oldPath = this.currentPath_; - this.beginPath(); - - this.moveTo(aX, aY); - this.lineTo(aX + aWidth, aY); - this.lineTo(aX + aWidth, aY + aHeight); - this.lineTo(aX, aY + aHeight); - this.closePath(); - this.fill(); - - this.currentPath_ = oldPath; - }; - - contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) { - var gradient = new CanvasGradient_('gradient'); - gradient.x0_ = aX0; - gradient.y0_ = aY0; - gradient.x1_ = aX1; - gradient.y1_ = aY1; - return gradient; - }; - - contextPrototype.createRadialGradient = function(aX0, aY0, aR0, - aX1, aY1, aR1) { - var gradient = new CanvasGradient_('gradientradial'); - gradient.x0_ = aX0; - gradient.y0_ = aY0; - gradient.r0_ = aR0; - gradient.x1_ = aX1; - gradient.y1_ = aY1; - gradient.r1_ = aR1; - return gradient; - }; - - contextPrototype.drawImage = function(image, var_args) { - var dx, dy, dw, dh, sx, sy, sw, sh; - - // to find the original width we overide the width and height - var oldRuntimeWidth = image.runtimeStyle.width; - var oldRuntimeHeight = image.runtimeStyle.height; - image.runtimeStyle.width = 'auto'; - image.runtimeStyle.height = 'auto'; - - // get the original size - var w = image.width; - var h = image.height; - - // and remove overides - image.runtimeStyle.width = oldRuntimeWidth; - image.runtimeStyle.height = oldRuntimeHeight; - - if (arguments.length == 3) { - dx = arguments[1]; - dy = arguments[2]; - sx = sy = 0; - sw = dw = w; - sh = dh = h; - } else if (arguments.length == 5) { - dx = arguments[1]; - dy = arguments[2]; - dw = arguments[3]; - dh = arguments[4]; - sx = sy = 0; - sw = w; - sh = h; - } else if (arguments.length == 9) { - sx = arguments[1]; - sy = arguments[2]; - sw = arguments[3]; - sh = arguments[4]; - dx = arguments[5]; - dy = arguments[6]; - dw = arguments[7]; - dh = arguments[8]; - } else { - throw Error('Invalid number of arguments'); - } - - var d = getCoords(this, dx, dy); - - var w2 = sw / 2; - var h2 = sh / 2; - - var vmlStr = []; - - var W = 10; - var H = 10; - - // For some reason that I've now forgotten, using divs didn't work - vmlStr.push(' ' , - '', - ''); - - this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join('')); - }; - - contextPrototype.stroke = function(aFill) { - var lineStr = []; - var lineOpen = false; - - var W = 10; - var H = 10; - - lineStr.push(''); - - if (!aFill) { - appendStroke(this, lineStr); - } else { - appendFill(this, lineStr, min, max); - } - - lineStr.push(''); - - this.element_.insertAdjacentHTML('beforeEnd', lineStr.join('')); - }; - - function appendStroke(ctx, lineStr) { - var a = processStyle(ctx.strokeStyle); - var color = a.color; - var opacity = a.alpha * ctx.globalAlpha; - var lineWidth = ctx.lineScale_ * ctx.lineWidth; - - // VML cannot correctly render a line if the width is less than 1px. - // In that case, we dilute the color to make the line look thinner. - if (lineWidth < 1) { - opacity *= lineWidth; - } - - lineStr.push( - '' - ); - } - - function appendFill(ctx, lineStr, min, max) { - var fillStyle = ctx.fillStyle; - var arcScaleX = ctx.arcScaleX_; - var arcScaleY = ctx.arcScaleY_; - var width = max.x - min.x; - var height = max.y - min.y; - if (fillStyle instanceof CanvasGradient_) { - // TODO: Gradients transformed with the transformation matrix. - var angle = 0; - var focus = {x: 0, y: 0}; - - // additional offset - var shift = 0; - // scale factor for offset - var expansion = 1; - - if (fillStyle.type_ == 'gradient') { - var x0 = fillStyle.x0_ / arcScaleX; - var y0 = fillStyle.y0_ / arcScaleY; - var x1 = fillStyle.x1_ / arcScaleX; - var y1 = fillStyle.y1_ / arcScaleY; - var p0 = getCoords(ctx, x0, y0); - var p1 = getCoords(ctx, x1, y1); - var dx = p1.x - p0.x; - var dy = p1.y - p0.y; - angle = Math.atan2(dx, dy) * 180 / Math.PI; - - // The angle should be a non-negative number. - if (angle < 0) { - angle += 360; - } - - // Very small angles produce an unexpected result because they are - // converted to a scientific notation string. - if (angle < 1e-6) { - angle = 0; - } - } else { - var p0 = getCoords(ctx, fillStyle.x0_, fillStyle.y0_); - focus = { - x: (p0.x - min.x) / width, - y: (p0.y - min.y) / height - }; - - width /= arcScaleX * Z; - height /= arcScaleY * Z; - var dimension = m.max(width, height); - shift = 2 * fillStyle.r0_ / dimension; - expansion = 2 * fillStyle.r1_ / dimension - shift; - } - - // We need to sort the color stops in ascending order by offset, - // otherwise IE won't interpret it correctly. - var stops = fillStyle.colors_; - stops.sort(function(cs1, cs2) { - return cs1.offset - cs2.offset; - }); - - var length = stops.length; - var color1 = stops[0].color; - var color2 = stops[length - 1].color; - var opacity1 = stops[0].alpha * ctx.globalAlpha; - var opacity2 = stops[length - 1].alpha * ctx.globalAlpha; - - var colors = []; - for (var i = 0; i < length; i++) { - var stop = stops[i]; - colors.push(stop.offset * expansion + shift + ' ' + stop.color); - } - - // When colors attribute is used, the meanings of opacity and o:opacity2 - // are reversed. - lineStr.push(''); - } else if (fillStyle instanceof CanvasPattern_) { - if (width && height) { - var deltaLeft = -min.x; - var deltaTop = -min.y; - lineStr.push(''); - } - } else { - var a = processStyle(ctx.fillStyle); - var color = a.color; - var opacity = a.alpha * ctx.globalAlpha; - lineStr.push(''); - } - } - - contextPrototype.fill = function() { - this.stroke(true); - }; - - contextPrototype.closePath = function() { - this.currentPath_.push({type: 'close'}); - }; - - function getCoords(ctx, aX, aY) { - var m = ctx.m_; - return { - x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2, - y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2 - }; - }; - - contextPrototype.save = function() { - var o = {}; - copyState(this, o); - this.aStack_.push(o); - this.mStack_.push(this.m_); - this.m_ = matrixMultiply(createMatrixIdentity(), this.m_); - }; - - contextPrototype.restore = function() { - if (this.aStack_.length) { - copyState(this.aStack_.pop(), this); - this.m_ = this.mStack_.pop(); - } - }; - - function matrixIsFinite(m) { - return isFinite(m[0][0]) && isFinite(m[0][1]) && - isFinite(m[1][0]) && isFinite(m[1][1]) && - isFinite(m[2][0]) && isFinite(m[2][1]); - } - - function setM(ctx, m, updateLineScale) { - if (!matrixIsFinite(m)) { - return; - } - ctx.m_ = m; - - if (updateLineScale) { - // Get the line scale. - // Determinant of this.m_ means how much the area is enlarged by the - // transformation. So its square root can be used as a scale factor - // for width. - var det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; - ctx.lineScale_ = sqrt(abs(det)); - } - } - - contextPrototype.translate = function(aX, aY) { - var m1 = [ - [1, 0, 0], - [0, 1, 0], - [aX, aY, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), false); - }; - - contextPrototype.rotate = function(aRot) { - var c = mc(aRot); - var s = ms(aRot); - - var m1 = [ - [c, s, 0], - [-s, c, 0], - [0, 0, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), false); - }; - - contextPrototype.scale = function(aX, aY) { - this.arcScaleX_ *= aX; - this.arcScaleY_ *= aY; - var m1 = [ - [aX, 0, 0], - [0, aY, 0], - [0, 0, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), true); - }; - - contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) { - var m1 = [ - [m11, m12, 0], - [m21, m22, 0], - [dx, dy, 1] - ]; - - setM(this, matrixMultiply(m1, this.m_), true); - }; - - contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) { - var m = [ - [m11, m12, 0], - [m21, m22, 0], - [dx, dy, 1] - ]; - - setM(this, m, true); - }; - - /** - * The text drawing function. - * The maxWidth argument isn't taken in account, since no browser supports - * it yet. - */ - contextPrototype.drawText_ = function(text, x, y, maxWidth, stroke) { - var m = this.m_, - delta = 1000, - left = 0, - right = delta, - offset = {x: 0, y: 0}, - lineStr = []; - - var fontStyle = getComputedStyle(processFontStyle(this.font), - this.element_); - - var fontStyleString = buildStyle(fontStyle); - - var elementStyle = this.element_.currentStyle; - var textAlign = this.textAlign.toLowerCase(); - switch (textAlign) { - case 'left': - case 'center': - case 'right': - break; - case 'end': - textAlign = elementStyle.direction == 'ltr' ? 'right' : 'left'; - break; - case 'start': - textAlign = elementStyle.direction == 'rtl' ? 'right' : 'left'; - break; - default: - textAlign = 'left'; - } - - // 1.75 is an arbitrary number, as there is no info about the text baseline - switch (this.textBaseline) { - case 'hanging': - case 'top': - offset.y = fontStyle.size / 1.75; - break; - case 'middle': - break; - default: - case null: - case 'alphabetic': - case 'ideographic': - case 'bottom': - offset.y = -fontStyle.size / 2.25; - break; - } - - switch(textAlign) { - case 'right': - left = delta; - right = 0.05; - break; - case 'center': - left = right = delta / 2; - break; - } - - var d = getCoords(this, x + offset.x, y + offset.y); - - lineStr.push(''); - - if (stroke) { - appendStroke(this, lineStr); - } else { - // TODO: Fix the min and max params. - appendFill(this, lineStr, {x: -left, y: 0}, - {x: right, y: fontStyle.size}); - } - - var skewM = m[0][0].toFixed(3) + ',' + m[1][0].toFixed(3) + ',' + - m[0][1].toFixed(3) + ',' + m[1][1].toFixed(3) + ',0,0'; - - var skewOffset = mr(d.x / Z) + ',' + mr(d.y / Z); - - lineStr.push('', - '', - ''); - - this.element_.insertAdjacentHTML('beforeEnd', lineStr.join('')); - }; - - contextPrototype.fillText = function(text, x, y, maxWidth) { - this.drawText_(text, x, y, maxWidth, false); - }; - - contextPrototype.strokeText = function(text, x, y, maxWidth) { - this.drawText_(text, x, y, maxWidth, true); - }; - - contextPrototype.measureText = function(text) { - if (!this.textMeasureEl_) { - var s = ''; - this.element_.insertAdjacentHTML('beforeEnd', s); - this.textMeasureEl_ = this.element_.lastChild; - } - var doc = this.element_.ownerDocument; - this.textMeasureEl_.innerHTML = ''; - this.textMeasureEl_.style.font = this.font; - // Don't use innerHTML or innerText because they allow markup/whitespace. - this.textMeasureEl_.appendChild(doc.createTextNode(text)); - return {width: this.textMeasureEl_.offsetWidth}; - }; - - /******** STUBS ********/ - contextPrototype.clip = function() { - // TODO: Implement - }; - - contextPrototype.arcTo = function() { - // TODO: Implement - }; - - contextPrototype.createPattern = function(image, repetition) { - return new CanvasPattern_(image, repetition); - }; - - // Gradient / Pattern Stubs - function CanvasGradient_(aType) { - this.type_ = aType; - this.x0_ = 0; - this.y0_ = 0; - this.r0_ = 0; - this.x1_ = 0; - this.y1_ = 0; - this.r1_ = 0; - this.colors_ = []; - } - - CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) { - aColor = processStyle(aColor); - this.colors_.push({offset: aOffset, - color: aColor.color, - alpha: aColor.alpha}); - }; - - function CanvasPattern_(image, repetition) { - assertImageIsValid(image); - switch (repetition) { - case 'repeat': - case null: - case '': - this.repetition_ = 'repeat'; - break - case 'repeat-x': - case 'repeat-y': - case 'no-repeat': - this.repetition_ = repetition; - break; - default: - throwException('SYNTAX_ERR'); - } - - this.src_ = image.src; - this.width_ = image.width; - this.height_ = image.height; - } - - function throwException(s) { - throw new DOMException_(s); - } - - function assertImageIsValid(img) { - if (!img || img.nodeType != 1 || img.tagName != 'IMG') { - throwException('TYPE_MISMATCH_ERR'); - } - if (img.readyState != 'complete') { - throwException('INVALID_STATE_ERR'); - } - } - - function DOMException_(s) { - this.code = this[s]; - this.message = s +': DOM Exception ' + this.code; - } - var p = DOMException_.prototype = new Error; - p.INDEX_SIZE_ERR = 1; - p.DOMSTRING_SIZE_ERR = 2; - p.HIERARCHY_REQUEST_ERR = 3; - p.WRONG_DOCUMENT_ERR = 4; - p.INVALID_CHARACTER_ERR = 5; - p.NO_DATA_ALLOWED_ERR = 6; - p.NO_MODIFICATION_ALLOWED_ERR = 7; - p.NOT_FOUND_ERR = 8; - p.NOT_SUPPORTED_ERR = 9; - p.INUSE_ATTRIBUTE_ERR = 10; - p.INVALID_STATE_ERR = 11; - p.SYNTAX_ERR = 12; - p.INVALID_MODIFICATION_ERR = 13; - p.NAMESPACE_ERR = 14; - p.INVALID_ACCESS_ERR = 15; - p.VALIDATION_ERR = 16; - p.TYPE_MISMATCH_ERR = 17; - - // set up externs - G_vmlCanvasManager = G_vmlCanvasManager_; - CanvasRenderingContext2D = CanvasRenderingContext2D_; - CanvasGradient = CanvasGradient_; - CanvasPattern = CanvasPattern_; - DOMException = DOMException_; -})(); - -} // if \ No newline at end of file diff --git a/system/templates/js/chart-js/site/assets/html.png b/system/templates/js/chart-js/site/assets/html.png deleted file mode 100755 index 55439dc9..00000000 Binary files a/system/templates/js/chart-js/site/assets/html.png and /dev/null differ diff --git a/system/templates/js/chart-js/site/assets/simple.png b/system/templates/js/chart-js/site/assets/simple.png deleted file mode 100755 index 43c945d5..00000000 Binary files a/system/templates/js/chart-js/site/assets/simple.png and /dev/null differ diff --git a/system/templates/js/chart-js/site/index.html b/system/templates/js/chart-js/site/index.html deleted file mode 100755 index 855ba894..00000000 --- a/system/templates/js/chart-js/site/index.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - Chart.js | HTML5 Charts for your website. - - - - - - - - - - - - -
-
-
-
-
-

Chart.js

-

Easy, object oriented client side graphs for designers and developers

-
- - - - DocumentationDownload -
-
-
- -

6 Chart types

-

Visualise your data in different ways. Each of them animated, fully customisable and look great, even on retina displays.

-
-
- -

HTML5 Based

-

Chart.js uses the HTML5 canvas element. It supports all modern browsers, and polyfills provide support for IE7/8.

-
-
- -

Simple and flexible

-

Chart.js is dependency free, lightweight (4.5k when minified and gzipped) and offers loads of customisation options.

-
-
-
- - - - - - - - - - - -

Like what you see? Download Chart.js on Github or read detailed documentation

-
- - - - - diff --git a/system/templates/js/chart-js/site/styles.css b/system/templates/js/chart-js/site/styles.css deleted file mode 100755 index e24d05dc..00000000 --- a/system/templates/js/chart-js/site/styles.css +++ /dev/null @@ -1,205 +0,0 @@ -* { - padding: 0; - margin: 0; - color: inherit; - -webkit-font-smoothing: antialiased; - text-rendering: optimizeLegibility; -} -body { - color: #282b36; - border-top: 8px solid #282b36; -} -canvas { - font-family: "proxima-nova", sans-serif sans-serif; -} -.redBorder, -.greenBorder, -.yellowBorder { - width: 33.33%; - float: left; - height: 8px; -} -.redBorder { - background-color: #f33e6f; -} -.greenBorder { - background-color: #46bfbd; -} -.yellowBorder { - background-color: #fdb45c; -} -h1 { - font-family: "proxima-nova", sans-serif; - font-weight: 600; - font-size: 55px; - margin-top: 40px; -} -h2 { - font-family: "proxima-nova", sans-serif; - font-weight: 400; - margin-top: 20px; - font-size: 26px; - line-height: 40px; -} -h3 { - font-family: "proxima-nova", sans-serif; - font-weight: 600; - text-align: center; - margin: 20px 0; -} -h3 a { - color: #2d91ea; - text-decoration: none; - border-bottom: 1px solid #2d91ea; -} -p { - font-family: "proxima-nova", sans-serif; - line-height: 24px; - font-size: 18px; - color: #767c8d; -} -.btn { - display: inline-block; - padding: 20px; - font-family: "proxima-nova", sans-serif; - font-weight: 600; - color: #fff; - text-decoration: none; - border-radius: 5px; - text-align: center; - font-size: 18px; - -webkit-transition-property: background-color box-shadow; - -webkit-transition-duration: 200ms; - -webkit-transition-timing-function: ease-in-out; - -moz-transition-property: background-color box-shadow; - -moz-transition-duration: 200ms; - -moz-transition-timing-function: ease-in-out; - -ms-transition-property: background-color box-shadow; - -ms-transition-duration: 200ms; - -ms-transition-timing-function: ease-in-out; - -o-transition-property: background-color box-shadow; - -o-transition-duration: 200ms; - -o-transition-timing-function: ease-in-out; - transition-property: background-color box-shadow; - transition-duration: 200ms; - transition-timing-function: ease-in-out; -} -.btn:active { - box-shadow: inset 1px 1px 4px rgba(0, 0, 0, 0.25); -} -.btn.red { - background-color: #f33e6f; -} -.btn.red:hover { - background-color: #f2265d; -} -.btn.blue { - background-color: #2d91ea; -} -.btn.blue:hover { - background-color: #1785e6; -} -header { - width: 978px; - margin: 20px auto; - display: block; - position: relative; -} -header hgroup { - width: 50%; - padding: 20px 0; -} -header #introChart { - position: absolute; - top: 60px; - right: 0; -} -header .btn { - margin-right: 10px; - width: 180px; -} -footer { - width: 100%; - text-align: center; - background-color: #ebebeb; -} -footer p { - color: #767c8d; - font-family: "proxima-nova", sans-serif; - font-size: 16px; - padding: 20px 0; -} -section { - width: 978px; - margin: 40px auto; -} -section:before { - content: ''; - width: 600px; - margin: 0 auto; - border-top: 1px solid #ebebeb; - height: 20px; - display: block; -} -section:after { - content: ""; - display: table; - clear: both; -} -*section { - zoom: 1; -} -#features article { - width: 33.33%; - float: left; -} -#features article p { - display: block; - width: 90%; - margin: 0 auto; - text-align: center; -} -#features article img { - width: 250px; - height: 250px; - margin: 0 auto; - display: block; -} -#examples article { - -webkit-transition: opacity 200ms ease-in-out; - -ms-transition: opacity 200ms ease-in-out; - -moz-transition: opacity 200ms ease-in-out; - -o-transition: opacity 200ms ease-in-out; - transition: opacity 200ms ease-in-out; - position: relative; - margin-top: 20px; - clear: both; -} -#examples article:after { - content: ''; - width: 600px; - padding-top: 40px; - margin: 40px auto; - border-bottom: 1px solid #ebebeb; - height: 20px; - display: block; - clear: both; -} -#examples article p { - margin-top: 10px; -} -#examples article .half { - width: 50%; - float: left; -} -#examples article .canvasWrapper { - float: left; - width: 449px; - padding: 0 20px; -} -#examples h3 { - clear: both; -} -#examples .hidden { - opacity: 0; -} diff --git a/system/templates/js/chart-js/src/chart.js b/system/templates/js/chart-js/src/chart.js deleted file mode 100644 index 77d2bb63..00000000 --- a/system/templates/js/chart-js/src/chart.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @namespace Chart - */ -var Chart = require('./core/core.js')(); - -require('./core/core.helpers')(Chart); -require('./platforms/platform.js')(Chart); -require('./core/core.canvasHelpers')(Chart); -require('./core/core.plugin.js')(Chart); -require('./core/core.element')(Chart); -require('./core/core.animation')(Chart); -require('./core/core.controller')(Chart); -require('./core/core.datasetController')(Chart); -require('./core/core.layoutService')(Chart); -require('./core/core.scaleService')(Chart); -require('./core/core.ticks.js')(Chart); -require('./core/core.scale')(Chart); -require('./core/core.title')(Chart); -require('./core/core.legend')(Chart); -require('./core/core.interaction')(Chart); -require('./core/core.tooltip')(Chart); - -require('./elements/element.arc')(Chart); -require('./elements/element.line')(Chart); -require('./elements/element.point')(Chart); -require('./elements/element.rectangle')(Chart); - -require('./scales/scale.linearbase.js')(Chart); -require('./scales/scale.category')(Chart); -require('./scales/scale.linear')(Chart); -require('./scales/scale.logarithmic')(Chart); -require('./scales/scale.radialLinear')(Chart); -require('./scales/scale.time')(Chart); - -// Controllers must be loaded after elements -// See Chart.core.datasetController.dataElementType -require('./controllers/controller.bar')(Chart); -require('./controllers/controller.bubble')(Chart); -require('./controllers/controller.doughnut')(Chart); -require('./controllers/controller.line')(Chart); -require('./controllers/controller.polarArea')(Chart); -require('./controllers/controller.radar')(Chart); - -require('./charts/Chart.Bar')(Chart); -require('./charts/Chart.Bubble')(Chart); -require('./charts/Chart.Doughnut')(Chart); -require('./charts/Chart.Line')(Chart); -require('./charts/Chart.PolarArea')(Chart); -require('./charts/Chart.Radar')(Chart); -require('./charts/Chart.Scatter')(Chart); - -window.Chart = module.exports = Chart; diff --git a/system/templates/js/chart-js/src/charts/Chart.Bar.js b/system/templates/js/chart-js/src/charts/Chart.Bar.js deleted file mode 100644 index e1ad7962..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.Bar.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - Chart.Bar = function(context, config) { - config.type = 'bar'; - - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/charts/Chart.Bubble.js b/system/templates/js/chart-js/src/charts/Chart.Bubble.js deleted file mode 100644 index 2de4a104..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.Bubble.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - Chart.Bubble = function(context, config) { - config.type = 'bubble'; - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/charts/Chart.Doughnut.js b/system/templates/js/chart-js/src/charts/Chart.Doughnut.js deleted file mode 100644 index e1e8ce54..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.Doughnut.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - Chart.Doughnut = function(context, config) { - config.type = 'doughnut'; - - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/charts/Chart.Line.js b/system/templates/js/chart-js/src/charts/Chart.Line.js deleted file mode 100644 index e89662ff..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.Line.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - Chart.Line = function(context, config) { - config.type = 'line'; - - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/charts/Chart.PolarArea.js b/system/templates/js/chart-js/src/charts/Chart.PolarArea.js deleted file mode 100644 index e07e4bac..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.PolarArea.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - Chart.PolarArea = function(context, config) { - config.type = 'polarArea'; - - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/charts/Chart.Radar.js b/system/templates/js/chart-js/src/charts/Chart.Radar.js deleted file mode 100644 index d17bd5d8..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.Radar.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - Chart.Radar = function(context, config) { - config.type = 'radar'; - - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/charts/Chart.Scatter.js b/system/templates/js/chart-js/src/charts/Chart.Scatter.js deleted file mode 100644 index 84594f63..00000000 --- a/system/templates/js/chart-js/src/charts/Chart.Scatter.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var defaultConfig = { - hover: { - mode: 'single' - }, - - scales: { - xAxes: [{ - type: 'linear', // scatter should not use a category axis - position: 'bottom', - id: 'x-axis-1' // need an ID so datasets can reference the scale - }], - yAxes: [{ - type: 'linear', - position: 'left', - id: 'y-axis-1' - }] - }, - - tooltips: { - callbacks: { - title: function() { - // Title doesn't make sense for scatter since we format the data as a point - return ''; - }, - label: function(tooltipItem) { - return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')'; - } - } - } - }; - - // Register the default config for this type - Chart.defaults.scatter = defaultConfig; - - // Scatter charts use line controllers - Chart.controllers.scatter = Chart.controllers.line; - - Chart.Scatter = function(context, config) { - config.type = 'scatter'; - return new Chart(context, config); - }; - -}; diff --git a/system/templates/js/chart-js/src/controllers/controller.bar.js b/system/templates/js/chart-js/src/controllers/controller.bar.js deleted file mode 100644 index 1d41386b..00000000 --- a/system/templates/js/chart-js/src/controllers/controller.bar.js +++ /dev/null @@ -1,540 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers; - - Chart.defaults.bar = { - hover: { - mode: 'label' - }, - - scales: { - xAxes: [{ - type: 'category', - - // Specific to Bar Controller - categoryPercentage: 0.8, - barPercentage: 0.9, - - // grid line settings - gridLines: { - offsetGridLines: true - } - }], - yAxes: [{ - type: 'linear' - }] - } - }; - - Chart.controllers.bar = Chart.DatasetController.extend({ - - dataElementType: Chart.elements.Rectangle, - - initialize: function(chart, datasetIndex) { - Chart.DatasetController.prototype.initialize.call(this, chart, datasetIndex); - - var me = this; - var meta = me.getMeta(); - var dataset = me.getDataset(); - - meta.stack = dataset.stack; - // Use this to indicate that this is a bar dataset. - meta.bar = true; - }, - - // Correctly calculate the bar width accounting for stacks and the fact that not all bars are visible - getStackCount: function() { - var me = this; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); - - var stacks = []; - helpers.each(me.chart.data.datasets, function(dataset, datasetIndex) { - var dsMeta = me.chart.getDatasetMeta(datasetIndex); - if (dsMeta.bar && me.chart.isDatasetVisible(datasetIndex) && - (yScale.options.stacked === false || - (yScale.options.stacked === true && stacks.indexOf(dsMeta.stack) === -1) || - (yScale.options.stacked === undefined && (dsMeta.stack === undefined || stacks.indexOf(dsMeta.stack) === -1)))) { - stacks.push(dsMeta.stack); - } - }, me); - - return stacks.length; - }, - - update: function(reset) { - var me = this; - helpers.each(me.getMeta().data, function(rectangle, index) { - me.updateElement(rectangle, index, reset); - }, me); - }, - - updateElement: function(rectangle, index, reset) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var yScale = me.getScaleForId(meta.yAxisID); - var scaleBase = yScale.getBasePixel(); - var rectangleElementOptions = me.chart.options.elements.rectangle; - var custom = rectangle.custom || {}; - var dataset = me.getDataset(); - - rectangle._xScale = xScale; - rectangle._yScale = yScale; - rectangle._datasetIndex = me.index; - rectangle._index = index; - - var ruler = me.getRuler(index); // The index argument for compatible - rectangle._model = { - x: me.calculateBarX(index, me.index, ruler), - y: reset ? scaleBase : me.calculateBarY(index, me.index), - - // Tooltip - label: me.chart.data.labels[index], - datasetLabel: dataset.label, - - // Appearance - horizontal: false, - base: reset ? scaleBase : me.calculateBarBase(me.index, index), - width: me.calculateBarWidth(ruler), - backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor), - borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleElementOptions.borderSkipped, - borderColor: custom.borderColor ? custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor), - borderWidth: custom.borderWidth ? custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth) - }; - - rectangle.pivot(); - }, - - calculateBarBase: function(datasetIndex, index) { - var me = this; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); - var base = yScale.getBaseValue(); - var original = base; - - if ((yScale.options.stacked === true) || - (yScale.options.stacked === undefined && meta.stack !== undefined)) { - var chart = me.chart; - var datasets = chart.data.datasets; - var value = Number(datasets[datasetIndex].data[index]); - - for (var i = 0; i < datasetIndex; i++) { - var currentDs = datasets[i]; - var currentDsMeta = chart.getDatasetMeta(i); - if (currentDsMeta.bar && currentDsMeta.yAxisID === yScale.id && chart.isDatasetVisible(i) && - meta.stack === currentDsMeta.stack) { - var currentVal = Number(currentDs.data[index]); - base += value < 0 ? Math.min(currentVal, original) : Math.max(currentVal, original); - } - } - - return yScale.getPixelForValue(base); - } - - return yScale.getBasePixel(); - }, - - getRuler: function() { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var stackCount = me.getStackCount(); - - var tickWidth = xScale.width / xScale.ticks.length; - var categoryWidth = tickWidth * xScale.options.categoryPercentage; - var categorySpacing = (tickWidth - (tickWidth * xScale.options.categoryPercentage)) / 2; - var fullBarWidth = categoryWidth / stackCount; - - var barWidth = fullBarWidth * xScale.options.barPercentage; - var barSpacing = fullBarWidth - (fullBarWidth * xScale.options.barPercentage); - - return { - stackCount: stackCount, - tickWidth: tickWidth, - categoryWidth: categoryWidth, - categorySpacing: categorySpacing, - fullBarWidth: fullBarWidth, - barWidth: barWidth, - barSpacing: barSpacing - }; - }, - - calculateBarWidth: function(ruler) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - if (xScale.options.barThickness) { - return xScale.options.barThickness; - } - return ruler.barWidth; - }, - - // Get stack index from the given dataset index accounting for stacks and the fact that not all bars are visible - getStackIndex: function(datasetIndex) { - var me = this; - var meta = me.chart.getDatasetMeta(datasetIndex); - var yScale = me.getScaleForId(meta.yAxisID); - var dsMeta, j; - var stacks = [meta.stack]; - - for (j = 0; j < datasetIndex; ++j) { - dsMeta = this.chart.getDatasetMeta(j); - if (dsMeta.bar && this.chart.isDatasetVisible(j) && - (yScale.options.stacked === false || - (yScale.options.stacked === true && stacks.indexOf(dsMeta.stack) === -1) || - (yScale.options.stacked === undefined && (dsMeta.stack === undefined || stacks.indexOf(dsMeta.stack) === -1)))) { - stacks.push(dsMeta.stack); - } - } - - return stacks.length - 1; - }, - - calculateBarX: function(index, datasetIndex, ruler) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var stackIndex = me.getStackIndex(datasetIndex); - var leftTick = xScale.getPixelForValue(null, index, datasetIndex, me.chart.isCombo); - leftTick -= me.chart.isCombo ? (ruler.tickWidth / 2) : 0; - - return leftTick + - (ruler.barWidth / 2) + - ruler.categorySpacing + - (ruler.barWidth * stackIndex) + - (ruler.barSpacing / 2) + - (ruler.barSpacing * stackIndex); - }, - - calculateBarY: function(index, datasetIndex) { - var me = this; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); - var value = Number(me.getDataset().data[index]); - - if (yScale.options.stacked || - (yScale.options.stacked === undefined && meta.stack !== undefined)) { - var base = yScale.getBaseValue(); - var sumPos = base, - sumNeg = base; - - for (var i = 0; i < datasetIndex; i++) { - var ds = me.chart.data.datasets[i]; - var dsMeta = me.chart.getDatasetMeta(i); - if (dsMeta.bar && dsMeta.yAxisID === yScale.id && me.chart.isDatasetVisible(i) && - meta.stack === dsMeta.stack) { - var stackedVal = Number(ds.data[index]); - if (stackedVal < 0) { - sumNeg += stackedVal || 0; - } else { - sumPos += stackedVal || 0; - } - } - } - - if (value < 0) { - return yScale.getPixelForValue(sumNeg + value); - } - return yScale.getPixelForValue(sumPos + value); - } - - return yScale.getPixelForValue(value); - }, - - draw: function(ease) { - var me = this; - var easingDecimal = ease || 1; - var metaData = me.getMeta().data; - var dataset = me.getDataset(); - var i, len; - - Chart.canvasHelpers.clipArea(me.chart.chart.ctx, me.chart.chartArea); - for (i = 0, len = metaData.length; i < len; ++i) { - var d = dataset.data[i]; - if (d !== null && d !== undefined && !isNaN(d)) { - metaData[i].transition(easingDecimal).draw(); - } - } - Chart.canvasHelpers.unclipArea(me.chart.chart.ctx); - }, - - setHoverStyle: function(rectangle) { - var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - var index = rectangle._index; - - var custom = rectangle.custom || {}; - var model = rectangle._model; - model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor)); - model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.getHoverColor(model.borderColor)); - model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.hoverBorderWidth, index, model.borderWidth); - }, - - removeHoverStyle: function(rectangle) { - var dataset = this.chart.data.datasets[rectangle._datasetIndex]; - var index = rectangle._index; - var custom = rectangle.custom || {}; - var model = rectangle._model; - var rectangleElementOptions = this.chart.options.elements.rectangle; - - model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor); - model.borderColor = custom.borderColor ? custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor); - model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth); - } - - }); - - - // including horizontalBar in the bar file, instead of a file of its own - // it extends bar (like pie extends doughnut) - Chart.defaults.horizontalBar = { - hover: { - mode: 'label' - }, - - scales: { - xAxes: [{ - type: 'linear', - position: 'bottom' - }], - yAxes: [{ - position: 'left', - type: 'category', - - // Specific to Horizontal Bar Controller - categoryPercentage: 0.8, - barPercentage: 0.9, - - // grid line settings - gridLines: { - offsetGridLines: true - } - }] - }, - elements: { - rectangle: { - borderSkipped: 'left' - } - }, - tooltips: { - callbacks: { - title: function(tooltipItems, data) { - // Pick first xLabel for now - var title = ''; - - if (tooltipItems.length > 0) { - if (tooltipItems[0].yLabel) { - title = tooltipItems[0].yLabel; - } else if (data.labels.length > 0 && tooltipItems[0].index < data.labels.length) { - title = data.labels[tooltipItems[0].index]; - } - } - - return title; - }, - label: function(tooltipItem, data) { - var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || ''; - return datasetLabel + ': ' + tooltipItem.xLabel; - } - } - } - }; - - Chart.controllers.horizontalBar = Chart.controllers.bar.extend({ - - // Correctly calculate the bar width accounting for stacks and the fact that not all bars are visible - getStackCount: function() { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - - var stacks = []; - helpers.each(me.chart.data.datasets, function(dataset, datasetIndex) { - var dsMeta = me.chart.getDatasetMeta(datasetIndex); - if (dsMeta.bar && me.chart.isDatasetVisible(datasetIndex) && - (xScale.options.stacked === false || - (xScale.options.stacked === true && stacks.indexOf(dsMeta.stack) === -1) || - (xScale.options.stacked === undefined && (dsMeta.stack === undefined || stacks.indexOf(dsMeta.stack) === -1)))) { - stacks.push(dsMeta.stack); - } - }, me); - - return stacks.length; - }, - - updateElement: function(rectangle, index, reset) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var yScale = me.getScaleForId(meta.yAxisID); - var scaleBase = xScale.getBasePixel(); - var custom = rectangle.custom || {}; - var dataset = me.getDataset(); - var rectangleElementOptions = me.chart.options.elements.rectangle; - - rectangle._xScale = xScale; - rectangle._yScale = yScale; - rectangle._datasetIndex = me.index; - rectangle._index = index; - - var ruler = me.getRuler(index); // The index argument for compatible - rectangle._model = { - x: reset ? scaleBase : me.calculateBarX(index, me.index), - y: me.calculateBarY(index, me.index, ruler), - - // Tooltip - label: me.chart.data.labels[index], - datasetLabel: dataset.label, - - // Appearance - horizontal: true, - base: reset ? scaleBase : me.calculateBarBase(me.index, index), - height: me.calculateBarHeight(ruler), - backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor), - borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleElementOptions.borderSkipped, - borderColor: custom.borderColor ? custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor), - borderWidth: custom.borderWidth ? custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth) - }; - - rectangle.pivot(); - }, - - calculateBarBase: function(datasetIndex, index) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var base = xScale.getBaseValue(); - var originalBase = base; - - if (xScale.options.stacked || - (xScale.options.stacked === undefined && meta.stack !== undefined)) { - var chart = me.chart; - var datasets = chart.data.datasets; - var value = Number(datasets[datasetIndex].data[index]); - - for (var i = 0; i < datasetIndex; i++) { - var currentDs = datasets[i]; - var currentDsMeta = chart.getDatasetMeta(i); - if (currentDsMeta.bar && currentDsMeta.xAxisID === xScale.id && chart.isDatasetVisible(i) && - meta.stack === currentDsMeta.stack) { - var currentVal = Number(currentDs.data[index]); - base += value < 0 ? Math.min(currentVal, originalBase) : Math.max(currentVal, originalBase); - } - } - - return xScale.getPixelForValue(base); - } - - return xScale.getBasePixel(); - }, - - getRuler: function() { - var me = this; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); - var stackCount = me.getStackCount(); - - var tickHeight = yScale.height / yScale.ticks.length; - var categoryHeight = tickHeight * yScale.options.categoryPercentage; - var categorySpacing = (tickHeight - (tickHeight * yScale.options.categoryPercentage)) / 2; - var fullBarHeight = categoryHeight / stackCount; - - var barHeight = fullBarHeight * yScale.options.barPercentage; - var barSpacing = fullBarHeight - (fullBarHeight * yScale.options.barPercentage); - - return { - stackCount: stackCount, - tickHeight: tickHeight, - categoryHeight: categoryHeight, - categorySpacing: categorySpacing, - fullBarHeight: fullBarHeight, - barHeight: barHeight, - barSpacing: barSpacing - }; - }, - - calculateBarHeight: function(ruler) { - var me = this; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); - if (yScale.options.barThickness) { - return yScale.options.barThickness; - } - return ruler.barHeight; - }, - - // Get stack index from the given dataset index accounting for stacks and the fact that not all bars are visible - getStackIndex: function(datasetIndex) { - var me = this; - var meta = me.chart.getDatasetMeta(datasetIndex); - var xScale = me.getScaleForId(meta.xAxisID); - var dsMeta, j; - var stacks = [meta.stack]; - - for (j = 0; j < datasetIndex; ++j) { - dsMeta = this.chart.getDatasetMeta(j); - if (dsMeta.bar && this.chart.isDatasetVisible(j) && - (xScale.options.stacked === false || - (xScale.options.stacked === true && stacks.indexOf(dsMeta.stack) === -1) || - (xScale.options.stacked === undefined && (dsMeta.stack === undefined || stacks.indexOf(dsMeta.stack) === -1)))) { - stacks.push(dsMeta.stack); - } - } - - return stacks.length - 1; - }, - - calculateBarX: function(index, datasetIndex) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var value = Number(me.getDataset().data[index]); - - if (xScale.options.stacked || - (xScale.options.stacked === undefined && meta.stack !== undefined)) { - var base = xScale.getBaseValue(); - var sumPos = base, - sumNeg = base; - - for (var i = 0; i < datasetIndex; i++) { - var ds = me.chart.data.datasets[i]; - var dsMeta = me.chart.getDatasetMeta(i); - if (dsMeta.bar && dsMeta.xAxisID === xScale.id && me.chart.isDatasetVisible(i) && - meta.stack === dsMeta.stack) { - var stackedVal = Number(ds.data[index]); - if (stackedVal < 0) { - sumNeg += stackedVal || 0; - } else { - sumPos += stackedVal || 0; - } - } - } - - if (value < 0) { - return xScale.getPixelForValue(sumNeg + value); - } - return xScale.getPixelForValue(sumPos + value); - } - - return xScale.getPixelForValue(value); - }, - - calculateBarY: function(index, datasetIndex, ruler) { - var me = this; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); - var stackIndex = me.getStackIndex(datasetIndex); - var topTick = yScale.getPixelForValue(null, index, datasetIndex, me.chart.isCombo); - topTick -= me.chart.isCombo ? (ruler.tickHeight / 2) : 0; - - return topTick + - (ruler.barHeight / 2) + - ruler.categorySpacing + - (ruler.barHeight * stackIndex) + - (ruler.barSpacing / 2) + - (ruler.barSpacing * stackIndex); - } - }); -}; diff --git a/system/templates/js/chart-js/src/controllers/controller.bubble.js b/system/templates/js/chart-js/src/controllers/controller.bubble.js deleted file mode 100644 index abe807b3..00000000 --- a/system/templates/js/chart-js/src/controllers/controller.bubble.js +++ /dev/null @@ -1,122 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers; - - Chart.defaults.bubble = { - hover: { - mode: 'single' - }, - - scales: { - xAxes: [{ - type: 'linear', // bubble should probably use a linear scale by default - position: 'bottom', - id: 'x-axis-0' // need an ID so datasets can reference the scale - }], - yAxes: [{ - type: 'linear', - position: 'left', - id: 'y-axis-0' - }] - }, - - tooltips: { - callbacks: { - title: function() { - // Title doesn't make sense for scatter since we format the data as a point - return ''; - }, - label: function(tooltipItem, data) { - var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || ''; - var dataPoint = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; - return datasetLabel + ': (' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ', ' + dataPoint.r + ')'; - } - } - } - }; - - Chart.controllers.bubble = Chart.DatasetController.extend({ - - dataElementType: Chart.elements.Point, - - update: function(reset) { - var me = this; - var meta = me.getMeta(); - var points = meta.data; - - // Update Points - helpers.each(points, function(point, index) { - me.updateElement(point, index, reset); - }); - }, - - updateElement: function(point, index, reset) { - var me = this; - var meta = me.getMeta(); - var xScale = me.getScaleForId(meta.xAxisID); - var yScale = me.getScaleForId(meta.yAxisID); - - var custom = point.custom || {}; - var dataset = me.getDataset(); - var data = dataset.data[index]; - var pointElementOptions = me.chart.options.elements.point; - var dsIndex = me.index; - - helpers.extend(point, { - // Utility - _xScale: xScale, - _yScale: yScale, - _datasetIndex: dsIndex, - _index: index, - - // Desired view properties - _model: { - x: reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex, me.chart.isCombo), - y: reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex), - // Appearance - radius: reset ? 0 : custom.radius ? custom.radius : me.getRadius(data), - - // Tooltip - hitRadius: custom.hitRadius ? custom.hitRadius : helpers.getValueAtIndexOrDefault(dataset.hitRadius, index, pointElementOptions.hitRadius) - } - }); - - // Trick to reset the styles of the point - Chart.DatasetController.prototype.removeHoverStyle.call(me, point, pointElementOptions); - - var model = point._model; - model.skip = custom.skip ? custom.skip : (isNaN(model.x) || isNaN(model.y)); - - point.pivot(); - }, - - getRadius: function(value) { - return value.r || this.chart.options.elements.point.radius; - }, - - setHoverStyle: function(point) { - var me = this; - Chart.DatasetController.prototype.setHoverStyle.call(me, point); - - // Radius - var dataset = me.chart.data.datasets[point._datasetIndex]; - var index = point._index; - var custom = point.custom || {}; - var model = point._model; - model.radius = custom.hoverRadius ? custom.hoverRadius : (helpers.getValueAtIndexOrDefault(dataset.hoverRadius, index, me.chart.options.elements.point.hoverRadius)) + me.getRadius(dataset.data[index]); - }, - - removeHoverStyle: function(point) { - var me = this; - Chart.DatasetController.prototype.removeHoverStyle.call(me, point, me.chart.options.elements.point); - - var dataVal = me.chart.data.datasets[point._datasetIndex].data[point._index]; - var custom = point.custom || {}; - var model = point._model; - - model.radius = custom.radius ? custom.radius : me.getRadius(dataVal); - } - }); -}; diff --git a/system/templates/js/chart-js/src/controllers/controller.doughnut.js b/system/templates/js/chart-js/src/controllers/controller.doughnut.js deleted file mode 100644 index 3d478058..00000000 --- a/system/templates/js/chart-js/src/controllers/controller.doughnut.js +++ /dev/null @@ -1,303 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers, - defaults = Chart.defaults; - - defaults.doughnut = { - animation: { - // Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, - // Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false - }, - aspectRatio: 1, - hover: { - mode: 'single' - }, - legendCallback: function(chart) { - var text = []; - text.push('
    '); - - var data = chart.data; - var datasets = data.datasets; - var labels = data.labels; - - if (datasets.length) { - for (var i = 0; i < datasets[0].data.length; ++i) { - text.push('
  • '); - if (labels[i]) { - text.push(labels[i]); - } - text.push('
  • '); - } - } - - text.push('
'); - return text.join(''); - }, - legend: { - labels: { - generateLabels: function(chart) { - var data = chart.data; - if (data.labels.length && data.datasets.length) { - return data.labels.map(function(label, i) { - var meta = chart.getDatasetMeta(0); - var ds = data.datasets[0]; - var arc = meta.data[i]; - var custom = arc && arc.custom || {}; - var getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault; - var arcOpts = chart.options.elements.arc; - var fill = custom.backgroundColor ? custom.backgroundColor : getValueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor); - var stroke = custom.borderColor ? custom.borderColor : getValueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor); - var bw = custom.borderWidth ? custom.borderWidth : getValueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth); - - return { - text: label, - fillStyle: fill, - strokeStyle: stroke, - lineWidth: bw, - hidden: isNaN(ds.data[i]) || meta.data[i].hidden, - - // Extra data used for toggling the correct item - index: i - }; - }); - } - return []; - } - }, - - onClick: function(e, legendItem) { - var index = legendItem.index; - var chart = this.chart; - var i, ilen, meta; - - for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) { - meta = chart.getDatasetMeta(i); - // toggle visibility of index if exists - if (meta.data[index]) { - meta.data[index].hidden = !meta.data[index].hidden; - } - } - - chart.update(); - } - }, - - // The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, - - // The rotation of the chart, where the first data arc begins. - rotation: Math.PI * -0.5, - - // The total circumference of the chart. - circumference: Math.PI * 2.0, - - // Need to override these to give a nice default - tooltips: { - callbacks: { - title: function() { - return ''; - }, - label: function(tooltipItem, data) { - var dataLabel = data.labels[tooltipItem.index]; - var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; - - if (helpers.isArray(dataLabel)) { - // show value on first line of multiline label - // need to clone because we are changing the value - dataLabel = dataLabel.slice(); - dataLabel[0] += value; - } else { - dataLabel += value; - } - - return dataLabel; - } - } - } - }; - - defaults.pie = helpers.clone(defaults.doughnut); - helpers.extend(defaults.pie, { - cutoutPercentage: 0 - }); - - - Chart.controllers.doughnut = Chart.controllers.pie = Chart.DatasetController.extend({ - - dataElementType: Chart.elements.Arc, - - linkScales: helpers.noop, - - // Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly - getRingIndex: function(datasetIndex) { - var ringIndex = 0; - - for (var j = 0; j < datasetIndex; ++j) { - if (this.chart.isDatasetVisible(j)) { - ++ringIndex; - } - } - - return ringIndex; - }, - - update: function(reset) { - var me = this; - var chart = me.chart, - chartArea = chart.chartArea, - opts = chart.options, - arcOpts = opts.elements.arc, - availableWidth = chartArea.right - chartArea.left - arcOpts.borderWidth, - availableHeight = chartArea.bottom - chartArea.top - arcOpts.borderWidth, - minSize = Math.min(availableWidth, availableHeight), - offset = { - x: 0, - y: 0 - }, - meta = me.getMeta(), - cutoutPercentage = opts.cutoutPercentage, - circumference = opts.circumference; - - // If the chart's circumference isn't a full circle, calculate minSize as a ratio of the width/height of the arc - if (circumference < Math.PI * 2.0) { - var startAngle = opts.rotation % (Math.PI * 2.0); - startAngle += Math.PI * 2.0 * (startAngle >= Math.PI ? -1 : startAngle < -Math.PI ? 1 : 0); - var endAngle = startAngle + circumference; - var start = {x: Math.cos(startAngle), y: Math.sin(startAngle)}; - var end = {x: Math.cos(endAngle), y: Math.sin(endAngle)}; - var contains0 = (startAngle <= 0 && 0 <= endAngle) || (startAngle <= Math.PI * 2.0 && Math.PI * 2.0 <= endAngle); - var contains90 = (startAngle <= Math.PI * 0.5 && Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 2.5 && Math.PI * 2.5 <= endAngle); - var contains180 = (startAngle <= -Math.PI && -Math.PI <= endAngle) || (startAngle <= Math.PI && Math.PI <= endAngle); - var contains270 = (startAngle <= -Math.PI * 0.5 && -Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 1.5 && Math.PI * 1.5 <= endAngle); - var cutout = cutoutPercentage / 100.0; - var min = {x: contains180 ? -1 : Math.min(start.x * (start.x < 0 ? 1 : cutout), end.x * (end.x < 0 ? 1 : cutout)), y: contains270 ? -1 : Math.min(start.y * (start.y < 0 ? 1 : cutout), end.y * (end.y < 0 ? 1 : cutout))}; - var max = {x: contains0 ? 1 : Math.max(start.x * (start.x > 0 ? 1 : cutout), end.x * (end.x > 0 ? 1 : cutout)), y: contains90 ? 1 : Math.max(start.y * (start.y > 0 ? 1 : cutout), end.y * (end.y > 0 ? 1 : cutout))}; - var size = {width: (max.x - min.x) * 0.5, height: (max.y - min.y) * 0.5}; - minSize = Math.min(availableWidth / size.width, availableHeight / size.height); - offset = {x: (max.x + min.x) * -0.5, y: (max.y + min.y) * -0.5}; - } - - chart.borderWidth = me.getMaxBorderWidth(meta.data); - chart.outerRadius = Math.max((minSize - chart.borderWidth) / 2, 0); - chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 0, 0); - chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount(); - chart.offsetX = offset.x * chart.outerRadius; - chart.offsetY = offset.y * chart.outerRadius; - - meta.total = me.calculateTotal(); - - me.outerRadius = chart.outerRadius - (chart.radiusLength * me.getRingIndex(me.index)); - me.innerRadius = Math.max(me.outerRadius - chart.radiusLength, 0); - - helpers.each(meta.data, function(arc, index) { - me.updateElement(arc, index, reset); - }); - }, - - updateElement: function(arc, index, reset) { - var me = this; - var chart = me.chart, - chartArea = chart.chartArea, - opts = chart.options, - animationOpts = opts.animation, - centerX = (chartArea.left + chartArea.right) / 2, - centerY = (chartArea.top + chartArea.bottom) / 2, - startAngle = opts.rotation, // non reset case handled later - endAngle = opts.rotation, // non reset case handled later - dataset = me.getDataset(), - circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumference / (2.0 * Math.PI)), - innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius, - outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius, - valueAtIndexOrDefault = helpers.getValueAtIndexOrDefault; - - helpers.extend(arc, { - // Utility - _datasetIndex: me.index, - _index: index, - - // Desired view properties - _model: { - x: centerX + chart.offsetX, - y: centerY + chart.offsetY, - startAngle: startAngle, - endAngle: endAngle, - circumference: circumference, - outerRadius: outerRadius, - innerRadius: innerRadius, - label: valueAtIndexOrDefault(dataset.label, index, chart.data.labels[index]) - } - }); - - var model = arc._model; - // Resets the visual styles - this.removeHoverStyle(arc); - - // Set correct angles if not resetting - if (!reset || !animationOpts.animateRotate) { - if (index === 0) { - model.startAngle = opts.rotation; - } else { - model.startAngle = me.getMeta().data[index - 1]._model.endAngle; - } - - model.endAngle = model.startAngle + model.circumference; - } - - arc.pivot(); - }, - - removeHoverStyle: function(arc) { - Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc); - }, - - calculateTotal: function() { - var dataset = this.getDataset(); - var meta = this.getMeta(); - var total = 0; - var value; - - helpers.each(meta.data, function(element, index) { - value = dataset.data[index]; - if (!isNaN(value) && !element.hidden) { - total += Math.abs(value); - } - }); - - /* if (total === 0) { - total = NaN; - }*/ - - return total; - }, - - calculateCircumference: function(value) { - var total = this.getMeta().total; - if (total > 0 && !isNaN(value)) { - return (Math.PI * 2.0) * (value / total); - } - return 0; - }, - - // gets the max border or hover width to properly scale pie charts - getMaxBorderWidth: function(elements) { - var max = 0, - index = this.index, - length = elements.length, - borderWidth, - hoverWidth; - - for (var i = 0; i < length; i++) { - borderWidth = elements[i]._model ? elements[i]._model.borderWidth : 0; - hoverWidth = elements[i]._chart ? elements[i]._chart.config.data.datasets[index].hoverBorderWidth : 0; - - max = borderWidth > max ? borderWidth : max; - max = hoverWidth > max ? hoverWidth : max; - } - return max; - } - }); -}; diff --git a/system/templates/js/chart-js/src/controllers/controller.line.js b/system/templates/js/chart-js/src/controllers/controller.line.js deleted file mode 100644 index 806ab4f3..00000000 --- a/system/templates/js/chart-js/src/controllers/controller.line.js +++ /dev/null @@ -1,339 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers; - - Chart.defaults.line = { - showLines: true, - spanGaps: false, - - hover: { - mode: 'label' - }, - - scales: { - xAxes: [{ - type: 'category', - id: 'x-axis-0' - }], - yAxes: [{ - type: 'linear', - id: 'y-axis-0' - }] - } - }; - - function lineEnabled(dataset, options) { - return helpers.getValueOrDefault(dataset.showLine, options.showLines); - } - - Chart.controllers.line = Chart.DatasetController.extend({ - - datasetElementType: Chart.elements.Line, - - dataElementType: Chart.elements.Point, - - update: function(reset) { - var me = this; - var meta = me.getMeta(); - var line = meta.dataset; - var points = meta.data || []; - var options = me.chart.options; - var lineElementOptions = options.elements.line; - var scale = me.getScaleForId(meta.yAxisID); - var i, ilen, custom; - var dataset = me.getDataset(); - var showLine = lineEnabled(dataset, options); - - // Update Line - if (showLine) { - custom = line.custom || {}; - - // Compatibility: If the properties are defined with only the old name, use those values - if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) { - dataset.lineTension = dataset.tension; - } - - // Utility - line._scale = scale; - line._datasetIndex = me.index; - // Data - line._children = points; - // Model - line._model = { - // Appearance - // The default behavior of lines is to break at null values, according - // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158 - // This option gives lines the ability to span gaps - spanGaps: dataset.spanGaps ? dataset.spanGaps : options.spanGaps, - tension: custom.tension ? custom.tension : helpers.getValueOrDefault(dataset.lineTension, lineElementOptions.tension), - backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor), - borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth), - borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor), - borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle), - borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash), - borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset), - borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle), - fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill), - steppedLine: custom.steppedLine ? custom.steppedLine : helpers.getValueOrDefault(dataset.steppedLine, lineElementOptions.stepped), - cubicInterpolationMode: custom.cubicInterpolationMode ? custom.cubicInterpolationMode : helpers.getValueOrDefault(dataset.cubicInterpolationMode, lineElementOptions.cubicInterpolationMode), - // Scale - scaleTop: scale.top, - scaleBottom: scale.bottom, - scaleZero: scale.getBasePixel() - }; - - line.pivot(); - } - - // Update Points - for (i=0, ilen=points.length; i'); - - var data = chart.data; - var datasets = data.datasets; - var labels = data.labels; - - if (datasets.length) { - for (var i = 0; i < datasets[0].data.length; ++i) { - text.push('
  • '); - if (labels[i]) { - text.push(labels[i]); - } - text.push('
  • '); - } - } - - text.push(''); - return text.join(''); - }, - legend: { - labels: { - generateLabels: function(chart) { - var data = chart.data; - if (data.labels.length && data.datasets.length) { - return data.labels.map(function(label, i) { - var meta = chart.getDatasetMeta(0); - var ds = data.datasets[0]; - var arc = meta.data[i]; - var custom = arc.custom || {}; - var getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault; - var arcOpts = chart.options.elements.arc; - var fill = custom.backgroundColor ? custom.backgroundColor : getValueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor); - var stroke = custom.borderColor ? custom.borderColor : getValueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor); - var bw = custom.borderWidth ? custom.borderWidth : getValueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth); - - return { - text: label, - fillStyle: fill, - strokeStyle: stroke, - lineWidth: bw, - hidden: isNaN(ds.data[i]) || meta.data[i].hidden, - - // Extra data used for toggling the correct item - index: i - }; - }); - } - return []; - } - }, - - onClick: function(e, legendItem) { - var index = legendItem.index; - var chart = this.chart; - var i, ilen, meta; - - for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) { - meta = chart.getDatasetMeta(i); - meta.data[index].hidden = !meta.data[index].hidden; - } - - chart.update(); - } - }, - - // Need to override these to give a nice default - tooltips: { - callbacks: { - title: function() { - return ''; - }, - label: function(tooltipItem, data) { - return data.labels[tooltipItem.index] + ': ' + tooltipItem.yLabel; - } - } - } - }; - - Chart.controllers.polarArea = Chart.DatasetController.extend({ - - dataElementType: Chart.elements.Arc, - - linkScales: helpers.noop, - - update: function(reset) { - var me = this; - var chart = me.chart; - var chartArea = chart.chartArea; - var meta = me.getMeta(); - var opts = chart.options; - var arcOpts = opts.elements.arc; - var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top); - chart.outerRadius = Math.max((minSize - arcOpts.borderWidth / 2) / 2, 0); - chart.innerRadius = Math.max(opts.cutoutPercentage ? (chart.outerRadius / 100) * (opts.cutoutPercentage) : 1, 0); - chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount(); - - me.outerRadius = chart.outerRadius - (chart.radiusLength * me.index); - me.innerRadius = me.outerRadius - chart.radiusLength; - - meta.count = me.countVisibleElements(); - - helpers.each(meta.data, function(arc, index) { - me.updateElement(arc, index, reset); - }); - }, - - updateElement: function(arc, index, reset) { - var me = this; - var chart = me.chart; - var dataset = me.getDataset(); - var opts = chart.options; - var animationOpts = opts.animation; - var scale = chart.scale; - var getValueAtIndexOrDefault = helpers.getValueAtIndexOrDefault; - var labels = chart.data.labels; - - var circumference = me.calculateCircumference(dataset.data[index]); - var centerX = scale.xCenter; - var centerY = scale.yCenter; - - // If there is NaN data before us, we need to calculate the starting angle correctly. - // We could be way more efficient here, but its unlikely that the polar area chart will have a lot of data - var visibleCount = 0; - var meta = me.getMeta(); - for (var i = 0; i < index; ++i) { - if (!isNaN(dataset.data[i]) && !meta.data[i].hidden) { - ++visibleCount; - } - } - - // var negHalfPI = -0.5 * Math.PI; - var datasetStartAngle = opts.startAngle; - var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]); - var startAngle = datasetStartAngle + (circumference * visibleCount); - var endAngle = startAngle + (arc.hidden ? 0 : circumference); - - var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]); - - helpers.extend(arc, { - // Utility - _datasetIndex: me.index, - _index: index, - _scale: scale, - - // Desired view properties - _model: { - x: centerX, - y: centerY, - innerRadius: 0, - outerRadius: reset ? resetRadius : distance, - startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle, - endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle, - label: getValueAtIndexOrDefault(labels, index, labels[index]) - } - }); - - // Apply border and fill style - me.removeHoverStyle(arc); - - arc.pivot(); - }, - - removeHoverStyle: function(arc) { - Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc); - }, - - countVisibleElements: function() { - var dataset = this.getDataset(); - var meta = this.getMeta(); - var count = 0; - - helpers.each(meta.data, function(element, index) { - if (!isNaN(dataset.data[index]) && !element.hidden) { - count++; - } - }); - - return count; - }, - - calculateCircumference: function(value) { - var count = this.getMeta().count; - if (count > 0 && !isNaN(value)) { - return (2 * Math.PI) / count; - } - return 0; - } - }); -}; diff --git a/system/templates/js/chart-js/src/controllers/controller.radar.js b/system/templates/js/chart-js/src/controllers/controller.radar.js deleted file mode 100644 index fc0c4a28..00000000 --- a/system/templates/js/chart-js/src/controllers/controller.radar.js +++ /dev/null @@ -1,181 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers; - - Chart.defaults.radar = { - aspectRatio: 1, - scale: { - type: 'radialLinear' - }, - elements: { - line: { - tension: 0 // no bezier in radar - } - } - }; - - Chart.controllers.radar = Chart.DatasetController.extend({ - - datasetElementType: Chart.elements.Line, - - dataElementType: Chart.elements.Point, - - linkScales: helpers.noop, - - update: function(reset) { - var me = this; - var meta = me.getMeta(); - var line = meta.dataset; - var points = meta.data; - var custom = line.custom || {}; - var dataset = me.getDataset(); - var lineElementOptions = me.chart.options.elements.line; - var scale = me.chart.scale; - - // Compatibility: If the properties are defined with only the old name, use those values - if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) { - dataset.lineTension = dataset.tension; - } - - helpers.extend(meta.dataset, { - // Utility - _datasetIndex: me.index, - // Data - _children: points, - _loop: true, - // Model - _model: { - // Appearance - tension: custom.tension ? custom.tension : helpers.getValueOrDefault(dataset.lineTension, lineElementOptions.tension), - backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor), - borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth), - borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor), - fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill), - borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle), - borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash), - borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset), - borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle), - - // Scale - scaleTop: scale.top, - scaleBottom: scale.bottom, - scaleZero: scale.getBasePosition() - } - }); - - meta.dataset.pivot(); - - // Update Points - helpers.each(points, function(point, index) { - me.updateElement(point, index, reset); - }, me); - - // Update bezier control points - me.updateBezierControlPoints(); - }, - updateElement: function(point, index, reset) { - var me = this; - var custom = point.custom || {}; - var dataset = me.getDataset(); - var scale = me.chart.scale; - var pointElementOptions = me.chart.options.elements.point; - var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]); - - helpers.extend(point, { - // Utility - _datasetIndex: me.index, - _index: index, - _scale: scale, - - // Desired view properties - _model: { - x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales - y: reset ? scale.yCenter : pointPosition.y, - - // Appearance - tension: custom.tension ? custom.tension : helpers.getValueOrDefault(dataset.lineTension, me.chart.options.elements.line.tension), - radius: custom.radius ? custom.radius : helpers.getValueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius), - backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, pointElementOptions.backgroundColor), - borderColor: custom.borderColor ? custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor), - borderWidth: custom.borderWidth ? custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth), - pointStyle: custom.pointStyle ? custom.pointStyle : helpers.getValueAtIndexOrDefault(dataset.pointStyle, index, pointElementOptions.pointStyle), - - // Tooltip - hitRadius: custom.hitRadius ? custom.hitRadius : helpers.getValueAtIndexOrDefault(dataset.hitRadius, index, pointElementOptions.hitRadius) - } - }); - - point._model.skip = custom.skip ? custom.skip : (isNaN(point._model.x) || isNaN(point._model.y)); - }, - updateBezierControlPoints: function() { - var chartArea = this.chart.chartArea; - var meta = this.getMeta(); - - helpers.each(meta.data, function(point, index) { - var model = point._model; - var controlPoints = helpers.splineCurve( - helpers.previousItem(meta.data, index, true)._model, - model, - helpers.nextItem(meta.data, index, true)._model, - model.tension - ); - - // Prevent the bezier going outside of the bounds of the graph - model.controlPointPreviousX = Math.max(Math.min(controlPoints.previous.x, chartArea.right), chartArea.left); - model.controlPointPreviousY = Math.max(Math.min(controlPoints.previous.y, chartArea.bottom), chartArea.top); - - model.controlPointNextX = Math.max(Math.min(controlPoints.next.x, chartArea.right), chartArea.left); - model.controlPointNextY = Math.max(Math.min(controlPoints.next.y, chartArea.bottom), chartArea.top); - - // Now pivot the point for animation - point.pivot(); - }); - }, - - draw: function(ease) { - var meta = this.getMeta(); - var easingDecimal = ease || 1; - - // Transition Point Locations - helpers.each(meta.data, function(point) { - point.transition(easingDecimal); - }); - - // Transition and Draw the line - meta.dataset.transition(easingDecimal).draw(); - - // Draw the points - helpers.each(meta.data, function(point) { - point.draw(); - }); - }, - - setHoverStyle: function(point) { - // Point - var dataset = this.chart.data.datasets[point._datasetIndex]; - var custom = point.custom || {}; - var index = point._index; - var model = point._model; - - model.radius = custom.hoverRadius ? custom.hoverRadius : helpers.getValueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius); - model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor)); - model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor)); - model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth); - }, - - removeHoverStyle: function(point) { - var dataset = this.chart.data.datasets[point._datasetIndex]; - var custom = point.custom || {}; - var index = point._index; - var model = point._model; - var pointElementOptions = this.chart.options.elements.point; - - model.radius = custom.radius ? custom.radius : helpers.getValueAtIndexOrDefault(dataset.radius, index, pointElementOptions.radius); - model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.pointBackgroundColor, index, pointElementOptions.backgroundColor); - model.borderColor = custom.borderColor ? custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor); - model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth); - } - }); -}; diff --git a/system/templates/js/chart-js/src/core/core.animation.js b/system/templates/js/chart-js/src/core/core.animation.js deleted file mode 100644 index dcb9c2ee..00000000 --- a/system/templates/js/chart-js/src/core/core.animation.js +++ /dev/null @@ -1,139 +0,0 @@ -/* global window: false */ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers; - - Chart.defaults.global.animation = { - duration: 1000, - easing: 'easeOutQuart', - onProgress: helpers.noop, - onComplete: helpers.noop - }; - - Chart.Animation = Chart.Element.extend({ - currentStep: null, // the current animation step - numSteps: 60, // default number of steps - easing: '', // the easing to use for this animation - render: null, // render function used by the animation service - - onAnimationProgress: null, // user specified callback to fire on each step of the animation - onAnimationComplete: null // user specified callback to fire when the animation finishes - }); - - Chart.animationService = { - frameDuration: 17, - animations: [], - dropFrames: 0, - request: null, - - /** - * @function Chart.animationService.addAnimation - * @param chartInstance {ChartController} the chart to animate - * @param animationObject {IAnimation} the animation that we will animate - * @param duration {Number} length of animation in ms - * @param lazy {Boolean} if true, the chart is not marked as animating to enable more responsive interactions - */ - addAnimation: function(chartInstance, animationObject, duration, lazy) { - var me = this; - - if (!lazy) { - chartInstance.animating = true; - } - - for (var index = 0; index < me.animations.length; ++index) { - if (me.animations[index].chartInstance === chartInstance) { - // replacing an in progress animation - me.animations[index].animationObject = animationObject; - return; - } - } - - me.animations.push({ - chartInstance: chartInstance, - animationObject: animationObject - }); - - // If there are no animations queued, manually kickstart a digest, for lack of a better word - if (me.animations.length === 1) { - me.requestAnimationFrame(); - } - }, - // Cancel the animation for a given chart instance - cancelAnimation: function(chartInstance) { - var index = helpers.findIndex(this.animations, function(animationWrapper) { - return animationWrapper.chartInstance === chartInstance; - }); - - if (index !== -1) { - this.animations.splice(index, 1); - chartInstance.animating = false; - } - }, - requestAnimationFrame: function() { - var me = this; - if (me.request === null) { - // Skip animation frame requests until the active one is executed. - // This can happen when processing mouse events, e.g. 'mousemove' - // and 'mouseout' events will trigger multiple renders. - me.request = helpers.requestAnimFrame.call(window, function() { - me.request = null; - me.startDigest(); - }); - } - }, - startDigest: function() { - var me = this; - - var startTime = Date.now(); - var framesToDrop = 0; - - if (me.dropFrames > 1) { - framesToDrop = Math.floor(me.dropFrames); - me.dropFrames = me.dropFrames % 1; - } - - var i = 0; - while (i < me.animations.length) { - if (me.animations[i].animationObject.currentStep === null) { - me.animations[i].animationObject.currentStep = 0; - } - - me.animations[i].animationObject.currentStep += 1 + framesToDrop; - - if (me.animations[i].animationObject.currentStep > me.animations[i].animationObject.numSteps) { - me.animations[i].animationObject.currentStep = me.animations[i].animationObject.numSteps; - } - - me.animations[i].animationObject.render(me.animations[i].chartInstance, me.animations[i].animationObject); - if (me.animations[i].animationObject.onAnimationProgress && me.animations[i].animationObject.onAnimationProgress.call) { - me.animations[i].animationObject.onAnimationProgress.call(me.animations[i].chartInstance, me.animations[i]); - } - - if (me.animations[i].animationObject.currentStep === me.animations[i].animationObject.numSteps) { - if (me.animations[i].animationObject.onAnimationComplete && me.animations[i].animationObject.onAnimationComplete.call) { - me.animations[i].animationObject.onAnimationComplete.call(me.animations[i].chartInstance, me.animations[i]); - } - - // executed the last frame. Remove the animation. - me.animations[i].chartInstance.animating = false; - - me.animations.splice(i, 1); - } else { - ++i; - } - } - - var endTime = Date.now(); - var dropFrames = (endTime - startTime) / me.frameDuration; - - me.dropFrames += dropFrames; - - // Do we have more stuff to animate? - if (me.animations.length > 0) { - me.requestAnimationFrame(); - } - } - }; -}; diff --git a/system/templates/js/chart-js/src/core/core.canvasHelpers.js b/system/templates/js/chart-js/src/core/core.canvasHelpers.js deleted file mode 100644 index 553730c7..00000000 --- a/system/templates/js/chart-js/src/core/core.canvasHelpers.js +++ /dev/null @@ -1,124 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - // Global Chart canvas helpers object for drawing items to canvas - var helpers = Chart.canvasHelpers = {}; - - helpers.drawPoint = function(ctx, pointStyle, radius, x, y) { - var type, edgeLength, xOffset, yOffset, height, size; - - if (typeof pointStyle === 'object') { - type = pointStyle.toString(); - if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') { - ctx.drawImage(pointStyle, x - pointStyle.width / 2, y - pointStyle.height / 2); - return; - } - } - - if (isNaN(radius) || radius <= 0) { - return; - } - - switch (pointStyle) { - // Default includes circle - default: - ctx.beginPath(); - ctx.arc(x, y, radius, 0, Math.PI * 2); - ctx.closePath(); - ctx.fill(); - break; - case 'triangle': - ctx.beginPath(); - edgeLength = 3 * radius / Math.sqrt(3); - height = edgeLength * Math.sqrt(3) / 2; - ctx.moveTo(x - edgeLength / 2, y + height / 3); - ctx.lineTo(x + edgeLength / 2, y + height / 3); - ctx.lineTo(x, y - 2 * height / 3); - ctx.closePath(); - ctx.fill(); - break; - case 'rect': - size = 1 / Math.SQRT2 * radius; - ctx.beginPath(); - ctx.fillRect(x - size, y - size, 2 * size, 2 * size); - ctx.strokeRect(x - size, y - size, 2 * size, 2 * size); - break; - case 'rectRounded': - var offset = radius / Math.SQRT2; - var leftX = x - offset; - var topY = y - offset; - var sideSize = Math.SQRT2 * radius; - Chart.helpers.drawRoundedRectangle(ctx, leftX, topY, sideSize, sideSize, radius / 2); - ctx.fill(); - break; - case 'rectRot': - size = 1 / Math.SQRT2 * radius; - ctx.beginPath(); - ctx.moveTo(x - size, y); - ctx.lineTo(x, y + size); - ctx.lineTo(x + size, y); - ctx.lineTo(x, y - size); - ctx.closePath(); - ctx.fill(); - break; - case 'cross': - ctx.beginPath(); - ctx.moveTo(x, y + radius); - ctx.lineTo(x, y - radius); - ctx.moveTo(x - radius, y); - ctx.lineTo(x + radius, y); - ctx.closePath(); - break; - case 'crossRot': - ctx.beginPath(); - xOffset = Math.cos(Math.PI / 4) * radius; - yOffset = Math.sin(Math.PI / 4) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + xOffset, y + yOffset); - ctx.moveTo(x - xOffset, y + yOffset); - ctx.lineTo(x + xOffset, y - yOffset); - ctx.closePath(); - break; - case 'star': - ctx.beginPath(); - ctx.moveTo(x, y + radius); - ctx.lineTo(x, y - radius); - ctx.moveTo(x - radius, y); - ctx.lineTo(x + radius, y); - xOffset = Math.cos(Math.PI / 4) * radius; - yOffset = Math.sin(Math.PI / 4) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + xOffset, y + yOffset); - ctx.moveTo(x - xOffset, y + yOffset); - ctx.lineTo(x + xOffset, y - yOffset); - ctx.closePath(); - break; - case 'line': - ctx.beginPath(); - ctx.moveTo(x - radius, y); - ctx.lineTo(x + radius, y); - ctx.closePath(); - break; - case 'dash': - ctx.beginPath(); - ctx.moveTo(x, y); - ctx.lineTo(x + radius, y); - ctx.closePath(); - break; - } - - ctx.stroke(); - }; - - helpers.clipArea = function(ctx, clipArea) { - ctx.save(); - ctx.beginPath(); - ctx.rect(clipArea.left, clipArea.top, clipArea.right - clipArea.left, clipArea.bottom - clipArea.top); - ctx.clip(); - }; - - helpers.unclipArea = function(ctx) { - ctx.restore(); - }; - -}; diff --git a/system/templates/js/chart-js/src/core/core.controller.js b/system/templates/js/chart-js/src/core/core.controller.js deleted file mode 100644 index b38df58b..00000000 --- a/system/templates/js/chart-js/src/core/core.controller.js +++ /dev/null @@ -1,752 +0,0 @@ -'use strict'; - -module.exports = function(Chart) { - - var helpers = Chart.helpers; - var plugins = Chart.plugins; - var platform = Chart.platform; - - // Create a dictionary of chart types, to allow for extension of existing types - Chart.types = {}; - - // Store a reference to each instance - allowing us to globally resize chart instances on window resize. - // Destroy method on the chart will remove the instance of the chart from this reference. - Chart.instances = {}; - - // Controllers available for dataset visualization eg. bar, line, slice, etc. - Chart.controllers = {}; - - /** - * Initializes the given config with global and chart default values. - */ - function initConfig(config) { - config = config || {}; - - // Do NOT use configMerge() for the data object because this method merges arrays - // and so would change references to labels and datasets, preventing data updates. - var data = config.data = config.data || {}; - data.datasets = data.datasets || []; - data.labels = data.labels || []; - - config.options = helpers.configMerge( - Chart.defaults.global, - Chart.defaults[config.type], - config.options || {}); - - return config; - } - - /** - * Updates the config of the chart - * @param chart {Chart.Controller} chart to update the options for - */ - function updateConfig(chart) { - var newOptions = chart.options; - - // Update Scale(s) with options - if (newOptions.scale) { - chart.scale.options = newOptions.scale; - } else if (newOptions.scales) { - newOptions.scales.xAxes.concat(newOptions.scales.yAxes).forEach(function(scaleOptions) { - chart.scales[scaleOptions.id].options = scaleOptions; - }); - } - - // Tooltip - chart.tooltip._options = newOptions.tooltips; - } - - /** - * @class Chart.Controller - * The main controller of a chart. - */ - Chart.Controller = function(item, config, instance) { - var me = this; - - config = initConfig(config); - - var context = platform.acquireContext(item, config); - var canvas = context && context.canvas; - var height = canvas && canvas.height; - var width = canvas && canvas.width; - - instance.ctx = context; - instance.canvas = canvas; - instance.config = config; - instance.width = width; - instance.height = height; - instance.aspectRatio = height? width / height : null; - - me.id = helpers.uid(); - me.chart = instance; - me.config = config; - me.options = config.options; - me._bufferedRender = false; - - // Add the chart instance to the global namespace - Chart.instances[me.id] = me; - - Object.defineProperty(me, 'data', { - get: function() { - return me.config.data; - } - }); - - if (!context || !canvas) { - // The given item is not a compatible context2d element, let's return before finalizing - // the chart initialization but after setting basic chart / controller properties that - // can help to figure out that the chart is not valid (e.g chart.canvas !== null); - // https://github.com/chartjs/Chart.js/issues/2807 - console.error("Failed to create chart: can't acquire context from the given item"); - return me; - } - - me.initialize(); - me.update(); - - return me; - }; - - helpers.extend(Chart.Controller.prototype, /** @lends Chart.Controller.prototype */ { - initialize: function() { - var me = this; - - // Before init plugin notification - plugins.notify(me, 'beforeInit'); - - helpers.retinaScale(me.chart); - - me.bindEvents(); - - if (me.options.responsive) { - // Initial resize before chart draws (must be silent to preserve initial animations). - me.resize(true); - } - - // Make sure scales have IDs and are built before we build any controllers. - me.ensureScalesHaveIDs(); - me.buildScales(); - me.initToolTip(); - - // After init plugin notification - plugins.notify(me, 'afterInit'); - - return me; - }, - - clear: function() { - helpers.clear(this.chart); - return this; - }, - - stop: function() { - // Stops any current animation loop occurring - Chart.animationService.cancelAnimation(this); - return this; - }, - - resize: function(silent) { - var me = this; - var chart = me.chart; - var options = me.options; - var canvas = chart.canvas; - var aspectRatio = (options.maintainAspectRatio && chart.aspectRatio) || null; - - // the canvas render width and height will be casted to integers so make sure that - // the canvas display style uses the same integer values to avoid blurring effect. - var newWidth = Math.floor(helpers.getMaximumWidth(canvas)); - var newHeight = Math.floor(aspectRatio? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)); - - if (chart.width === newWidth && chart.height === newHeight) { - return; - } - - canvas.width = chart.width = newWidth; - canvas.height = chart.height = newHeight; - canvas.style.width = newWidth + 'px'; - canvas.style.height = newHeight + 'px'; - - helpers.retinaScale(chart); - - if (!silent) { - // Notify any plugins about the resize - var newSize = {width: newWidth, height: newHeight}; - plugins.notify(me, 'resize', [newSize]); - - // Notify of resize - if (me.options.onResize) { - me.options.onResize(me, newSize); - } - - me.stop(); - me.update(me.options.responsiveAnimationDuration); - } - }, - - ensureScalesHaveIDs: function() { - var options = this.options; - var scalesOptions = options.scales || {}; - var scaleOptions = options.scale; - - helpers.each(scalesOptions.xAxes, function(xAxisOptions, index) { - xAxisOptions.id = xAxisOptions.id || ('x-axis-' + index); - }); - - helpers.each(scalesOptions.yAxes, function(yAxisOptions, index) { - yAxisOptions.id = yAxisOptions.id || ('y-axis-' + index); - }); - - if (scaleOptions) { - scaleOptions.id = scaleOptions.id || 'scale'; - } - }, - - /** - * Builds a map of scale ID to scale object for future lookup. - */ - buildScales: function() { - var me = this; - var options = me.options; - var scales = me.scales = {}; - var items = []; - - if (options.scales) { - items = items.concat( - (options.scales.xAxes || []).map(function(xAxisOptions) { - return {options: xAxisOptions, dtype: 'category'}; - }), - (options.scales.yAxes || []).map(function(yAxisOptions) { - return {options: yAxisOptions, dtype: 'linear'}; - }) - ); - } - - if (options.scale) { - items.push({options: options.scale, dtype: 'radialLinear', isDefault: true}); - } - - helpers.each(items, function(item) { - var scaleOptions = item.options; - var scaleType = helpers.getValueOrDefault(scaleOptions.type, item.dtype); - var scaleClass = Chart.scaleService.getScaleConstructor(scaleType); - if (!scaleClass) { - return; - } - - var scale = new scaleClass({ - id: scaleOptions.id, - options: scaleOptions, - ctx: me.chart.ctx, - chart: me - }); - - scales[scale.id] = scale; - - // TODO(SB): I think we should be able to remove this custom case (options.scale) - // and consider it as a regular scale part of the "scales"" map only! This would - // make the logic easier and remove some useless? custom code. - if (item.isDefault) { - me.scale = scale; - } - }); - - Chart.scaleService.addScalesToLayout(this); - }, - - buildOrUpdateControllers: function() { - var me = this; - var types = []; - var newControllers = []; - - helpers.each(me.data.datasets, function(dataset, datasetIndex) { - var meta = me.getDatasetMeta(datasetIndex); - if (!meta.type) { - meta.type = dataset.type || me.config.type; - } - - types.push(meta.type); - - if (meta.controller) { - meta.controller.updateIndex(datasetIndex); - } else { - meta.controller = new Chart.controllers[meta.type](me, datasetIndex); - newControllers.push(meta.controller); - } - }, me); - - if (types.length > 1) { - for (var i = 1; i < types.length; i++) { - if (types[i] !== types[i - 1]) { - me.isCombo = true; - break; - } - } - } - - return newControllers; - }, - - /** - * Reset the elements of all datasets - * @private - */ - resetElements: function() { - var me = this; - helpers.each(me.data.datasets, function(dataset, datasetIndex) { - me.getDatasetMeta(datasetIndex).controller.reset(); - }, me); - }, - - /** - * Resets the chart back to it's state before the initial animation - */ - reset: function() { - this.resetElements(); - this.tooltip.initialize(); - }, - - update: function(animationDuration, lazy) { - var me = this; - - updateConfig(me); - - if (plugins.notify(me, 'beforeUpdate') === false) { - return; - } - - // In case the entire data object changed - me.tooltip._data = me.data; - - // Make sure dataset controllers are updated and new controllers are reset - var newControllers = me.buildOrUpdateControllers(); - - // Make sure all dataset controllers have correct meta data counts - helpers.each(me.data.datasets, function(dataset, datasetIndex) { - me.getDatasetMeta(datasetIndex).controller.buildOrUpdateElements(); - }, me); - - me.updateLayout(); - - // Can only reset the new controllers after the scales have been updated - helpers.each(newControllers, function(controller) { - controller.reset(); - }); - - me.updateDatasets(); - - // Do this before render so that any plugins that need final scale updates can use it - plugins.notify(me, 'afterUpdate'); - - if (me._bufferedRender) { - me._bufferedRequest = { - lazy: lazy, - duration: animationDuration - }; - } else { - me.render(animationDuration, lazy); - } - }, - - /** - * Updates the chart layout unless a plugin returns `false` to the `beforeLayout` - * hook, in which case, plugins will not be called on `afterLayout`. - * @private - */ - updateLayout: function() { - var me = this; - - if (plugins.notify(me, 'beforeLayout') === false) { - return; - } - - Chart.layoutService.update(this, this.chart.width, this.chart.height); - - /** - * Provided for backward compatibility, use `afterLayout` instead. - * @method IPlugin#afterScaleUpdate - * @deprecated since version 2.5.0 - * @todo remove at version 3 - */ - plugins.notify(me, 'afterScaleUpdate'); - plugins.notify(me, 'afterLayout'); - }, - - /** - * Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate` - * hook, in which case, plugins will not be called on `afterDatasetsUpdate`. - * @private - */ - updateDatasets: function() { - var me = this; - - if (plugins.notify(me, 'beforeDatasetsUpdate') === false) { - return; - } - - for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) { - me.getDatasetMeta(i).controller.update(); - } - - plugins.notify(me, 'afterDatasetsUpdate'); - }, - - render: function(duration, lazy) { - var me = this; - - if (plugins.notify(me, 'beforeRender') === false) { - return; - } - - var animationOptions = me.options.animation; - var onComplete = function() { - plugins.notify(me, 'afterRender'); - var callback = animationOptions && animationOptions.onComplete; - if (callback && callback.call) { - callback.call(me); - } - }; - - if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) { - var animation = new Chart.Animation(); - animation.numSteps = (duration || animationOptions.duration) / 16.66; // 60 fps - animation.easing = animationOptions.easing; - - // render function - animation.render = function(chartInstance, animationObject) { - var easingFunction = helpers.easingEffects[animationObject.easing]; - var stepDecimal = animationObject.currentStep / animationObject.numSteps; - var easeDecimal = easingFunction(stepDecimal); - - chartInstance.draw(easeDecimal, stepDecimal, animationObject.currentStep); - }; - - // user events - animation.onAnimationProgress = animationOptions.onProgress; - animation.onAnimationComplete = onComplete; - - Chart.animationService.addAnimation(me, animation, duration, lazy); - } else { - me.draw(); - onComplete(); - } - - return me; - }, - - draw: function(easingValue) { - var me = this; - - me.clear(); - - if (easingValue === undefined || easingValue === null) { - easingValue = 1; - } - - if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) { - return; - } - - // Draw all the scales - helpers.each(me.boxes, function(box) { - box.draw(me.chartArea); - }, me); - - if (me.scale) { - me.scale.draw(); - } - - me.drawDatasets(easingValue); - - // Finally draw the tooltip - me.tooltip.transition(easingValue).draw(); - - plugins.notify(me, 'afterDraw', [easingValue]); - }, - - /** - * Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw` - * hook, in which case, plugins will not be called on `afterDatasetsDraw`. - * @private - */ - drawDatasets: function(easingValue) { - var me = this; - - if (plugins.notify(me, 'beforeDatasetsDraw', [easingValue]) === false) { - return; - } - - // Draw each dataset via its respective controller (reversed to support proper line stacking) - helpers.each(me.data.datasets, function(dataset, datasetIndex) { - if (me.isDatasetVisible(datasetIndex)) { - me.getDatasetMeta(datasetIndex).controller.draw(easingValue); - } - }, me, true); - - plugins.notify(me, 'afterDatasetsDraw', [easingValue]); - }, - - // Get the single element that was clicked on - // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw - getElementAtEvent: function(e) { - return Chart.Interaction.modes.single(this, e); - }, - - getElementsAtEvent: function(e) { - return Chart.Interaction.modes.label(this, e, {intersect: true}); - }, - - getElementsAtXAxis: function(e) { - return Chart.Interaction.modes['x-axis'](this, e, {intersect: true}); - }, - - getElementsAtEventForMode: function(e, mode, options) { - var method = Chart.Interaction.modes[mode]; - if (typeof method === 'function') { - return method(this, e, options); - } - - return []; - }, - - getDatasetAtEvent: function(e) { - return Chart.Interaction.modes.dataset(this, e, {intersect: true}); - }, - - getDatasetMeta: function(datasetIndex) { - var me = this; - var dataset = me.data.datasets[datasetIndex]; - if (!dataset._meta) { - dataset._meta = {}; - } - - var meta = dataset._meta[me.id]; - if (!meta) { - meta = dataset._meta[me.id] = { - type: null, - data: [], - dataset: null, - controller: null, - hidden: null, // See isDatasetVisible() comment - xAxisID: null, - yAxisID: null - }; - } - - return meta; - }, - - getVisibleDatasetCount: function() { - var count = 0; - for (var i = 0, ilen = this.data.datasets.length; i