From b4006390a4b8de13bcce5520635e4a5af040da92 Mon Sep 17 00:00:00 2001 From: Jonathon Hill Date: Fri, 18 Nov 2016 11:02:58 -0500 Subject: [PATCH] Bump version to 0.1.3 --- dist/chartjs-plugin-draggable.js | 160 ++++++++++++++------------- dist/chartjs-plugin-draggable.min.js | 4 +- package.json | 2 +- webpack.config.js | 2 +- 4 files changed, 85 insertions(+), 83 deletions(-) diff --git a/dist/chartjs-plugin-draggable.js b/dist/chartjs-plugin-draggable.js index c13f9e2..97fddb6 100644 --- a/dist/chartjs-plugin-draggable.js +++ b/dist/chartjs-plugin-draggable.js @@ -1,7 +1,7 @@ /*! * chartjs-plugin-draggable.js * http://chartjs.org/ - * Version: 0.1.2 + * Version: 0.1.3 * * Copyright 2016 Jonathon Hill * Released under the MIT license @@ -1465,7 +1465,7 @@ var _accessor = __webpack_require__(7); - var _lineElement = __webpack_require__(8); + var _lineElement = __webpack_require__(9); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -1514,8 +1514,7 @@ case 'line': return _lineElement.DraggableLineAnnotationElement; - default: - throw 'Unsupported annotation type: ' + config.type; + // @TODO: implement 'box' support, DraggableBoxAnnotationElement class } }); } @@ -1527,16 +1526,19 @@ /***/ }, /* 7 */ -/***/ function(module, exports) { +/***/ function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); + exports.DraggableElementAccessor = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var _element = __webpack_require__(8); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var DraggableElementAccessor = exports.DraggableElementAccessor = function () { @@ -1557,7 +1559,7 @@ }; return elements.map(function (element, i) { - var className = elementClassFn(configs[i]); + var className = elementClassFn(configs[i]) || _element.DraggableElement; return new className(chartInstance, element, configs[i]); }).filter(function (element, i) { return !!configs[i].draggable; @@ -1570,79 +1572,6 @@ /***/ }, /* 8 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.DraggableLineAnnotationElement = undefined; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _element = __webpack_require__(9); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var DraggableLineAnnotationElement = exports.DraggableLineAnnotationElement = function (_DraggableElement) { - _inherits(DraggableLineAnnotationElement, _DraggableElement); - - function DraggableLineAnnotationElement(chartInstance, elementInstance, elementConfig) { - _classCallCheck(this, DraggableLineAnnotationElement); - - var _this = _possibleConstructorReturn(this, (DraggableLineAnnotationElement.__proto__ || Object.getPrototypeOf(DraggableLineAnnotationElement)).call(this, chartInstance, elementInstance, elementConfig)); - - _this.scale = _this.chart.scales[elementConfig.scaleID]; - return _this; - } - - _createClass(DraggableLineAnnotationElement, [{ - key: '_getPixel', - value: function _getPixel(event) { - return this.scale.isHorizontal() ? event.x : event.y; - } - }, { - key: '_getValue', - value: function _getValue(event) { - var offset = this.offset || 0; - return this.scale.getValueForPixel(this._getPixel(event) - offset); - } - }, { - key: 'getBox', - value: function getBox(tolerance) { - return { - x: [this.element._view.x1 - tolerance, this.element._view.x2 + tolerance], - y: [this.element._view.y1 - tolerance, this.element._view.y2 + tolerance] - }; - } - }, { - key: 'onDragStart', - value: function onDragStart(event) { - this.offset = this._getPixel(event) - this.scale.getPixelForValue(this.config.value); - } - }, { - key: 'onDrag', - value: function onDrag(event) { - this.config.value = this._constrainValue(this.scale, this._getValue(event)); - this.chart.update(0); - } - }, { - key: 'onDragEnd', - value: function onDragEnd(event) { - this.offset = undefined; - } - }]); - - return DraggableLineAnnotationElement; - }(_element.DraggableElement); - -/***/ }, -/* 9 */ /***/ function(module, exports) { 'use strict'; @@ -1742,5 +1671,78 @@ return DraggableElement; }(); +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.DraggableLineAnnotationElement = undefined; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _element = __webpack_require__(8); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + var DraggableLineAnnotationElement = exports.DraggableLineAnnotationElement = function (_DraggableElement) { + _inherits(DraggableLineAnnotationElement, _DraggableElement); + + function DraggableLineAnnotationElement(chartInstance, elementInstance, elementConfig) { + _classCallCheck(this, DraggableLineAnnotationElement); + + var _this = _possibleConstructorReturn(this, (DraggableLineAnnotationElement.__proto__ || Object.getPrototypeOf(DraggableLineAnnotationElement)).call(this, chartInstance, elementInstance, elementConfig)); + + _this.scale = _this.chart.scales[elementConfig.scaleID]; + return _this; + } + + _createClass(DraggableLineAnnotationElement, [{ + key: '_getPixel', + value: function _getPixel(event) { + return this.scale.isHorizontal() ? event.x : event.y; + } + }, { + key: '_getValue', + value: function _getValue(event) { + var offset = this.offset || 0; + return this.scale.getValueForPixel(this._getPixel(event) - offset); + } + }, { + key: 'getBox', + value: function getBox(tolerance) { + return { + x: [this.element._view.x1 - tolerance, this.element._view.x2 + tolerance], + y: [this.element._view.y1 - tolerance, this.element._view.y2 + tolerance] + }; + } + }, { + key: 'onDragStart', + value: function onDragStart(event) { + this.offset = this._getPixel(event) - this.scale.getPixelForValue(this.config.value); + } + }, { + key: 'onDrag', + value: function onDrag(event) { + this.config.value = this._constrainValue(this.scale, this._getValue(event)); + this.chart.update(0); + } + }, { + key: 'onDragEnd', + value: function onDragEnd(event) { + this.offset = undefined; + } + }]); + + return DraggableLineAnnotationElement; + }(_element.DraggableElement); + /***/ } /******/ ]); \ No newline at end of file diff --git a/dist/chartjs-plugin-draggable.min.js b/dist/chartjs-plugin-draggable.min.js index fd871f1..dc3646d 100644 --- a/dist/chartjs-plugin-draggable.min.js +++ b/dist/chartjs-plugin-draggable.min.js @@ -1,10 +1,10 @@ /*! * chartjs-plugin-draggable.js * http://chartjs.org/ - * Version: 0.1.2 + * Version: 0.1.3 * * Copyright 2016 Jonathon Hill * Released under the MIT license * https://github.com/compwright/chartjs-plugin-draggable/blob/master/LICENSE.md */ -!function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=n(6),c=new u.ChartjsDraggablePlugin([a.DraggableAnnotationAccessor]);i.default.pluginService.register(c),e.default=c},function(t,e){t.exports=Chart},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){return function(){return t.draggable.draggables=e.map(function(e){return e.getElements(t)}).reduce(function(t,e){return t.concat(e)},[]).filter(function(t){return t.isInBox(s.event,10)}),t.draggable.draggables.length>0}}function i(t){return function(){return t.draggable.draggables[0]}}function u(t,e){return function(){return t().dispatch(e,s.event)}}Object.defineProperty(e,"__esModule",{value:!0}),e.ChartjsDraggablePlugin=void 0;var a=function(){function t(t,e){for(var n=0;n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}function o(t,e){for(var n,r=0,o=t.length;r0)for(var n,r,o=new Array(n),i=0;i=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Rt.hasOwnProperty(e)?{space:Rt[e],local:t}:t}function n(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ut&&e.documentElement.namespaceURI===Ut?e.createElement(t):e.createElementNS(n,t)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function o(t){var o=e(t);return(o.local?r:n)(o)}function i(){return new u}function u(){this._="@"+(++Ht).toString(36)}function a(t,e,n){return t=c(t,e,n),function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t.call(this,e)}}function c(e,n,r){return function(o){var i=t.event;t.event=o;try{e.call(this,this.__data__,n,r)}finally{t.event=i}}}function s(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}function l(t){return function(){var e=this.__on;if(e){for(var n,r=0,o=-1,i=e.length;r=b&&(b=w+1);!(m=g[b])&&++b=0;)(r=o[i])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function N(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=L);for(var n=this._groups,r=n.length,o=new Array(r),i=0;ie?1:t>=e?0:NaN}function B(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function V(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t}function I(){for(var t=this._groups,e=0,n=t.length;e1?this.each((null==e?K:"function"==typeof e?W:Q)(t,e,null==n?"":n)):J(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function tt(t){return function(){delete this[t]}}function et(t,e){return function(){this[t]=e}}function nt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function rt(t,e){return arguments.length>1?this.each((null==e?tt:"function"==typeof e?nt:et)(t,e)):this.node()[t]}function ot(t){return t.trim().split(/^|\s+/)}function it(t){return t.classList||new ut(t)}function ut(t){this._node=t,this._names=ot(t.getAttribute("class")||"")}function at(t,e){for(var n=it(t),r=-1,o=e.length;++r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Qt=[null];Lt.prototype=Bt.prototype={constructor:Lt,select:m,selectAll:x,filter:E,data:D,enter:P,exit:T,merge:M,order:C,sort:N,call:B,nodes:V,node:I,size:q,empty:z,each:U,attr:$,style:Z,property:rt,classed:ht,text:gt,html:wt,raise:xt,lower:At,append:Pt,insert:St,remove:kt,datum:Dt,on:h,dispatch:Nt},t.creator=o,t.local=i,t.matcher=Ft,t.mouse=g,t.namespace=e,t.namespaces=Rt,t.select=Vt,t.selectAll=It,t.selection=Bt,t.selector=_,t.selectorAll=b,t.touch=qt,t.touches=zt,t.window=J,t.customEvent=p,Object.defineProperty(t,"__esModule",{value:!0})})},function(t,e,n){(function(t){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.DraggableAnnotationAccessor=void 0;var u=function(){function t(t,e){for(var n=0;n=o.x[0]&&n.x<=o.x[1]&&n.y>=o.y[0]&&n.y<=o.y[1]}},{key:"_constrainValue",value:function(t,e){return"undefined"!=typeof t.min&&et.max?t.max:e}},{key:"dispatch",value:function(t,e){"function"==typeof this[t]&&this[t](e),"function"==typeof this.config[t]&&this.config[t](e)}}]),t}()}]); \ No newline at end of file +!function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),i=r(o),u=n(2),a=n(6),c=new u.ChartjsDraggablePlugin([a.DraggableAnnotationAccessor]);i.default.pluginService.register(c),e.default=c},function(t,e){t.exports=Chart},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){return function(){return t.draggable.draggables=e.map(function(e){return e.getElements(t)}).reduce(function(t,e){return t.concat(e)},[]).filter(function(t){return t.isInBox(s.event,10)}),t.draggable.draggables.length>0}}function i(t){return function(){return t.draggable.draggables[0]}}function u(t,e){return function(){return t().dispatch(e,s.event)}}Object.defineProperty(e,"__esModule",{value:!0}),e.ChartjsDraggablePlugin=void 0;var a=function(){function t(t,e){for(var n=0;n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}function o(t,e){for(var n,r=0,o=t.length;r0)for(var n,r,o=new Array(n),i=0;i=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Ut.hasOwnProperty(e)?{space:Ut[e],local:t}:t}function n(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Rt&&e.documentElement.namespaceURI===Rt?e.createElement(t):e.createElementNS(n,t)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function o(t){var o=e(t);return(o.local?r:n)(o)}function i(){return new u}function u(){this._="@"+(++Ht).toString(36)}function a(t,e,n){return t=c(t,e,n),function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t.call(this,e)}}function c(e,n,r){return function(o){var i=t.event;t.event=o;try{e.call(this,this.__data__,n,r)}finally{t.event=i}}}function s(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}function l(t){return function(){var e=this.__on;if(e){for(var n,r=0,o=-1,i=e.length;r=b&&(b=w+1);!(m=y[b])&&++b=0;)(r=o[i])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function N(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=L);for(var n=this._groups,r=n.length,o=new Array(r),i=0;ie?1:t>=e?0:NaN}function B(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function V(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t}function I(){for(var t=this._groups,e=0,n=t.length;e1?this.each((null==e?K:"function"==typeof e?W:Q)(t,e,null==n?"":n)):J(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function tt(t){return function(){delete this[t]}}function et(t,e){return function(){this[t]=e}}function nt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function rt(t,e){return arguments.length>1?this.each((null==e?tt:"function"==typeof e?nt:et)(t,e)):this.node()[t]}function ot(t){return t.trim().split(/^|\s+/)}function it(t){return t.classList||new ut(t)}function ut(t){this._node=t,this._names=ot(t.getAttribute("class")||"")}function at(t,e){for(var n=it(t),r=-1,o=e.length;++r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Qt=[null];Lt.prototype=Bt.prototype={constructor:Lt,select:m,selectAll:x,filter:E,data:D,enter:P,exit:T,merge:M,order:C,sort:N,call:B,nodes:V,node:I,size:q,empty:z,each:R,attr:$,style:Z,property:rt,classed:ht,text:yt,html:wt,raise:xt,lower:At,append:Pt,insert:St,remove:kt,datum:Dt,on:h,dispatch:Nt},t.creator=o,t.local=i,t.matcher=Ft,t.mouse=y,t.namespace=e,t.namespaces=Ut,t.select=Vt,t.selectAll=It,t.selection=Bt,t.selector=_,t.selectorAll=b,t.touch=qt,t.touches=zt,t.window=J,t.customEvent=p,Object.defineProperty(t,"__esModule",{value:!0})})},function(t,e,n){(function(t){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.DraggableAnnotationAccessor=void 0;var u=function(){function t(t,e){for(var n=0;n=o.x[0]&&n.x<=o.x[1]&&n.y>=o.y[0]&&n.y<=o.y[1]}},{key:"_constrainValue",value:function(t,e){return"undefined"!=typeof t.min&&et.max?t.max:e}},{key:"dispatch",value:function(t,e){"function"==typeof this[t]&&this[t](e),"function"==typeof this.config[t]&&this.config[t](e)}}]),t}()},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.DraggableLineAnnotationElement=void 0;var u=function(){function t(t,e){for(var n=0;n