chartjs-plugin-waterfall
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -373,3 +373,3 @@ (function (global, factory) { | ||
var initializeDatasets = function initializeDatasets(chart) { | ||
chart.data.datasets.forEach(function (dataset, i) { | ||
chart.data.datasets.forEach(function (dataset) { | ||
dataset.waterfall = merge({}, { | ||
@@ -379,5 +379,3 @@ stepLines: {} | ||
// Each dataset must have a unique label so we set the dummy stacks to have dummy labels | ||
if (dataset.waterfall.dummyStack) { | ||
dataset.label = 'dummyStack_' + i; | ||
dataset.backgroundColor = 'rgba(0, 0, 0, 0)'; | ||
@@ -384,0 +382,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lodash.merge"),require("lodash.groupby")):"function"==typeof define&&define.amd?define(["lodash.merge","lodash.groupby"],e):t.chartjsWPluginWaterfall=e(t._.merge,t._.groupby)}(this,function(t,e){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;!function(){function t(t){this.value=t}function e(e){function o(n,r){try{var s=e[n](r),i=s.value;i instanceof t?Promise.resolve(i.value).then(function(t){o("next",t)},function(t){o("throw",t)}):a(s.done?"return":"normal",s.value)}catch(t){a("throw",t)}}function a(t,e){switch(t){case"return":n.resolve({value:e,done:!0});break;case"throw":n.reject(e);break;default:n.resolve({value:e,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}var n,r;this._invoke=function(t,e){return new Promise(function(a,s){var i={key:t,arg:e,resolve:a,reject:s,next:null};r?r=r.next=i:(n=r=i,o(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var o=function(t){if(Array.isArray(t)){for(var e=0,o=Array(t.length);e<t.length;e++)o[e]=t[e];return o}return Array.from(t)},a=function(t,e,o,a){var n=o.stackBase,r=a.stackBase,s=o.stackTopYPos,i=a.stackTopYPos;s===r?(i=r,r=a.dummyStackBase):n===i&&(s=n,n=o.dummyStackBase),!o.isPositive&&a.isPositive&&(i=r,r=a.stackTopYPos),o.isPositive&&!a.isPositive&&(s=n,n=o.stackTopYPos);var l=s>i?s:i,u=n>r?n:r,c=t.createLinearGradient(0,l,0,u),f=o.options.startColor||e.startColor,p=o.options.endColor||e.endColor,d=o.options.startColorStop||e.startColorStop,k=o.options.endColorStop||e.endColorStop;c.addColorStop(d,f),c.addColorStop(k,p),t.fillStyle=c,t.beginPath(),t.lineTo(o.stackRightXPos,s),t.lineTo(a.stackLeftXPos,i),t.lineTo(a.stackLeftXPos,r),t.lineTo(o.stackRightXPos,n),t.fill()},n=function(t){var n=t.ctx,r=t.data.datasets,s=t.options.plugins.waterFallPlugin.stepLines,i=e(r,"stack"),l=[],u=function(t){var e=Object.keys(t._meta)[0];return t._meta[e].data[0]._model};Object.keys(i).forEach(function(t){var e=i[t],a=e.filter(function(t){return!t.waterfall.dummyStack}).map(function(t){return u(t).base}),n=Math.max.apply(Math,o(a)),r=e.map(function(t){return u(t).base}),s=Math.max.apply(Math,o(r)),c=e.map(function(t){var e=u(t);return{stackRightXPos:e.x+e.width/2,stackLeftXPos:e.x-e.width/2,stackTopYPos:e.y,stackBase:n,dummyStackBase:s,isPositive:t.data[0]>0,options:t.waterfall.stepLines}});l.push(c)});for(var c=function(t){var e=t.length-1;return{stackRightXPos:t[e].stackRightXPos,stackLeftXPos:t[e].stackLeftXPos,stackTopYPos:t[e].stackTopYPos,stackBase:t[e].stackBase,dummyStackBase:t[e].dummyStackBase,isPositive:t[e].isPositive,options:t[e].options}},f=function(t){var e=l[t];if(t!==l.length-1){var o=l[t+1],r=c(e),i=c(o);(s.diagonalStepLines||function(t,e){return t.stackTopYPos===e.stackTopYPos&&t.stackBase===e.stackBase}(r,i))&&a(n,s,r,i),Array.isArray(s.diagonalStepLines)&&s.diagonalStepLines.forEach(function(t){var r=t[0],i=t[1],l=e[r],u=o[i];l&&u&&a(n,s,l,u)})}},p=0;p<l.length;p+=1)f(p)},r={waterFallPlugin:{stepLines:{enabled:!0,startColorStop:0,endColorStop:.6,startColor:"rgba(0, 0, 0, 0.55)",endColor:"rgba(0, 0, 0, 0)",diagonalStepLines:!0}}},s={},i=function(t,e){return!e.datasets[t.datasetIndex].waterfall.dummyStack},l=function(e){e.data.datasets.forEach(function(e,o){e.waterfall=t({},{stepLines:{}},e.waterfall),e.waterfall.dummyStack&&(e.label="dummyStack_"+o,e.backgroundColor="rgba(0, 0, 0, 0)")})};return{beforeInit:function(t){s[t.id]={readyToDrawStepLines:!1}},afterInit:function(e){l(e),e.options.plugins=t({},r,e.options.plugins),e.options.tooltips.filter=i,e.options.legend.labels.filter=i,setTimeout(function(){s[e.id].readyToDrawStepLines=!0,n(e)},e.options.animation.duration)},afterDraw:function(t){var e=t.options.plugins.waterFallPlugin;l(t),e.stepLines.enabled&&s[t.id].readyToDrawStepLines&&n(t)}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("lodash.merge"),require("lodash.groupby")):"function"==typeof define&&define.amd?define(["lodash.merge","lodash.groupby"],e):t.chartjsWPluginWaterfall=e(t._.merge,t._.groupby)}(this,function(t,e){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;!function(){function t(t){this.value=t}function e(e){function o(n,r){try{var s=e[n](r),i=s.value;i instanceof t?Promise.resolve(i.value).then(function(t){o("next",t)},function(t){o("throw",t)}):a(s.done?"return":"normal",s.value)}catch(t){a("throw",t)}}function a(t,e){switch(t){case"return":n.resolve({value:e,done:!0});break;case"throw":n.reject(e);break;default:n.resolve({value:e,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}var n,r;this._invoke=function(t,e){return new Promise(function(a,s){var i={key:t,arg:e,resolve:a,reject:s,next:null};r?r=r.next=i:(n=r=i,o(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var o=function(t){if(Array.isArray(t)){for(var e=0,o=Array(t.length);e<t.length;e++)o[e]=t[e];return o}return Array.from(t)},a=function(t,e,o,a){var n=o.stackBase,r=a.stackBase,s=o.stackTopYPos,i=a.stackTopYPos;s===r?(i=r,r=a.dummyStackBase):n===i&&(s=n,n=o.dummyStackBase),!o.isPositive&&a.isPositive&&(i=r,r=a.stackTopYPos),o.isPositive&&!a.isPositive&&(s=n,n=o.stackTopYPos);var l=s>i?s:i,u=n>r?n:r,c=t.createLinearGradient(0,l,0,u),f=o.options.startColor||e.startColor,p=o.options.endColor||e.endColor,d=o.options.startColorStop||e.startColorStop,k=o.options.endColorStop||e.endColorStop;c.addColorStop(d,f),c.addColorStop(k,p),t.fillStyle=c,t.beginPath(),t.lineTo(o.stackRightXPos,s),t.lineTo(a.stackLeftXPos,i),t.lineTo(a.stackLeftXPos,r),t.lineTo(o.stackRightXPos,n),t.fill()},n=function(t){var n=t.ctx,r=t.data.datasets,s=t.options.plugins.waterFallPlugin.stepLines,i=e(r,"stack"),l=[],u=function(t){var e=Object.keys(t._meta)[0];return t._meta[e].data[0]._model};Object.keys(i).forEach(function(t){var e=i[t],a=e.filter(function(t){return!t.waterfall.dummyStack}).map(function(t){return u(t).base}),n=Math.max.apply(Math,o(a)),r=e.map(function(t){return u(t).base}),s=Math.max.apply(Math,o(r)),c=e.map(function(t){var e=u(t);return{stackRightXPos:e.x+e.width/2,stackLeftXPos:e.x-e.width/2,stackTopYPos:e.y,stackBase:n,dummyStackBase:s,isPositive:t.data[0]>0,options:t.waterfall.stepLines}});l.push(c)});for(var c=function(t){var e=t.length-1;return{stackRightXPos:t[e].stackRightXPos,stackLeftXPos:t[e].stackLeftXPos,stackTopYPos:t[e].stackTopYPos,stackBase:t[e].stackBase,dummyStackBase:t[e].dummyStackBase,isPositive:t[e].isPositive,options:t[e].options}},f=function(t){var e=l[t];if(t!==l.length-1){var o=l[t+1],r=c(e),i=c(o);(s.diagonalStepLines||function(t,e){return t.stackTopYPos===e.stackTopYPos&&t.stackBase===e.stackBase}(r,i))&&a(n,s,r,i),Array.isArray(s.diagonalStepLines)&&s.diagonalStepLines.forEach(function(t){var r=t[0],i=t[1],l=e[r],u=o[i];l&&u&&a(n,s,l,u)})}},p=0;p<l.length;p+=1)f(p)},r={waterFallPlugin:{stepLines:{enabled:!0,startColorStop:0,endColorStop:.6,startColor:"rgba(0, 0, 0, 0.55)",endColor:"rgba(0, 0, 0, 0)",diagonalStepLines:!0}}},s={},i=function(t,e){return!e.datasets[t.datasetIndex].waterfall.dummyStack},l=function(e){e.data.datasets.forEach(function(e){e.waterfall=t({},{stepLines:{}},e.waterfall),e.waterfall.dummyStack&&(e.backgroundColor="rgba(0, 0, 0, 0)")})};return{beforeInit:function(t){s[t.id]={readyToDrawStepLines:!1}},afterInit:function(e){l(e),e.options.plugins=t({},r,e.options.plugins),e.options.tooltips.filter=i,e.options.legend.labels.filter=i,setTimeout(function(){s[e.id].readyToDrawStepLines=!0,n(e)},e.options.animation.duration)},afterDraw:function(t){var e=t.options.plugins.waterFallPlugin;l(t),e.stepLines.enabled&&s[t.id].readyToDrawStepLines&&n(t)}}}); | ||
//# sourceMappingURL=chartjs-plugin-waterfall.min.js.map |
@@ -371,3 +371,3 @@ 'use strict'; | ||
var initializeDatasets = function initializeDatasets(chart) { | ||
chart.data.datasets.forEach(function (dataset, i) { | ||
chart.data.datasets.forEach(function (dataset) { | ||
dataset.waterfall = merge({}, { | ||
@@ -377,5 +377,3 @@ stepLines: {} | ||
// Each dataset must have a unique label so we set the dummy stacks to have dummy labels | ||
if (dataset.waterfall.dummyStack) { | ||
dataset.label = 'dummyStack_' + i; | ||
dataset.backgroundColor = 'rgba(0, 0, 0, 0)'; | ||
@@ -382,0 +380,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "Chart.js plugin for easy waterfall charts", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "lib/chartjs-plugin-waterfall.js", |
@@ -73,3 +73,5 @@ ### Installation | ||
globally: Chart.defaults.global.plugins.waterfall.* | ||
per chart: options.plugins.waterfall.* | ||
per dataset: dataset.waterfall.* (not all options) | ||
@@ -76,0 +78,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142
78881
619