forked from chartjs/chartjs-plugin-annotation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chart.Annotation.min.js
10 lines (10 loc) · 3.21 KB
/
Chart.Annotation.min.js
1
2
3
4
5
6
7
8
9
10
/*!
* Chart.Annotation.js
* http://chartjs.org/
* Version: 0.1.1
*
* Copyright 2016 Evert Timberg
* Released under the MIT license
* https://github.com/chartjs/Chart.Annotation.js/blob/master/LICENSE.md
*/
!function t(o,e,n){function r(i,s){if(!e[i]){if(!o[i]){var l="function"==typeof require&&require;if(!s&&l)return l(i,!0);if(a)return a(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var u=e[i]={exports:{}};o[i][0].call(u.exports,function(t){var e=o[i][1][t];return r(e?e:t)},u,u.exports,t,o,e,n)}return e[i].exports}for(var a="function"==typeof require&&require,i=0;i<n.length;i++)r(n[i]);return r}({1:[function(t,o,e){},{}],2:[function(t,o,e){o.exports=function(t){function o(t){return!isNaN(t)&&isFinite(t)}function e(t,e,n){var r,a,i=t._model=t._model||{},s=n.scales[e.xScaleID],l=n.scales[e.yScaleID],f=n.chartArea,u=f.left,c=f.top,d=f.right,h=f.bottom;s&&(r=o(e.xMin)?s.getPixelForValue(e.xMin):f.left,a=o(e.xMax)?s.getPixelForValue(e.xMax):f.right,u=Math.min(r,a),d=Math.max(r,a)),l&&(r=o(e.yMin)?l.getPixelForValue(e.yMin):f.bottom,a=o(e.yMax)?l.getPixelForValue(e.yMax):f.top,c=Math.min(r,a),h=Math.max(r,a)),i.left=u,i.top=c,i.right=d,i.bottom=h,i.borderColor=e.borderColor,i.borderWidth=e.borderWidth,i.backgroundColor=e.backgroundColor}var n=t.Element.extend({draw:function(t){var o=this._view;t.lineWidth=o.borderWidth,t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor;var e=o.right-o.left,n=o.bottom-o.top;t.fillRect(o.left,o.top,e,n),t.strokeRect(o.left,o.top,e,n)}});return{Constructor:n,update:e}}},{}],3:[function(t,o,e){var n=t("chart.js");n="function"==typeof n?n:window.Chart;var r=n.helpers,a=r.isArray;n.Annotation=n.Annotation||{};var i=(n.Annotation.defaults={annotations:[]},t("./line.js")(n)),s=t("./box.js")(n),l=n.Annotation.annotationTypes={line:i.Constructor,box:s.Constructor},f=n.Annotation.updateFunctions={line:i.update,box:s.update},u=n.PluginBase.extend({beforeInit:function(t){var o=t.options;o.annotation=r.configMerge(o.annotation,n.Annotation.defaults);var e=o.annotation.annotations;if(a(e)){var i=t._annotationObjects=[];e.forEach(function(t,o){var e=l[t.type];e&&i.push(new e({_index:o}))})}},afterScaleUpdate:function(t){var o=t._annotationObjects,e=t.options.annotation;a(o)&&o.forEach(function(o,n){var r=e.annotations[o._index],a=f[r.type];a&&a(o,r,t)})},afterDraw:function(t,o){var e=t._annotationObjects;if(a(e)){var n=t.chart.ctx;e.forEach(function(t){t.transition(o).draw(n)})}}});o.exports=u,n.pluginService.register(new u)},{"./box.js":2,"./line.js":4,"chart.js":1}],4:[function(t,o,e){o.exports=function(t){function o(t,o,n){var r=t._model=t._model||{},a=n.scales[o.scaleID],i=a?a.getPixelForValue(o.value):NaN,s=n.chartArea;isNaN(i)||(o.mode==e?(r.x1=s.left,r.x2=s.right,r.y1=r.y2=i):(r.y1=s.top,r.y2=s.bottom,r.x1=r.x2=i)),r.borderColor=o.borderColor,r.borderWidth=o.borderWidth,r.borderDash=o.borderDash||[],r.borderDashOffset=o.borderDashOffset||0}var e="horizontal",n=t.Element.extend({draw:function(t){var o=this._view;t.lineWidth=o.borderWidth,t.strokeStyle=o.borderColor,t.setLineDash&&t.setLineDash(o.borderDash),t.lineDashOffset=o.borderDashOffset,t.beginPath(),t.moveTo(o.x1,o.y1),t.lineTo(o.x2,o.y2),t.stroke()}});return{Constructor:n,update:o}}},{}]},{},[3]);