@kevinburke/flot 5.1.1 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/flot.js +47 -28
- package/dist/flot.min.js +1 -1
- package/dist/flot.min.js.map +1 -1
- package/dist/flot.mjs +47 -28
- package/dist/jquery.flot.js +69 -28
- package/dist/jquery.flot.min.js +1 -1
- package/dist/jquery.flot.min.js.map +1 -1
- package/dist/plugins/jquery.flot.crosshair.js +1 -1
- package/dist/plugins/jquery.flot.image.js +1 -1
- package/dist/plugins/jquery.flot.pie.js +3 -3
- package/dist/plugins/jquery.flot.pie.min.js +1 -1
- package/dist/plugins/jquery.flot.pie.min.js.map +1 -1
- package/dist/plugins/jquery.flot.resize.js +1 -1
- package/dist/plugins/jquery.flot.threshold.js +1 -1
- package/package.json +1 -1
- package/source/helpers.js +16 -4
- package/source/jquery-adapter.js +19 -0
- package/source/jquery.canvaswrapper.js +8 -4
- package/source/jquery.flot.browser.js +1 -1
- package/source/jquery.flot.composeImages.js +1 -1
- package/source/jquery.flot.hover.js +4 -4
- package/source/jquery.flot.js +1 -1
- package/source/jquery.flot.legend.js +1 -1
- package/source/jquery.flot.navigate.js +1 -1
- package/source/jquery.flot.pie.js +2 -2
- package/source/jquery.flot.selection.js +3 -2
- package/source/jquery.flot.time.js +3 -3
- package/source/jquery.flot.touch.js +6 -1
- package/source/jquery.flot.touchNavigate.js +5 -3
- package/source/jquery.js +0 -9473
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @kevinburke/flot v5.1.
|
|
1
|
+
/*! @kevinburke/flot v5.1.2 | MIT License | https://github.com/kevinburke/flot */
|
|
2
2
|
(function (jquery_flot_js, helpers_js) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -662,8 +662,8 @@
|
|
|
662
662
|
// event fires before processDatapoints has run.
|
|
663
663
|
var options = plot.getOptions();
|
|
664
664
|
var offset = plot.offset();
|
|
665
|
-
var canvasX = parseInt(e.pageX - offset.left);
|
|
666
|
-
var canvasY = parseInt(e.pageY - offset.top);
|
|
665
|
+
var canvasX = parseInt(String(e.pageX - offset.left));
|
|
666
|
+
var canvasY = parseInt(String(e.pageY - offset.top));
|
|
667
667
|
var item = findNearbySlice(canvasX, canvasY);
|
|
668
668
|
|
|
669
669
|
if (options.grid.autoHighlight) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"use strict";var i={series:{pie:{show:!1,radius:"auto",innerRadius:0,startAngle:1.5,tilt:1,shadow:{left:5,top:15,alpha:.02},offset:{top:0,left:"auto"},stroke:{color:"#fff",width:1},label:{show:"auto",formatter:function(e,t){return"<div style='font-size:x-small;text-align:center;padding:2px;color:"+t.color+";'>"+e+"<br/>"+Math.round(t.percent)+"%</div>"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:.5}}}};e.plugins.push({init:function(e){var i=null,s=null,r=null,a=null,l=null,n=null,o=!1,p=null,h=[];function c(t){var i=e.getOptions();if(i.series.pie.innerRadius>0){t.save();var s=i.series.pie.innerRadius>1?i.series.pie.innerRadius:a*i.series.pie.innerRadius;t.globalCompositeOperation="destination-out",t.beginPath(),t.fillStyle=i.series.pie.stroke.color,t.arc(0,0,s,0,2*Math.PI,!1),t.fill(),t.closePath(),t.restore(),t.save(),t.beginPath(),t.strokeStyle=i.series.pie.stroke.color,t.arc(0,0,s,0,2*Math.PI,!1),t.stroke(),t.closePath(),t.restore()}}function u(e,t){for(var i=!1,s=-1,r=e.length,a=r-1;++s<r;a=s)(e[s][1]<=t[1]&&t[1]<e[a][1]||e[a][1]<=t[1]&&t[1]<e[s][1])&&t[0]<(e[a][0]-e[s][0])*(t[1]-e[s][1])/(e[a][1]-e[s][1])+e[s][0]&&(i=!i);return i}function g(e){f("plothover",e)}function d(e){f("plotclick",e)}function f(i,r){var o=e.getOptions(),c=e.offset(),g=function(t,i){for(var s,r,o=e.getData(),h=e.getOptions(),c=h.series.pie.radius>1?h.series.pie.radius:a*h.series.pie.radius,g=0;g<o.length;++g){var d=o[g];if(d.pie.show){if(p.save(),p.beginPath(),p.moveTo(0,0),p.arc(0,0,c,d.startAngle,d.startAngle+d.angle/2,!1),p.arc(0,0,c,d.startAngle+d.angle/2,d.startAngle+d.angle,!1),p.closePath(),s=t-l,r=i-n,p.isPointInPath){if(p.isPointInPath(t-l,i-n))return p.restore(),{datapoint:[d.percent,d.data],dataIndex:0,series:d,seriesIndex:g}}else if(u([[0,0],[c*Math.cos(d.startAngle),c*Math.sin(d.startAngle)],[c*Math.cos(d.startAngle+d.angle/4),c*Math.sin(d.startAngle+d.angle/4)],[c*Math.cos(d.startAngle+d.angle/2),c*Math.sin(d.startAngle+d.angle/2)],[c*Math.cos(d.startAngle+d.angle/1.5),c*Math.sin(d.startAngle+d.angle/1.5)],[c*Math.cos(d.startAngle+d.angle),c*Math.sin(d.startAngle+d.angle)]],[s,r]))return p.restore(),{datapoint:[d.percent,d.data],dataIndex:0,series:d,seriesIndex:g};p.restore()}}return null}(parseInt(r.pageX-c.left),parseInt(r.pageY-c.top));if(o.grid.autoHighlight)for(var d=0;d<h.length;++d){var f=h[d];f.auto!==i||g&&f.series===g.series||b(f.series)}g&&function(t,i){var s=v(t);-1===s?(h.push({series:t,auto:i}),e.triggerRedrawOverlay()):i||(h[s].auto=!1)}(g.series,i);var m={pageX:r.pageX,pageY:r.pageY};t.trigger(s,i,[m,g])}function b(t){null==t&&(h=[],e.triggerRedrawOverlay());var i=v(t);-1!==i&&(h.splice(i,1),e.triggerRedrawOverlay())}function v(e){for(var t=0;t<h.length;++t)if(h[t].series===e)return t;return-1}e.hooks.processOptions.push(function(e,t){t.series.pie.show&&(t.grid.show=!1,"auto"===t.series.pie.label.show&&(t.legend.show?t.series.pie.label.show=!1:t.series.pie.label.show=!0),"auto"===t.series.pie.radius&&(t.series.pie.label.show?t.series.pie.radius=3/4:t.series.pie.radius=1),t.series.pie.tilt>1?t.series.pie.tilt=1:t.series.pie.tilt<0&&(t.series.pie.tilt=0))}),e.hooks.bindEvents.push(function(e,i){var s=e.getOptions();s.series.pie.show&&(s.grid.hoverable&&(t.unbind(i,"mousemove"),t.bind(i,"mousemove",g),t.bind(i,"mouseleave",g)),s.grid.clickable&&(t.unbind(i,"click"),t.bind(i,"click",d)))}),e.hooks.shutdown.push(function(e,i){t.unbind(i,"mousemove",g),t.unbind(i,"mouseleave",g),t.unbind(i,"click",d),h=[]}),e.hooks.processDatapoints.push(function(e,a,l,n){e.getOptions().series.pie.show&&function(e){o||(o=!0,i=e.getCanvas(),s=i.parentElement,r=e.getOptions(),e.setData(function(e){var i,s,a=0,l=0,n=0,o=r.series.pie.combine.color,p=[];for(i=0;i<e.length;++i)s=e[i].data,Array.isArray(s)&&1===s.length&&(s=s[0]),Array.isArray(s)?!isNaN(parseFloat(s[1]))&&isFinite(s[1])?s[1]=+s[1]:s[1]=0:s=!isNaN(parseFloat(s))&&isFinite(s)?[1,+s]:[1,0],e[i].data=[s];for(i=0;i<e.length;++i)a+=e[i].data[0][1];for(i=0;i<e.length;++i)(s=e[i].data[0][1])/a<=r.series.pie.combine.threshold&&(l+=s,n++,o||(o=e[i].color));for(i=0;i<e.length;++i)s=e[i].data[0][1],(n<2||s/a>r.series.pie.combine.threshold)&&p.push(t.extend(e[i],{data:[[1,s]],color:e[i].color,label:e[i].label,angle:s*Math.PI*2/a,percent:s/(a/100)}));return n>1&&p.push({data:[[1,l]],color:o,label:r.series.pie.combine.label,angle:l*Math.PI*2/a,percent:l/(a/100)}),p}(e.getData())))}(e)}),e.hooks.drawOverlay.push(function(e,t){e.getOptions().series.pie.show&&function(e,t){var i=e.getOptions(),s=i.series.pie.radius>1?i.series.pie.radius:a*i.series.pie.radius;t.save(),t.translate(l,n),t.scale(1,i.series.pie.tilt);for(var r=0;r<h.length;++r)o(h[r].series);function o(e){e.angle<=0||isNaN(e.angle)||(t.fillStyle="rgba(255, 255, 255, "+i.series.pie.highlight.opacity+")",t.beginPath(),Math.abs(e.angle-2*Math.PI)>1e-9&&t.moveTo(0,0),t.arc(0,0,s,e.startAngle,e.startAngle+e.angle/2,!1),t.arc(0,0,s,e.startAngle+e.angle/2,e.startAngle+e.angle,!1),t.closePath(),t.fill())}c(t),t.restore()}(e,t)}),e.hooks.draw.push(function(e,i){e.getOptions().series.pie.show&&function(e,i){if(s){var h=t.width(e.getPlaceholder()),u=t.height(e.getPlaceholder()),g=s.querySelector(".legend"),d=g&&g.firstElementChild?g.firstElementChild.clientWidth:0;p=i,o=!1,a=Math.min(h,u/r.series.pie.tilt)/2,n=u/2+r.series.pie.offset.top,l=h/2,"auto"===r.series.pie.offset.left?(r.legend.position.match("w")?l+=d/2:l-=d/2,l<a?l=a:l>h-a&&(l=h-a)):l+=r.series.pie.offset.left;var f=e.getData(),b=0;do{b>0&&(a*=.95),b+=1,m(),r.series.pie.tilt<=.8&&w()}while(!y()&&b<10);if(b>=10){m();var v=document.createElement("div");v.className="error",v.textContent="Could not draw pie with labels contained inside canvas",s.insertBefore(v,s.firstChild)}e.setSeries&&e.insertLegend&&(e.setSeries(f),e.insertLegend())}function m(){p.clearRect(0,0,h,u);for(var e=s.querySelectorAll(".pieLabel, .pieLabelBackground"),t=0;t<e.length;t++)e[t].remove()}function w(){var e=r.series.pie.shadow.left,t=r.series.pie.shadow.top,i=r.series.pie.shadow.alpha,s=r.series.pie.radius>1?r.series.pie.radius:a*r.series.pie.radius;if(!(s>=h/2-e||s*r.series.pie.tilt>=u/2-t||s<=10)){p.save(),p.translate(e,t),p.globalAlpha=i,p.fillStyle="#000",p.translate(l,n),p.scale(1,r.series.pie.tilt);for(var o=1;o<=10;o++)p.beginPath(),p.arc(0,0,s,0,2*Math.PI,!1),p.fill(),s-=o;p.restore()}}function y(){var e,t=Math.PI*r.series.pie.startAngle,i=r.series.pie.radius>1?r.series.pie.radius:a*r.series.pie.radius;p.save(),p.translate(l,n),p.scale(1,r.series.pie.tilt),p.save();var o=t;for(e=0;e<f.length;++e)f[e].startAngle=o,g(f[e].angle,f[e].color,!0);if(p.restore(),r.series.pie.stroke.width>0){for(p.save(),p.lineWidth=r.series.pie.stroke.width,o=t,e=0;e<f.length;++e)g(f[e].angle,r.series.pie.stroke.color,!1);p.restore()}return c(p),p.restore(),!r.series.pie.label.show||function(){for(var e=t,i=r.series.pie.label.radius>1?r.series.pie.label.radius:a*r.series.pie.label.radius,o=0;o<f.length;++o){if(f[o].percent>=100*r.series.pie.label.threshold&&!p(f[o],e,o))return!1;e+=f[o].angle}return!0;function p(e,t,a){if(0===e.data[0][1])return!0;var o,p=r.legend.labelFormatter,c=r.series.pie.label.formatter;o=p?p(e.label,e):e.label,c&&(o=c(o,e));var g=(t+e.angle+t)/2,d=l+Math.round(Math.cos(g)*i),f=n+Math.round(Math.sin(g)*i)*r.series.pie.tilt,b=document.createElement("span");b.className="pieLabel",b.id="pieLabel"+a,b.style.position="absolute",b.style.top=f+"px",b.style.left=d+"px",b.innerHTML=o,s.appendChild(b);var v=s.querySelector("#pieLabel"+a),m=f-v.clientHeight/2,w=d-v.clientWidth/2;if(v.style.top=m+"px",v.style.left=w+"px",0-m>0||0-w>0||u-(m+v.clientHeight)<0||h-(w+v.clientWidth)<0)return!1;if(0!==r.series.pie.label.background.opacity){var y=r.series.pie.label.background.color;null==y&&(y=e.color);var k=document.createElement("div");k.className="pieLabelBackground",k.style.cssText="position:absolute;width:"+v.clientWidth+"px;height:"+v.clientHeight+"px;top:"+m+"px;left:"+w+"px;background-color:"+y+";",k.style.opacity=r.series.pie.label.background.opacity,v.parentNode.insertBefore(k,v)}return!0}}();function g(e,t,s){e<=0||isNaN(e)||(s?p.fillStyle=t:(p.strokeStyle=t,p.lineJoin="round"),p.beginPath(),Math.abs(e-2*Math.PI)>1e-9&&p.moveTo(0,0),p.arc(0,0,i,o,o+e/2,!1),p.arc(0,0,i,o+e/2,o+e,!1),p.closePath(),o+=e,s?p.fill():p.stroke())}}}(e,i)})},options:i,name:"pie",version:"1.1"})}(jquery_flot_js,helpers_js);
|
|
1
|
+
!function(e,t){"use strict";var i={series:{pie:{show:!1,radius:"auto",innerRadius:0,startAngle:1.5,tilt:1,shadow:{left:5,top:15,alpha:.02},offset:{top:0,left:"auto"},stroke:{color:"#fff",width:1},label:{show:"auto",formatter:function(e,t){return"<div style='font-size:x-small;text-align:center;padding:2px;color:"+t.color+";'>"+e+"<br/>"+Math.round(t.percent)+"%</div>"},radius:1,background:{color:null,opacity:0},threshold:0},combine:{threshold:-1,color:null,label:"Other"},highlight:{opacity:.5}}}};e.plugins.push({init:function(e){var i=null,s=null,r=null,a=null,l=null,n=null,o=!1,p=null,h=[];function c(t){var i=e.getOptions();if(i.series.pie.innerRadius>0){t.save();var s=i.series.pie.innerRadius>1?i.series.pie.innerRadius:a*i.series.pie.innerRadius;t.globalCompositeOperation="destination-out",t.beginPath(),t.fillStyle=i.series.pie.stroke.color,t.arc(0,0,s,0,2*Math.PI,!1),t.fill(),t.closePath(),t.restore(),t.save(),t.beginPath(),t.strokeStyle=i.series.pie.stroke.color,t.arc(0,0,s,0,2*Math.PI,!1),t.stroke(),t.closePath(),t.restore()}}function u(e,t){for(var i=!1,s=-1,r=e.length,a=r-1;++s<r;a=s)(e[s][1]<=t[1]&&t[1]<e[a][1]||e[a][1]<=t[1]&&t[1]<e[s][1])&&t[0]<(e[a][0]-e[s][0])*(t[1]-e[s][1])/(e[a][1]-e[s][1])+e[s][0]&&(i=!i);return i}function g(e){f("plothover",e)}function d(e){f("plotclick",e)}function f(i,r){var o=e.getOptions(),c=e.offset(),g=function(t,i){for(var s,r,o=e.getData(),h=e.getOptions(),c=h.series.pie.radius>1?h.series.pie.radius:a*h.series.pie.radius,g=0;g<o.length;++g){var d=o[g];if(d.pie.show){if(p.save(),p.beginPath(),p.moveTo(0,0),p.arc(0,0,c,d.startAngle,d.startAngle+d.angle/2,!1),p.arc(0,0,c,d.startAngle+d.angle/2,d.startAngle+d.angle,!1),p.closePath(),s=t-l,r=i-n,p.isPointInPath){if(p.isPointInPath(t-l,i-n))return p.restore(),{datapoint:[d.percent,d.data],dataIndex:0,series:d,seriesIndex:g}}else if(u([[0,0],[c*Math.cos(d.startAngle),c*Math.sin(d.startAngle)],[c*Math.cos(d.startAngle+d.angle/4),c*Math.sin(d.startAngle+d.angle/4)],[c*Math.cos(d.startAngle+d.angle/2),c*Math.sin(d.startAngle+d.angle/2)],[c*Math.cos(d.startAngle+d.angle/1.5),c*Math.sin(d.startAngle+d.angle/1.5)],[c*Math.cos(d.startAngle+d.angle),c*Math.sin(d.startAngle+d.angle)]],[s,r]))return p.restore(),{datapoint:[d.percent,d.data],dataIndex:0,series:d,seriesIndex:g};p.restore()}}return null}(parseInt(String(r.pageX-c.left)),parseInt(String(r.pageY-c.top)));if(o.grid.autoHighlight)for(var d=0;d<h.length;++d){var f=h[d];f.auto!==i||g&&f.series===g.series||b(f.series)}g&&function(t,i){var s=v(t);-1===s?(h.push({series:t,auto:i}),e.triggerRedrawOverlay()):i||(h[s].auto=!1)}(g.series,i);var m={pageX:r.pageX,pageY:r.pageY};t.trigger(s,i,[m,g])}function b(t){null==t&&(h=[],e.triggerRedrawOverlay());var i=v(t);-1!==i&&(h.splice(i,1),e.triggerRedrawOverlay())}function v(e){for(var t=0;t<h.length;++t)if(h[t].series===e)return t;return-1}e.hooks.processOptions.push(function(e,t){t.series.pie.show&&(t.grid.show=!1,"auto"===t.series.pie.label.show&&(t.legend.show?t.series.pie.label.show=!1:t.series.pie.label.show=!0),"auto"===t.series.pie.radius&&(t.series.pie.label.show?t.series.pie.radius=3/4:t.series.pie.radius=1),t.series.pie.tilt>1?t.series.pie.tilt=1:t.series.pie.tilt<0&&(t.series.pie.tilt=0))}),e.hooks.bindEvents.push(function(e,i){var s=e.getOptions();s.series.pie.show&&(s.grid.hoverable&&(t.unbind(i,"mousemove"),t.bind(i,"mousemove",g),t.bind(i,"mouseleave",g)),s.grid.clickable&&(t.unbind(i,"click"),t.bind(i,"click",d)))}),e.hooks.shutdown.push(function(e,i){t.unbind(i,"mousemove",g),t.unbind(i,"mouseleave",g),t.unbind(i,"click",d),h=[]}),e.hooks.processDatapoints.push(function(e,a,l,n){e.getOptions().series.pie.show&&function(e){o||(o=!0,i=e.getCanvas(),s=i.parentElement,r=e.getOptions(),e.setData(function(e){var i,s,a=0,l=0,n=0,o=r.series.pie.combine.color,p=[];for(i=0;i<e.length;++i)s=e[i].data,Array.isArray(s)&&1===s.length&&(s=s[0]),Array.isArray(s)?!isNaN(parseFloat(s[1]))&&isFinite(s[1])?s[1]=+s[1]:s[1]=0:s=!isNaN(parseFloat(s))&&isFinite(s)?[1,+s]:[1,0],e[i].data=[s];for(i=0;i<e.length;++i)a+=e[i].data[0][1];for(i=0;i<e.length;++i)(s=e[i].data[0][1])/a<=r.series.pie.combine.threshold&&(l+=s,n++,o||(o=e[i].color));for(i=0;i<e.length;++i)s=e[i].data[0][1],(n<2||s/a>r.series.pie.combine.threshold)&&p.push(t.extend(e[i],{data:[[1,s]],color:e[i].color,label:e[i].label,angle:s*Math.PI*2/a,percent:s/(a/100)}));return n>1&&p.push({data:[[1,l]],color:o,label:r.series.pie.combine.label,angle:l*Math.PI*2/a,percent:l/(a/100)}),p}(e.getData())))}(e)}),e.hooks.drawOverlay.push(function(e,t){e.getOptions().series.pie.show&&function(e,t){var i=e.getOptions(),s=i.series.pie.radius>1?i.series.pie.radius:a*i.series.pie.radius;t.save(),t.translate(l,n),t.scale(1,i.series.pie.tilt);for(var r=0;r<h.length;++r)o(h[r].series);function o(e){e.angle<=0||isNaN(e.angle)||(t.fillStyle="rgba(255, 255, 255, "+i.series.pie.highlight.opacity+")",t.beginPath(),Math.abs(e.angle-2*Math.PI)>1e-9&&t.moveTo(0,0),t.arc(0,0,s,e.startAngle,e.startAngle+e.angle/2,!1),t.arc(0,0,s,e.startAngle+e.angle/2,e.startAngle+e.angle,!1),t.closePath(),t.fill())}c(t),t.restore()}(e,t)}),e.hooks.draw.push(function(e,i){e.getOptions().series.pie.show&&function(e,i){if(s){var h=t.width(e.getPlaceholder()),u=t.height(e.getPlaceholder()),g=s.querySelector(".legend"),d=g&&g.firstElementChild?g.firstElementChild.clientWidth:0;p=i,o=!1,a=Math.min(h,u/r.series.pie.tilt)/2,n=u/2+r.series.pie.offset.top,l=h/2,"auto"===r.series.pie.offset.left?(r.legend.position.match("w")?l+=d/2:l-=d/2,l<a?l=a:l>h-a&&(l=h-a)):l+=r.series.pie.offset.left;var f=e.getData(),b=0;do{b>0&&(a*=.95),b+=1,m(),r.series.pie.tilt<=.8&&w()}while(!y()&&b<10);if(b>=10){m();var v=document.createElement("div");v.className="error",v.textContent="Could not draw pie with labels contained inside canvas",s.insertBefore(v,s.firstChild)}e.setSeries&&e.insertLegend&&(e.setSeries(f),e.insertLegend())}function m(){p.clearRect(0,0,h,u);for(var e=s.querySelectorAll(".pieLabel, .pieLabelBackground"),t=0;t<e.length;t++)e[t].remove()}function w(){var e=r.series.pie.shadow.left,t=r.series.pie.shadow.top,i=r.series.pie.shadow.alpha,s=r.series.pie.radius>1?r.series.pie.radius:a*r.series.pie.radius;if(!(s>=h/2-e||s*r.series.pie.tilt>=u/2-t||s<=10)){p.save(),p.translate(e,t),p.globalAlpha=i,p.fillStyle="#000",p.translate(l,n),p.scale(1,r.series.pie.tilt);for(var o=1;o<=10;o++)p.beginPath(),p.arc(0,0,s,0,2*Math.PI,!1),p.fill(),s-=o;p.restore()}}function y(){var e,t=Math.PI*r.series.pie.startAngle,i=r.series.pie.radius>1?r.series.pie.radius:a*r.series.pie.radius;p.save(),p.translate(l,n),p.scale(1,r.series.pie.tilt),p.save();var o=t;for(e=0;e<f.length;++e)f[e].startAngle=o,g(f[e].angle,f[e].color,!0);if(p.restore(),r.series.pie.stroke.width>0){for(p.save(),p.lineWidth=r.series.pie.stroke.width,o=t,e=0;e<f.length;++e)g(f[e].angle,r.series.pie.stroke.color,!1);p.restore()}return c(p),p.restore(),!r.series.pie.label.show||function(){for(var e=t,i=r.series.pie.label.radius>1?r.series.pie.label.radius:a*r.series.pie.label.radius,o=0;o<f.length;++o){if(f[o].percent>=100*r.series.pie.label.threshold&&!p(f[o],e,o))return!1;e+=f[o].angle}return!0;function p(e,t,a){if(0===e.data[0][1])return!0;var o,p=r.legend.labelFormatter,c=r.series.pie.label.formatter;o=p?p(e.label,e):e.label,c&&(o=c(o,e));var g=(t+e.angle+t)/2,d=l+Math.round(Math.cos(g)*i),f=n+Math.round(Math.sin(g)*i)*r.series.pie.tilt,b=document.createElement("span");b.className="pieLabel",b.id="pieLabel"+a,b.style.position="absolute",b.style.top=f+"px",b.style.left=d+"px",b.innerHTML=o,s.appendChild(b);var v=s.querySelector("#pieLabel"+a),m=f-v.clientHeight/2,w=d-v.clientWidth/2;if(v.style.top=m+"px",v.style.left=w+"px",0-m>0||0-w>0||u-(m+v.clientHeight)<0||h-(w+v.clientWidth)<0)return!1;if(0!==r.series.pie.label.background.opacity){var y=r.series.pie.label.background.color;null==y&&(y=e.color);var k=document.createElement("div");k.className="pieLabelBackground",k.style.cssText="position:absolute;width:"+v.clientWidth+"px;height:"+v.clientHeight+"px;top:"+m+"px;left:"+w+"px;background-color:"+y+";",k.style.opacity=r.series.pie.label.background.opacity,v.parentNode.insertBefore(k,v)}return!0}}();function g(e,t,s){e<=0||isNaN(e)||(s?p.fillStyle=t:(p.strokeStyle=t,p.lineJoin="round"),p.beginPath(),Math.abs(e-2*Math.PI)>1e-9&&p.moveTo(0,0),p.arc(0,0,i,o,o+e/2,!1),p.arc(0,0,i,o+e/2,o+e,!1),p.closePath(),o+=e,s?p.fill():p.stroke())}}}(e,i)})},options:i,name:"pie",version:"1.1"})}(jquery_flot_js,helpers_js);
|
|
2
2
|
//# sourceMappingURL=jquery.flot.pie.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jquery.flot.pie.min.js","sources":["../../source/jquery.flot.pie.js"],"sourcesContent":["/* Flot plugin for rendering pie charts.\n\nCopyright (c) 2007-2014 IOLA and Ole Laursen.\nLicensed under the MIT license.\n\nThe plugin assumes that each series has a single data value, and that each\nvalue is a positive integer or zero. Negative numbers don't make sense for a\npie chart, and have unpredictable results. The values do NOT need to be\npassed in as percentages; the plugin will calculate the total and per-slice\npercentages internally.\n\n* Created by Brian Medendorp\n\n* Updated with contributions from btburnett3, Anthony Aragues and Xavi Ivars\n\nThe plugin supports these options:\n\n series: {\n pie: {\n show: true/false\n radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'\n innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect\n startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result\n tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)\n offset: {\n top: integer value to move the pie up or down\n left: integer value to move the pie left or right, or 'auto'\n },\n stroke: {\n color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')\n width: integer pixel width of the stroke\n },\n label: {\n show: true/false, or 'auto'\n formatter: a user-defined function that modifies the text/style of the label text\n radius: 0-1 for percentage of fullsize, or a specified pixel length\n background: {\n color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')\n opacity: 0-1\n },\n threshold: 0-1 for the percentage value at which to hide labels (if they're too small)\n },\n combine: {\n threshold: 0-1 for the percentage value at which to combine slices (if they're too small)\n color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined\n label: any text value of what the combined slice should be labeled\n }\n highlight: {\n opacity: 0-1\n }\n }\n }\n\nMore detail and specific examples can be found in the included HTML file.\n\n*/\n\nimport { plugins } from './jquery.flot.js';\nimport { extend, bind, unbind, trigger, width, height } from './helpers.js';\n\n // Maximum redraw attempts when fitting labels within the plot\n\n var REDRAW_ATTEMPTS = 10;\n\n // Factor by which to shrink the pie when fitting labels within the plot\n\n var REDRAW_SHRINK = 0.95;\n\n function init(plot) {\n var canvas = null,\n target = null,\n options = null,\n maxRadius = null,\n centerLeft = null,\n centerTop = null,\n processed = false,\n ctx = null;\n\n // interactive variables\n\n var highlights = [];\n\n // add hook to determine if pie plugin in enabled, and then perform necessary operations\n\n plot.hooks.processOptions.push(function(plot, options) {\n if (options.series.pie.show) {\n options.grid.show = false;\n\n // set labels.show\n\n if (options.series.pie.label.show === \"auto\") {\n if (options.legend.show) {\n options.series.pie.label.show = false;\n } else {\n options.series.pie.label.show = true;\n }\n }\n\n // set radius\n\n if (options.series.pie.radius === \"auto\") {\n if (options.series.pie.label.show) {\n options.series.pie.radius = 3 / 4;\n } else {\n options.series.pie.radius = 1;\n }\n }\n\n // ensure sane tilt\n\n if (options.series.pie.tilt > 1) {\n options.series.pie.tilt = 1;\n } else if (options.series.pie.tilt < 0) {\n options.series.pie.tilt = 0;\n }\n }\n });\n\n plot.hooks.bindEvents.push(function(plot, eventHolder) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n if (options.grid.hoverable) {\n unbind(eventHolder, \"mousemove\");\n bind(eventHolder, \"mousemove\", onMouseMove);\n bind(eventHolder, \"mouseleave\", onMouseMove);\n }\n if (options.grid.clickable) {\n unbind(eventHolder, \"click\");\n bind(eventHolder, \"click\", onClick);\n }\n }\n });\n\n plot.hooks.shutdown.push(function (plot, eventHolder) {\n unbind(eventHolder, \"mousemove\", onMouseMove);\n unbind(eventHolder, \"mouseleave\", onMouseMove);\n unbind(eventHolder, \"click\", onClick);\n highlights = [];\n });\n\n plot.hooks.processDatapoints.push(function(plot, series, data, datapoints) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n processDatapoints(plot, series, datapoints);\n }\n });\n\n plot.hooks.drawOverlay.push(function(plot, octx) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n drawOverlay(plot, octx);\n }\n });\n\n plot.hooks.draw.push(function(plot, newCtx) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n draw(plot, newCtx);\n }\n });\n\n function processDatapoints(plot, series, datapoints) {\n if (!processed) {\n processed = true;\n canvas = plot.getCanvas();\n target = canvas.parentElement;\n options = plot.getOptions();\n plot.setData(combine(plot.getData()));\n }\n }\n\n function combine(data) {\n var total = 0,\n combined = 0,\n numCombined = 0,\n color = options.series.pie.combine.color,\n newdata = [],\n i,\n value;\n\n // Fix up the raw data from Flot, ensuring the data is numeric\n\n for (i = 0; i < data.length; ++i) {\n value = data[i].data;\n\n // If the data is an array, we'll assume that it's a standard\n // Flot x-y pair, and are concerned only with the second value.\n\n // Note how we use the original array, rather than creating a\n // new one; this is more efficient and preserves any extra data\n // that the user may have stored in higher indexes.\n\n if (Array.isArray(value) && value.length === 1) {\n value = value[0];\n }\n\n if (Array.isArray(value)) {\n // Equivalent to $.isNumeric() but compatible with jQuery < 1.7\n if (!isNaN(parseFloat(value[1])) && isFinite(value[1])) {\n value[1] = +value[1];\n } else {\n value[1] = 0;\n }\n } else if (!isNaN(parseFloat(value)) && isFinite(value)) {\n value = [1, +value];\n } else {\n value = [1, 0];\n }\n\n data[i].data = [value];\n }\n\n // Sum up all the slices, so we can calculate percentages for each\n\n for (i = 0; i < data.length; ++i) {\n total += data[i].data[0][1];\n }\n\n // Count the number of slices with percentages below the combine\n // threshold; if it turns out to be just one, we won't combine.\n\n for (i = 0; i < data.length; ++i) {\n value = data[i].data[0][1];\n if (value / total <= options.series.pie.combine.threshold) {\n combined += value;\n numCombined++;\n if (!color) {\n color = data[i].color;\n }\n }\n }\n\n for (i = 0; i < data.length; ++i) {\n value = data[i].data[0][1];\n if (numCombined < 2 || value / total > options.series.pie.combine.threshold) {\n newdata.push(\n extend(data[i], { /* extend to allow keeping all other original data values\n and using them e.g. in labelFormatter. */\n data: [[1, value]],\n color: data[i].color,\n label: data[i].label,\n angle: value * Math.PI * 2 / total,\n percent: value / (total / 100)\n })\n );\n }\n }\n\n if (numCombined > 1) {\n newdata.push({\n data: [[1, combined]],\n color: color,\n label: options.series.pie.combine.label,\n angle: combined * Math.PI * 2 / total,\n percent: combined / (total / 100)\n });\n }\n\n return newdata;\n }\n\n function draw(plot, newCtx) {\n if (!target) {\n return; // if no series were passed\n }\n\n var canvasWidth = width(plot.getPlaceholder()),\n canvasHeight = height(plot.getPlaceholder()),\n legendEl = target.querySelector(\".legend\"),\n legendWidth = legendEl && legendEl.firstElementChild ? legendEl.firstElementChild.clientWidth : 0;\n\n ctx = newCtx;\n\n // WARNING: HACK! REWRITE THIS CODE AS SOON AS POSSIBLE!\n\n // When combining smaller slices into an 'other' slice, we need to\n // add a new series. Since Flot gives plugins no way to modify the\n // list of series, the pie plugin uses a hack where the first call\n // to processDatapoints results in a call to setData with the new\n // list of series, then subsequent processDatapoints do nothing.\n\n // The plugin-global 'processed' flag is used to control this hack;\n // it starts out false, and is set to true after the first call to\n // processDatapoints.\n\n // Unfortunately this turns future setData calls into no-ops; they\n // call processDatapoints, the flag is true, and nothing happens.\n\n // To fix this we'll set the flag back to false here in draw, when\n // all series have been processed, so the next sequence of calls to\n // processDatapoints once again starts out with a slice-combine.\n // This is really a hack; in 0.9 we need to give plugins a proper\n // way to modify series before any processing begins.\n\n processed = false;\n\n // calculate maximum radius and center point\n maxRadius = Math.min(canvasWidth, canvasHeight / options.series.pie.tilt) / 2;\n centerTop = canvasHeight / 2 + options.series.pie.offset.top;\n centerLeft = canvasWidth / 2;\n\n if (options.series.pie.offset.left === \"auto\") {\n if (options.legend.position.match(\"w\")) {\n centerLeft += legendWidth / 2;\n } else {\n centerLeft -= legendWidth / 2;\n }\n if (centerLeft < maxRadius) {\n centerLeft = maxRadius;\n } else if (centerLeft > canvasWidth - maxRadius) {\n centerLeft = canvasWidth - maxRadius;\n }\n } else {\n centerLeft += options.series.pie.offset.left;\n }\n\n var slices = plot.getData(),\n attempts = 0;\n\n // Keep shrinking the pie's radius until drawPie returns true,\n // indicating that all the labels fit, or we try too many times.\n do {\n if (attempts > 0) {\n maxRadius *= REDRAW_SHRINK;\n }\n attempts += 1;\n clear();\n if (options.series.pie.tilt <= 0.8) {\n drawShadow();\n }\n } while (!drawPie() && attempts < REDRAW_ATTEMPTS)\n\n if (attempts >= REDRAW_ATTEMPTS) {\n clear();\n var errorDiv = document.createElement('div');\n errorDiv.className = 'error';\n errorDiv.textContent = 'Could not draw pie with labels contained inside canvas';\n target.insertBefore(errorDiv, target.firstChild);\n }\n\n if (plot.setSeries && plot.insertLegend) {\n plot.setSeries(slices);\n plot.insertLegend();\n }\n\n // we're actually done at this point, just defining internal functions at this point\n function clear() {\n ctx.clearRect(0, 0, canvasWidth, canvasHeight);\n var labels = target.querySelectorAll(\".pieLabel, .pieLabelBackground\");\n for (var li = 0; li < labels.length; li++) {\n labels[li].remove();\n }\n }\n\n function drawShadow() {\n var shadowLeft = options.series.pie.shadow.left;\n var shadowTop = options.series.pie.shadow.top;\n var edge = 10;\n var alpha = options.series.pie.shadow.alpha;\n var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;\n\n if (radius >= canvasWidth / 2 - shadowLeft || radius * options.series.pie.tilt >= canvasHeight / 2 - shadowTop || radius <= edge) {\n return; // shadow would be outside canvas, so don't draw it\n }\n\n ctx.save();\n ctx.translate(shadowLeft, shadowTop);\n ctx.globalAlpha = alpha;\n ctx.fillStyle = \"#000\";\n\n // center and rotate to starting position\n ctx.translate(centerLeft, centerTop);\n ctx.scale(1, options.series.pie.tilt);\n\n //radius -= edge;\n for (var i = 1; i <= edge; i++) {\n ctx.beginPath();\n ctx.arc(0, 0, radius, 0, Math.PI * 2, false);\n ctx.fill();\n radius -= i;\n }\n\n ctx.restore();\n }\n\n function drawPie() {\n var startAngle = Math.PI * options.series.pie.startAngle;\n var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;\n var i;\n // center and rotate to starting position\n\n ctx.save();\n ctx.translate(centerLeft, centerTop);\n ctx.scale(1, options.series.pie.tilt);\n //ctx.rotate(startAngle); // start at top; -- This doesn't work properly in Opera\n\n // draw slices\n ctx.save();\n\n var currentAngle = startAngle;\n for (i = 0; i < slices.length; ++i) {\n slices[i].startAngle = currentAngle;\n drawSlice(slices[i].angle, slices[i].color, true);\n }\n\n ctx.restore();\n\n // draw slice outlines\n if (options.series.pie.stroke.width > 0) {\n ctx.save();\n ctx.lineWidth = options.series.pie.stroke.width;\n currentAngle = startAngle;\n for (i = 0; i < slices.length; ++i) {\n drawSlice(slices[i].angle, options.series.pie.stroke.color, false);\n }\n\n ctx.restore();\n }\n\n // draw donut hole\n drawDonutHole(ctx);\n\n ctx.restore();\n\n // Draw the labels, returning true if they fit within the plot\n if (options.series.pie.label.show) {\n return drawLabels();\n } else return true;\n\n function drawSlice(angle, color, fill) {\n if (angle <= 0 || isNaN(angle)) {\n return;\n }\n\n if (fill) {\n ctx.fillStyle = color;\n } else {\n ctx.strokeStyle = color;\n ctx.lineJoin = \"round\";\n }\n\n ctx.beginPath();\n if (Math.abs(angle - Math.PI * 2) > 0.000000001) {\n ctx.moveTo(0, 0); // Center of the pie\n }\n\n //ctx.arc(0, 0, radius, 0, angle, false); // This doesn't work properly in Opera\n ctx.arc(0, 0, radius, currentAngle, currentAngle + angle / 2, false);\n ctx.arc(0, 0, radius, currentAngle + angle / 2, currentAngle + angle, false);\n ctx.closePath();\n //ctx.rotate(angle); // This doesn't work properly in Opera\n currentAngle += angle;\n\n if (fill) {\n ctx.fill();\n } else {\n ctx.stroke();\n }\n }\n\n function drawLabels() {\n var currentAngle = startAngle;\n var radius = options.series.pie.label.radius > 1 ? options.series.pie.label.radius : maxRadius * options.series.pie.label.radius;\n\n for (var i = 0; i < slices.length; ++i) {\n if (slices[i].percent >= options.series.pie.label.threshold * 100) {\n if (!drawLabel(slices[i], currentAngle, i)) {\n return false;\n }\n }\n currentAngle += slices[i].angle;\n }\n\n return true;\n\n function drawLabel(slice, startAngle, index) {\n if (slice.data[0][1] === 0) {\n return true;\n }\n\n // format label text\n var lf = options.legend.labelFormatter, text, plf = options.series.pie.label.formatter;\n\n if (lf) {\n text = lf(slice.label, slice);\n } else {\n text = slice.label;\n }\n\n if (plf) {\n text = plf(text, slice);\n }\n\n var halfAngle = ((startAngle + slice.angle) + startAngle) / 2;\n var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);\n var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;\n\n var labelSpan = document.createElement('span');\n labelSpan.className = 'pieLabel';\n labelSpan.id = 'pieLabel' + index;\n labelSpan.style.position = 'absolute';\n labelSpan.style.top = y + 'px';\n labelSpan.style.left = x + 'px';\n labelSpan.innerHTML = text;\n target.appendChild(labelSpan);\n\n var label = target.querySelector(\"#pieLabel\" + index);\n var labelTop = (y - label.clientHeight / 2);\n var labelLeft = (x - label.clientWidth / 2);\n\n label.style.top = labelTop + 'px';\n label.style.left = labelLeft + 'px';\n\n // check to make sure that the label is not outside the canvas\n if (0 - labelTop > 0 || 0 - labelLeft > 0 || canvasHeight - (labelTop + label.clientHeight) < 0 || canvasWidth - (labelLeft + label.clientWidth) < 0) {\n return false;\n }\n\n if (options.series.pie.label.background.opacity !== 0) {\n // put in the transparent background separately to avoid blended labels and label boxes\n var c = options.series.pie.label.background.color;\n if (c == null) {\n c = slice.color;\n }\n\n var bgDiv = document.createElement('div');\n bgDiv.className = 'pieLabelBackground';\n bgDiv.style.cssText = 'position:absolute;width:' + label.clientWidth + 'px;height:' + label.clientHeight + 'px;top:' + labelTop + 'px;left:' + labelLeft + 'px;background-color:' + c + ';';\n bgDiv.style.opacity = options.series.pie.label.background.opacity;\n label.parentNode.insertBefore(bgDiv, label);\n }\n\n return true;\n } // end individual label function\n } // end drawLabels function\n } // end drawPie function\n } // end draw function\n\n // Placed here because it needs to be accessed from multiple locations\n\n function drawDonutHole(layer) {\n // The closure-scoped `options` is set by the processDatapoints\n // hook on first draw, but drawDonutHole can be reached from\n // paths that fire before that hook, leaving `options` null.\n // Read it eagerly. Upstream flot/flot#1559.\n var options = plot.getOptions();\n if (options.series.pie.innerRadius > 0) {\n // subtract the center\n layer.save();\n var innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;\n layer.globalCompositeOperation = \"destination-out\"; // this does not work with excanvas, but it will fall back to using the stroke color\n layer.beginPath();\n layer.fillStyle = options.series.pie.stroke.color;\n layer.arc(0, 0, innerRadius, 0, Math.PI * 2, false);\n layer.fill();\n layer.closePath();\n layer.restore();\n\n // add inner stroke\n layer.save();\n layer.beginPath();\n layer.strokeStyle = options.series.pie.stroke.color;\n layer.arc(0, 0, innerRadius, 0, Math.PI * 2, false);\n layer.stroke();\n layer.closePath();\n layer.restore();\n\n // TODO: add extra shadow inside hole (with a mask) if the pie is tilted.\n }\n }\n\n //-- Additional Interactive related functions --\n\n function isPointInPoly(poly, pt) {\n for (var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) {\n ((poly[i][1] <= pt[1] && pt[1] < poly[j][1]) ||\n (poly[j][1] <= pt[1] && pt[1] < poly[i][1])) &&\n (pt[0] < (poly[j][0] - poly[i][0]) * (pt[1] - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]) &&\n (c = !c);\n }\n return c;\n }\n\n function findNearbySlice(mouseX, mouseY) {\n var slices = plot.getData(),\n options = plot.getOptions(),\n radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius,\n x, y;\n\n for (var i = 0; i < slices.length; ++i) {\n var s = slices[i];\n if (s.pie.show) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0); // Center of the pie\n //ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here.\n ctx.arc(0, 0, radius, s.startAngle, s.startAngle + s.angle / 2, false);\n ctx.arc(0, 0, radius, s.startAngle + s.angle / 2, s.startAngle + s.angle, false);\n ctx.closePath();\n x = mouseX - centerLeft;\n y = mouseY - centerTop;\n\n if (ctx.isPointInPath) {\n if (ctx.isPointInPath(mouseX - centerLeft, mouseY - centerTop)) {\n ctx.restore();\n return {\n datapoint: [s.percent, s.data],\n dataIndex: 0,\n series: s,\n seriesIndex: i\n };\n }\n } else {\n // excanvas for IE doesn;t support isPointInPath, this is a workaround.\n var p1X = radius * Math.cos(s.startAngle),\n p1Y = radius * Math.sin(s.startAngle),\n p2X = radius * Math.cos(s.startAngle + s.angle / 4),\n p2Y = radius * Math.sin(s.startAngle + s.angle / 4),\n p3X = radius * Math.cos(s.startAngle + s.angle / 2),\n p3Y = radius * Math.sin(s.startAngle + s.angle / 2),\n p4X = radius * Math.cos(s.startAngle + s.angle / 1.5),\n p4Y = radius * Math.sin(s.startAngle + s.angle / 1.5),\n p5X = radius * Math.cos(s.startAngle + s.angle),\n p5Y = radius * Math.sin(s.startAngle + s.angle),\n arrPoly = [[0, 0], [p1X, p1Y], [p2X, p2Y], [p3X, p3Y], [p4X, p4Y], [p5X, p5Y]],\n arrPoint = [x, y];\n\n // TODO: perhaps do some mathmatical trickery here with the Y-coordinate to compensate for pie tilt?\n\n if (isPointInPoly(arrPoly, arrPoint)) {\n ctx.restore();\n return {\n datapoint: [s.percent, s.data],\n dataIndex: 0,\n series: s,\n seriesIndex: i\n };\n }\n }\n\n ctx.restore();\n }\n }\n\n return null;\n }\n\n function onMouseMove(e) {\n triggerClickHoverEvent(\"plothover\", e);\n }\n\n function onClick(e) {\n triggerClickHoverEvent(\"plotclick\", e);\n }\n\n // trigger click or hover event (they send the same parameters so we share their code)\n\n function triggerClickHoverEvent(eventname, e) {\n // See drawDonutHole above: read `options` fresh in case the\n // event fires before processDatapoints has run.\n var options = plot.getOptions();\n var offset = plot.offset();\n var canvasX = parseInt(e.pageX - offset.left);\n var canvasY = parseInt(e.pageY - offset.top);\n var item = findNearbySlice(canvasX, canvasY);\n\n if (options.grid.autoHighlight) {\n // clear auto-highlights\n for (var i = 0; i < highlights.length; ++i) {\n var h = highlights[i];\n if (h.auto === eventname && !(item && h.series === item.series)) {\n unhighlight(h.series);\n }\n }\n }\n\n // highlight the slice\n\n if (item) {\n highlight(item.series, eventname);\n }\n\n // trigger any hover bind events\n\n var pos = { pageX: e.pageX, pageY: e.pageY };\n trigger(target, eventname, [pos, item]);\n }\n\n function highlight(s, auto) {\n //if (typeof s == \"number\") {\n // s = series[s];\n //}\n\n var i = indexOfHighlight(s);\n\n if (i === -1) {\n highlights.push({ series: s, auto: auto });\n plot.triggerRedrawOverlay();\n } else if (!auto) {\n highlights[i].auto = false;\n }\n }\n\n function unhighlight(s) {\n if (s == null) {\n highlights = [];\n plot.triggerRedrawOverlay();\n }\n\n //if (typeof s == \"number\") {\n // s = series[s];\n //}\n\n var i = indexOfHighlight(s);\n\n if (i !== -1) {\n highlights.splice(i, 1);\n plot.triggerRedrawOverlay();\n }\n }\n\n function indexOfHighlight(s) {\n for (var i = 0; i < highlights.length; ++i) {\n var h = highlights[i];\n if (h.series === s) {\n return i;\n }\n }\n return -1;\n }\n\n function drawOverlay(plot, octx) {\n var options = plot.getOptions();\n var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;\n\n octx.save();\n octx.translate(centerLeft, centerTop);\n octx.scale(1, options.series.pie.tilt);\n\n for (var i = 0; i < highlights.length; ++i) {\n drawHighlight(highlights[i].series);\n }\n\n drawDonutHole(octx);\n\n octx.restore();\n\n function drawHighlight(series) {\n if (series.angle <= 0 || isNaN(series.angle)) {\n return;\n }\n\n //octx.fillStyle = parseColor(options.series.pie.highlight.color).scale(null, null, null, options.series.pie.highlight.opacity).toString();\n octx.fillStyle = \"rgba(255, 255, 255, \" + options.series.pie.highlight.opacity + \")\"; // this is temporary until we have access to parseColor\n octx.beginPath();\n if (Math.abs(series.angle - Math.PI * 2) > 0.000000001) {\n octx.moveTo(0, 0); // Center of the pie\n }\n octx.arc(0, 0, radius, series.startAngle, series.startAngle + series.angle / 2, false);\n octx.arc(0, 0, radius, series.startAngle + series.angle / 2, series.startAngle + series.angle, false);\n octx.closePath();\n octx.fill();\n }\n }\n } // end init (plugin body)\n\n // define pie specific options and their default values\n var options = {\n series: {\n pie: {\n show: false,\n radius: \"auto\", // actual radius of the visible pie (based on full calculated radius if <=1, or hard pixel value)\n innerRadius: 0, /* for donut */\n startAngle: 3 / 2,\n tilt: 1,\n shadow: {\n left: 5, // shadow left offset\n top: 15, // shadow top offset\n alpha: 0.02 // shadow alpha\n },\n offset: {\n top: 0,\n left: \"auto\"\n },\n stroke: {\n color: \"#fff\",\n width: 1\n },\n label: {\n show: \"auto\",\n formatter: function(label, slice) {\n return \"<div style='font-size:x-small;text-align:center;padding:2px;color:\" + slice.color + \";'>\" + label + \"<br/>\" + Math.round(slice.percent) + \"%</div>\";\n }, // formatter function\n radius: 1, // radius at which to place the labels (based on full calculated radius if <=1, or hard pixel value)\n background: {\n color: null,\n opacity: 0\n },\n threshold: 0 // percentage at which to hide the label (i.e. the slice is too narrow)\n },\n combine: {\n threshold: -1, // percentage at which to combine little slices into one larger slice\n color: null, // color to give the new slice (auto-generated if null)\n label: \"Other\" // label to give the new slice\n },\n highlight: {\n //color: \"#fff\", // will add this functionality once parseColor is available\n opacity: 0.5\n }\n }\n }\n };\n\n plugins.push({\n init: init,\n options: options,\n name: \"pie\",\n version: \"1.1\"\n });\n"],"names":["options","series","pie","show","radius","innerRadius","startAngle","tilt","shadow","left","top","alpha","offset","stroke","color","width","label","formatter","slice","Math","round","percent","background","opacity","threshold","combine","highlight","plugins","push","init","plot","canvas","target","maxRadius","centerLeft","centerTop","processed","ctx","highlights","drawDonutHole","layer","getOptions","save","globalCompositeOperation","beginPath","fillStyle","arc","PI","fill","closePath","restore","strokeStyle","isPointInPoly","poly","pt","c","i","l","length","j","onMouseMove","e","triggerClickHoverEvent","onClick","eventname","item","mouseX","mouseY","x","y","slices","getData","s","moveTo","angle","isPointInPath","datapoint","data","dataIndex","seriesIndex","cos","sin","findNearbySlice","parseInt","pageX","pageY","grid","autoHighlight","h","auto","unhighlight","indexOfHighlight","triggerRedrawOverlay","pos","trigger","splice","hooks","processOptions","legend","bindEvents","eventHolder","hoverable","unbind","bind","clickable","shutdown","processDatapoints","datapoints","getCanvas","parentElement","setData","value","total","combined","numCombined","newdata","Array","isArray","isNaN","parseFloat","isFinite","extend","drawOverlay","octx","translate","scale","drawHighlight","abs","draw","newCtx","canvasWidth","getPlaceholder","canvasHeight","height","legendEl","querySelector","legendWidth","firstElementChild","clientWidth","min","position","match","attempts","clear","drawShadow","drawPie","errorDiv","document","createElement","className","textContent","insertBefore","firstChild","setSeries","insertLegend","clearRect","labels","querySelectorAll","li","remove","shadowLeft","shadowTop","globalAlpha","currentAngle","drawSlice","lineWidth","drawLabel","index","text","lf","labelFormatter","plf","halfAngle","labelSpan","id","style","innerHTML","appendChild","labelTop","clientHeight","labelLeft","bgDiv","cssText","parentNode","drawLabels","lineJoin","name","version"],"mappings":"4BA+vBI,IAAIA,EAAU,CACVC,OAAQ,CACJC,IAAK,CACDC,MAAM,EACNC,OAAQ,OACRC,YAAa,EACbC,WAAY,IACZC,KAAM,EACNC,OAAQ,CACJC,KAAM,EACNC,IAAK,GACLC,MAAO,KAEXC,OAAQ,CACJF,IAAK,EACLD,KAAM,QAEVI,OAAQ,CACJC,MAAO,OACPC,MAAO,GAEXC,MAAO,CACHb,KAAM,OACNc,UAAW,SAASD,EAAOE,GACvB,MAAO,qEAAuEA,EAAMJ,MAAQ,MAAQE,EAAQ,QAAUG,KAAKC,MAAMF,EAAMG,SAAW,SACtJ,EACAjB,OAAQ,EACRkB,WAAY,CACRR,MAAO,KACPS,QAAS,GAEbC,UAAW,GAEfC,QAAS,CACLD,WAAW,EACXV,MAAO,KACPE,MAAO,SAEXU,UAAW,CAEPH,QAAS,OAMzBI,EAAAA,QAAQC,KAAK,CACTC,KA1uBJ,SAAcC,GACV,IAAIC,EAAS,KACTC,EAAS,KACThC,EAAU,KACViC,EAAY,KACZC,EAAa,KACbC,EAAY,KACZC,GAAY,EACZC,EAAM,KAINC,EAAa,GA4cjB,SAASC,EAAcC,GAKnB,IAAIxC,EAAU8B,EAAKW,aACnB,GAAIzC,EAAQC,OAAOC,IAAIG,YAAc,EAAG,CAEpCmC,EAAME,OACN,IAAIrC,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AMN,MAAMxJ,QAAUvB,EAAQC,OAAOC,IAAIc,MAAMM,WAAWC,QAC1DP,EAAMuK,WAAWhC,aAAa8B,EAAOrK,EACzC,CAEA,OAAO,CACX,CACJ,CA5GWwK,GAGX,SAASpB,EAAU1F,EAAO5D,EAAOkC,GACzB0B,GAAS,GAAK4C,MAAM5C,KAIpB1B,EACAX,EAAIQ,UAAY/B,GAEhBuB,EAAIc,YAAcrC,EAClBuB,EAAIoJ,SAAW,SAGnBpJ,EAAIO,YACAzB,KAAK4G,IAAIrD,EAAkB,EAAVvD,KAAK4B,IAAU,MAChCV,EAAIoC,OAAO,EAAG,GAIlBpC,EAAIS,IAAI,EAAG,EAAG1C,EAAQ+J,EAAcA,EAAezF,EAAQ,GAAG,GAC9DrC,EAAIS,IAAI,EAAG,EAAG1C,EAAQ+J,EAAezF,EAAQ,EAAGyF,EAAezF,GAAO,GACtErC,EAAIY,YAEJkH,GAAgBzF,EAEZ1B,EACAX,EAAIW,OAEJX,EAAIxB,SAEZ,CA6EJ,CACJ,CA3XQmH,CAAKlG,EAAMmG,EAEnB,EA6lBJ,EAmDIjI,QAASA,EACT0L,KAAM,MACNC,QAAS"}
|
|
1
|
+
{"version":3,"file":"jquery.flot.pie.min.js","sources":["../../source/jquery.flot.pie.js"],"sourcesContent":["/* Flot plugin for rendering pie charts.\n\nCopyright (c) 2007-2014 IOLA and Ole Laursen.\nLicensed under the MIT license.\n\nThe plugin assumes that each series has a single data value, and that each\nvalue is a positive integer or zero. Negative numbers don't make sense for a\npie chart, and have unpredictable results. The values do NOT need to be\npassed in as percentages; the plugin will calculate the total and per-slice\npercentages internally.\n\n* Created by Brian Medendorp\n\n* Updated with contributions from btburnett3, Anthony Aragues and Xavi Ivars\n\nThe plugin supports these options:\n\n series: {\n pie: {\n show: true/false\n radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'\n innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect\n startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result\n tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)\n offset: {\n top: integer value to move the pie up or down\n left: integer value to move the pie left or right, or 'auto'\n },\n stroke: {\n color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')\n width: integer pixel width of the stroke\n },\n label: {\n show: true/false, or 'auto'\n formatter: a user-defined function that modifies the text/style of the label text\n radius: 0-1 for percentage of fullsize, or a specified pixel length\n background: {\n color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')\n opacity: 0-1\n },\n threshold: 0-1 for the percentage value at which to hide labels (if they're too small)\n },\n combine: {\n threshold: 0-1 for the percentage value at which to combine slices (if they're too small)\n color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined\n label: any text value of what the combined slice should be labeled\n }\n highlight: {\n opacity: 0-1\n }\n }\n }\n\nMore detail and specific examples can be found in the included HTML file.\n\n*/\n\nimport { plugins } from './jquery.flot.js';\nimport { extend, bind, unbind, trigger, width, height } from './helpers.js';\n\n // Maximum redraw attempts when fitting labels within the plot\n\n var REDRAW_ATTEMPTS = 10;\n\n // Factor by which to shrink the pie when fitting labels within the plot\n\n var REDRAW_SHRINK = 0.95;\n\n function init(plot) {\n var canvas = null,\n target = null,\n options = null,\n maxRadius = null,\n centerLeft = null,\n centerTop = null,\n processed = false,\n ctx = null;\n\n // interactive variables\n\n var highlights = [];\n\n // add hook to determine if pie plugin in enabled, and then perform necessary operations\n\n plot.hooks.processOptions.push(function(plot, options) {\n if (options.series.pie.show) {\n options.grid.show = false;\n\n // set labels.show\n\n if (options.series.pie.label.show === \"auto\") {\n if (options.legend.show) {\n options.series.pie.label.show = false;\n } else {\n options.series.pie.label.show = true;\n }\n }\n\n // set radius\n\n if (options.series.pie.radius === \"auto\") {\n if (options.series.pie.label.show) {\n options.series.pie.radius = 3 / 4;\n } else {\n options.series.pie.radius = 1;\n }\n }\n\n // ensure sane tilt\n\n if (options.series.pie.tilt > 1) {\n options.series.pie.tilt = 1;\n } else if (options.series.pie.tilt < 0) {\n options.series.pie.tilt = 0;\n }\n }\n });\n\n plot.hooks.bindEvents.push(function(plot, eventHolder) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n if (options.grid.hoverable) {\n unbind(eventHolder, \"mousemove\");\n bind(eventHolder, \"mousemove\", onMouseMove);\n bind(eventHolder, \"mouseleave\", onMouseMove);\n }\n if (options.grid.clickable) {\n unbind(eventHolder, \"click\");\n bind(eventHolder, \"click\", onClick);\n }\n }\n });\n\n plot.hooks.shutdown.push(function (plot, eventHolder) {\n unbind(eventHolder, \"mousemove\", onMouseMove);\n unbind(eventHolder, \"mouseleave\", onMouseMove);\n unbind(eventHolder, \"click\", onClick);\n highlights = [];\n });\n\n plot.hooks.processDatapoints.push(function(plot, series, data, datapoints) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n processDatapoints(plot, series, datapoints);\n }\n });\n\n plot.hooks.drawOverlay.push(function(plot, octx) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n drawOverlay(plot, octx);\n }\n });\n\n plot.hooks.draw.push(function(plot, newCtx) {\n var options = plot.getOptions();\n if (options.series.pie.show) {\n draw(plot, newCtx);\n }\n });\n\n function processDatapoints(plot, series, datapoints) {\n if (!processed) {\n processed = true;\n canvas = plot.getCanvas();\n target = canvas.parentElement;\n options = plot.getOptions();\n plot.setData(combine(plot.getData()));\n }\n }\n\n function combine(data) {\n var total = 0,\n combined = 0,\n numCombined = 0,\n color = options.series.pie.combine.color,\n newdata = [],\n i,\n value;\n\n // Fix up the raw data from Flot, ensuring the data is numeric\n\n for (i = 0; i < data.length; ++i) {\n value = data[i].data;\n\n // If the data is an array, we'll assume that it's a standard\n // Flot x-y pair, and are concerned only with the second value.\n\n // Note how we use the original array, rather than creating a\n // new one; this is more efficient and preserves any extra data\n // that the user may have stored in higher indexes.\n\n if (Array.isArray(value) && value.length === 1) {\n value = value[0];\n }\n\n if (Array.isArray(value)) {\n // Equivalent to $.isNumeric() but compatible with jQuery < 1.7\n if (!isNaN(parseFloat(value[1])) && isFinite(value[1])) {\n value[1] = +value[1];\n } else {\n value[1] = 0;\n }\n } else if (!isNaN(parseFloat(value)) && isFinite(value)) {\n value = [1, +value];\n } else {\n value = [1, 0];\n }\n\n data[i].data = [value];\n }\n\n // Sum up all the slices, so we can calculate percentages for each\n\n for (i = 0; i < data.length; ++i) {\n total += data[i].data[0][1];\n }\n\n // Count the number of slices with percentages below the combine\n // threshold; if it turns out to be just one, we won't combine.\n\n for (i = 0; i < data.length; ++i) {\n value = data[i].data[0][1];\n if (value / total <= options.series.pie.combine.threshold) {\n combined += value;\n numCombined++;\n if (!color) {\n color = data[i].color;\n }\n }\n }\n\n for (i = 0; i < data.length; ++i) {\n value = data[i].data[0][1];\n if (numCombined < 2 || value / total > options.series.pie.combine.threshold) {\n newdata.push(\n extend(data[i], { /* extend to allow keeping all other original data values\n and using them e.g. in labelFormatter. */\n data: [[1, value]],\n color: data[i].color,\n label: data[i].label,\n angle: value * Math.PI * 2 / total,\n percent: value / (total / 100)\n })\n );\n }\n }\n\n if (numCombined > 1) {\n newdata.push({\n data: [[1, combined]],\n color: color,\n label: options.series.pie.combine.label,\n angle: combined * Math.PI * 2 / total,\n percent: combined / (total / 100)\n });\n }\n\n return newdata;\n }\n\n function draw(plot, newCtx) {\n if (!target) {\n return; // if no series were passed\n }\n\n var canvasWidth = width(plot.getPlaceholder()),\n canvasHeight = height(plot.getPlaceholder()),\n legendEl = target.querySelector(\".legend\"),\n legendWidth = legendEl && legendEl.firstElementChild ? legendEl.firstElementChild.clientWidth : 0;\n\n ctx = newCtx;\n\n // WARNING: HACK! REWRITE THIS CODE AS SOON AS POSSIBLE!\n\n // When combining smaller slices into an 'other' slice, we need to\n // add a new series. Since Flot gives plugins no way to modify the\n // list of series, the pie plugin uses a hack where the first call\n // to processDatapoints results in a call to setData with the new\n // list of series, then subsequent processDatapoints do nothing.\n\n // The plugin-global 'processed' flag is used to control this hack;\n // it starts out false, and is set to true after the first call to\n // processDatapoints.\n\n // Unfortunately this turns future setData calls into no-ops; they\n // call processDatapoints, the flag is true, and nothing happens.\n\n // To fix this we'll set the flag back to false here in draw, when\n // all series have been processed, so the next sequence of calls to\n // processDatapoints once again starts out with a slice-combine.\n // This is really a hack; in 0.9 we need to give plugins a proper\n // way to modify series before any processing begins.\n\n processed = false;\n\n // calculate maximum radius and center point\n maxRadius = Math.min(canvasWidth, canvasHeight / options.series.pie.tilt) / 2;\n centerTop = canvasHeight / 2 + options.series.pie.offset.top;\n centerLeft = canvasWidth / 2;\n\n if (options.series.pie.offset.left === \"auto\") {\n if (options.legend.position.match(\"w\")) {\n centerLeft += legendWidth / 2;\n } else {\n centerLeft -= legendWidth / 2;\n }\n if (centerLeft < maxRadius) {\n centerLeft = maxRadius;\n } else if (centerLeft > canvasWidth - maxRadius) {\n centerLeft = canvasWidth - maxRadius;\n }\n } else {\n centerLeft += options.series.pie.offset.left;\n }\n\n var slices = plot.getData(),\n attempts = 0;\n\n // Keep shrinking the pie's radius until drawPie returns true,\n // indicating that all the labels fit, or we try too many times.\n do {\n if (attempts > 0) {\n maxRadius *= REDRAW_SHRINK;\n }\n attempts += 1;\n clear();\n if (options.series.pie.tilt <= 0.8) {\n drawShadow();\n }\n } while (!drawPie() && attempts < REDRAW_ATTEMPTS)\n\n if (attempts >= REDRAW_ATTEMPTS) {\n clear();\n var errorDiv = document.createElement('div');\n errorDiv.className = 'error';\n errorDiv.textContent = 'Could not draw pie with labels contained inside canvas';\n target.insertBefore(errorDiv, target.firstChild);\n }\n\n if (plot.setSeries && plot.insertLegend) {\n plot.setSeries(slices);\n plot.insertLegend();\n }\n\n // we're actually done at this point, just defining internal functions at this point\n function clear() {\n ctx.clearRect(0, 0, canvasWidth, canvasHeight);\n var labels = target.querySelectorAll(\".pieLabel, .pieLabelBackground\");\n for (var li = 0; li < labels.length; li++) {\n labels[li].remove();\n }\n }\n\n function drawShadow() {\n var shadowLeft = options.series.pie.shadow.left;\n var shadowTop = options.series.pie.shadow.top;\n var edge = 10;\n var alpha = options.series.pie.shadow.alpha;\n var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;\n\n if (radius >= canvasWidth / 2 - shadowLeft || radius * options.series.pie.tilt >= canvasHeight / 2 - shadowTop || radius <= edge) {\n return; // shadow would be outside canvas, so don't draw it\n }\n\n ctx.save();\n ctx.translate(shadowLeft, shadowTop);\n ctx.globalAlpha = alpha;\n ctx.fillStyle = \"#000\";\n\n // center and rotate to starting position\n ctx.translate(centerLeft, centerTop);\n ctx.scale(1, options.series.pie.tilt);\n\n //radius -= edge;\n for (var i = 1; i <= edge; i++) {\n ctx.beginPath();\n ctx.arc(0, 0, radius, 0, Math.PI * 2, false);\n ctx.fill();\n radius -= i;\n }\n\n ctx.restore();\n }\n\n function drawPie() {\n var startAngle = Math.PI * options.series.pie.startAngle;\n var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;\n var i;\n // center and rotate to starting position\n\n ctx.save();\n ctx.translate(centerLeft, centerTop);\n ctx.scale(1, options.series.pie.tilt);\n //ctx.rotate(startAngle); // start at top; -- This doesn't work properly in Opera\n\n // draw slices\n ctx.save();\n\n var currentAngle = startAngle;\n for (i = 0; i < slices.length; ++i) {\n slices[i].startAngle = currentAngle;\n drawSlice(slices[i].angle, slices[i].color, true);\n }\n\n ctx.restore();\n\n // draw slice outlines\n if (options.series.pie.stroke.width > 0) {\n ctx.save();\n ctx.lineWidth = options.series.pie.stroke.width;\n currentAngle = startAngle;\n for (i = 0; i < slices.length; ++i) {\n drawSlice(slices[i].angle, options.series.pie.stroke.color, false);\n }\n\n ctx.restore();\n }\n\n // draw donut hole\n drawDonutHole(ctx);\n\n ctx.restore();\n\n // Draw the labels, returning true if they fit within the plot\n if (options.series.pie.label.show) {\n return drawLabels();\n } else return true;\n\n function drawSlice(angle, color, fill) {\n if (angle <= 0 || isNaN(angle)) {\n return;\n }\n\n if (fill) {\n ctx.fillStyle = color;\n } else {\n ctx.strokeStyle = color;\n ctx.lineJoin = \"round\";\n }\n\n ctx.beginPath();\n if (Math.abs(angle - Math.PI * 2) > 0.000000001) {\n ctx.moveTo(0, 0); // Center of the pie\n }\n\n //ctx.arc(0, 0, radius, 0, angle, false); // This doesn't work properly in Opera\n ctx.arc(0, 0, radius, currentAngle, currentAngle + angle / 2, false);\n ctx.arc(0, 0, radius, currentAngle + angle / 2, currentAngle + angle, false);\n ctx.closePath();\n //ctx.rotate(angle); // This doesn't work properly in Opera\n currentAngle += angle;\n\n if (fill) {\n ctx.fill();\n } else {\n ctx.stroke();\n }\n }\n\n function drawLabels() {\n var currentAngle = startAngle;\n var radius = options.series.pie.label.radius > 1 ? options.series.pie.label.radius : maxRadius * options.series.pie.label.radius;\n\n for (var i = 0; i < slices.length; ++i) {\n if (slices[i].percent >= options.series.pie.label.threshold * 100) {\n if (!drawLabel(slices[i], currentAngle, i)) {\n return false;\n }\n }\n currentAngle += slices[i].angle;\n }\n\n return true;\n\n function drawLabel(slice, startAngle, index) {\n if (slice.data[0][1] === 0) {\n return true;\n }\n\n // format label text\n var lf = options.legend.labelFormatter, text, plf = options.series.pie.label.formatter;\n\n if (lf) {\n text = lf(slice.label, slice);\n } else {\n text = slice.label;\n }\n\n if (plf) {\n text = plf(text, slice);\n }\n\n var halfAngle = ((startAngle + slice.angle) + startAngle) / 2;\n var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);\n var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;\n\n var labelSpan = document.createElement('span');\n labelSpan.className = 'pieLabel';\n labelSpan.id = 'pieLabel' + index;\n labelSpan.style.position = 'absolute';\n labelSpan.style.top = y + 'px';\n labelSpan.style.left = x + 'px';\n labelSpan.innerHTML = text;\n target.appendChild(labelSpan);\n\n var label = target.querySelector(\"#pieLabel\" + index);\n var labelTop = (y - label.clientHeight / 2);\n var labelLeft = (x - label.clientWidth / 2);\n\n label.style.top = labelTop + 'px';\n label.style.left = labelLeft + 'px';\n\n // check to make sure that the label is not outside the canvas\n if (0 - labelTop > 0 || 0 - labelLeft > 0 || canvasHeight - (labelTop + label.clientHeight) < 0 || canvasWidth - (labelLeft + label.clientWidth) < 0) {\n return false;\n }\n\n if (options.series.pie.label.background.opacity !== 0) {\n // put in the transparent background separately to avoid blended labels and label boxes\n var c = options.series.pie.label.background.color;\n if (c == null) {\n c = slice.color;\n }\n\n var bgDiv = document.createElement('div');\n bgDiv.className = 'pieLabelBackground';\n bgDiv.style.cssText = 'position:absolute;width:' + label.clientWidth + 'px;height:' + label.clientHeight + 'px;top:' + labelTop + 'px;left:' + labelLeft + 'px;background-color:' + c + ';';\n bgDiv.style.opacity = options.series.pie.label.background.opacity;\n label.parentNode.insertBefore(bgDiv, label);\n }\n\n return true;\n } // end individual label function\n } // end drawLabels function\n } // end drawPie function\n } // end draw function\n\n // Placed here because it needs to be accessed from multiple locations\n\n function drawDonutHole(layer) {\n // The closure-scoped `options` is set by the processDatapoints\n // hook on first draw, but drawDonutHole can be reached from\n // paths that fire before that hook, leaving `options` null.\n // Read it eagerly. Upstream flot/flot#1559.\n var options = plot.getOptions();\n if (options.series.pie.innerRadius > 0) {\n // subtract the center\n layer.save();\n var innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;\n layer.globalCompositeOperation = \"destination-out\"; // this does not work with excanvas, but it will fall back to using the stroke color\n layer.beginPath();\n layer.fillStyle = options.series.pie.stroke.color;\n layer.arc(0, 0, innerRadius, 0, Math.PI * 2, false);\n layer.fill();\n layer.closePath();\n layer.restore();\n\n // add inner stroke\n layer.save();\n layer.beginPath();\n layer.strokeStyle = options.series.pie.stroke.color;\n layer.arc(0, 0, innerRadius, 0, Math.PI * 2, false);\n layer.stroke();\n layer.closePath();\n layer.restore();\n\n // TODO: add extra shadow inside hole (with a mask) if the pie is tilted.\n }\n }\n\n //-- Additional Interactive related functions --\n\n function isPointInPoly(poly, pt) {\n for (var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) {\n ((poly[i][1] <= pt[1] && pt[1] < poly[j][1]) ||\n (poly[j][1] <= pt[1] && pt[1] < poly[i][1])) &&\n (pt[0] < (poly[j][0] - poly[i][0]) * (pt[1] - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]) &&\n (c = !c);\n }\n return c;\n }\n\n function findNearbySlice(mouseX, mouseY) {\n var slices = plot.getData(),\n options = plot.getOptions(),\n radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius,\n x, y;\n\n for (var i = 0; i < slices.length; ++i) {\n var s = slices[i];\n if (s.pie.show) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0); // Center of the pie\n //ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here.\n ctx.arc(0, 0, radius, s.startAngle, s.startAngle + s.angle / 2, false);\n ctx.arc(0, 0, radius, s.startAngle + s.angle / 2, s.startAngle + s.angle, false);\n ctx.closePath();\n x = mouseX - centerLeft;\n y = mouseY - centerTop;\n\n if (ctx.isPointInPath) {\n if (ctx.isPointInPath(mouseX - centerLeft, mouseY - centerTop)) {\n ctx.restore();\n return {\n datapoint: [s.percent, s.data],\n dataIndex: 0,\n series: s,\n seriesIndex: i\n };\n }\n } else {\n // excanvas for IE doesn;t support isPointInPath, this is a workaround.\n var p1X = radius * Math.cos(s.startAngle),\n p1Y = radius * Math.sin(s.startAngle),\n p2X = radius * Math.cos(s.startAngle + s.angle / 4),\n p2Y = radius * Math.sin(s.startAngle + s.angle / 4),\n p3X = radius * Math.cos(s.startAngle + s.angle / 2),\n p3Y = radius * Math.sin(s.startAngle + s.angle / 2),\n p4X = radius * Math.cos(s.startAngle + s.angle / 1.5),\n p4Y = radius * Math.sin(s.startAngle + s.angle / 1.5),\n p5X = radius * Math.cos(s.startAngle + s.angle),\n p5Y = radius * Math.sin(s.startAngle + s.angle),\n arrPoly = [[0, 0], [p1X, p1Y], [p2X, p2Y], [p3X, p3Y], [p4X, p4Y], [p5X, p5Y]],\n arrPoint = [x, y];\n\n // TODO: perhaps do some mathmatical trickery here with the Y-coordinate to compensate for pie tilt?\n\n if (isPointInPoly(arrPoly, arrPoint)) {\n ctx.restore();\n return {\n datapoint: [s.percent, s.data],\n dataIndex: 0,\n series: s,\n seriesIndex: i\n };\n }\n }\n\n ctx.restore();\n }\n }\n\n return null;\n }\n\n function onMouseMove(e) {\n triggerClickHoverEvent(\"plothover\", e);\n }\n\n function onClick(e) {\n triggerClickHoverEvent(\"plotclick\", e);\n }\n\n // trigger click or hover event (they send the same parameters so we share their code)\n\n function triggerClickHoverEvent(eventname, e) {\n // See drawDonutHole above: read `options` fresh in case the\n // event fires before processDatapoints has run.\n var options = plot.getOptions();\n var offset = plot.offset();\n var canvasX = parseInt(String(e.pageX - offset.left));\n var canvasY = parseInt(String(e.pageY - offset.top));\n var item = findNearbySlice(canvasX, canvasY);\n\n if (options.grid.autoHighlight) {\n // clear auto-highlights\n for (var i = 0; i < highlights.length; ++i) {\n var h = highlights[i];\n if (h.auto === eventname && !(item && h.series === item.series)) {\n unhighlight(h.series);\n }\n }\n }\n\n // highlight the slice\n\n if (item) {\n highlight(item.series, eventname);\n }\n\n // trigger any hover bind events\n\n var pos = { pageX: e.pageX, pageY: e.pageY };\n trigger(target, eventname, [pos, item]);\n }\n\n function highlight(s, auto) {\n //if (typeof s == \"number\") {\n // s = series[s];\n //}\n\n var i = indexOfHighlight(s);\n\n if (i === -1) {\n highlights.push({ series: s, auto: auto });\n plot.triggerRedrawOverlay();\n } else if (!auto) {\n highlights[i].auto = false;\n }\n }\n\n function unhighlight(s) {\n if (s == null) {\n highlights = [];\n plot.triggerRedrawOverlay();\n }\n\n //if (typeof s == \"number\") {\n // s = series[s];\n //}\n\n var i = indexOfHighlight(s);\n\n if (i !== -1) {\n highlights.splice(i, 1);\n plot.triggerRedrawOverlay();\n }\n }\n\n function indexOfHighlight(s) {\n for (var i = 0; i < highlights.length; ++i) {\n var h = highlights[i];\n if (h.series === s) {\n return i;\n }\n }\n return -1;\n }\n\n function drawOverlay(plot, octx) {\n var options = plot.getOptions();\n var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;\n\n octx.save();\n octx.translate(centerLeft, centerTop);\n octx.scale(1, options.series.pie.tilt);\n\n for (var i = 0; i < highlights.length; ++i) {\n drawHighlight(highlights[i].series);\n }\n\n drawDonutHole(octx);\n\n octx.restore();\n\n function drawHighlight(series) {\n if (series.angle <= 0 || isNaN(series.angle)) {\n return;\n }\n\n //octx.fillStyle = parseColor(options.series.pie.highlight.color).scale(null, null, null, options.series.pie.highlight.opacity).toString();\n octx.fillStyle = \"rgba(255, 255, 255, \" + options.series.pie.highlight.opacity + \")\"; // this is temporary until we have access to parseColor\n octx.beginPath();\n if (Math.abs(series.angle - Math.PI * 2) > 0.000000001) {\n octx.moveTo(0, 0); // Center of the pie\n }\n octx.arc(0, 0, radius, series.startAngle, series.startAngle + series.angle / 2, false);\n octx.arc(0, 0, radius, series.startAngle + series.angle / 2, series.startAngle + series.angle, false);\n octx.closePath();\n octx.fill();\n }\n }\n } // end init (plugin body)\n\n // define pie specific options and their default values\n var options = {\n series: {\n pie: {\n show: false,\n radius: \"auto\", // actual radius of the visible pie (based on full calculated radius if <=1, or hard pixel value)\n innerRadius: 0, /* for donut */\n startAngle: 3 / 2,\n tilt: 1,\n shadow: {\n left: 5, // shadow left offset\n top: 15, // shadow top offset\n alpha: 0.02 // shadow alpha\n },\n offset: {\n top: 0,\n left: \"auto\"\n },\n stroke: {\n color: \"#fff\",\n width: 1\n },\n label: {\n show: \"auto\",\n formatter: function(label, slice) {\n return \"<div style='font-size:x-small;text-align:center;padding:2px;color:\" + slice.color + \";'>\" + label + \"<br/>\" + Math.round(slice.percent) + \"%</div>\";\n }, // formatter function\n radius: 1, // radius at which to place the labels (based on full calculated radius if <=1, or hard pixel value)\n background: {\n color: null,\n opacity: 0\n },\n threshold: 0 // percentage at which to hide the label (i.e. the slice is too narrow)\n },\n combine: {\n threshold: -1, // percentage at which to combine little slices into one larger slice\n color: null, // color to give the new slice (auto-generated if null)\n label: \"Other\" // label to give the new slice\n },\n highlight: {\n //color: \"#fff\", // will add this functionality once parseColor is available\n opacity: 0.5\n }\n }\n }\n };\n\n plugins.push({\n init: init,\n options: options,\n name: \"pie\",\n version: \"1.1\"\n });\n"],"names":["options","series","pie","show","radius","innerRadius","startAngle","tilt","shadow","left","top","alpha","offset","stroke","color","width","label","formatter","slice","Math","round","percent","background","opacity","threshold","combine","highlight","plugins","push","init","plot","canvas","target","maxRadius","centerLeft","centerTop","processed","ctx","highlights","drawDonutHole","layer","getOptions","save","globalCompositeOperation","beginPath","fillStyle","arc","PI","fill","closePath","restore","strokeStyle","isPointInPoly","poly","pt","c","i","l","length","j","onMouseMove","e","triggerClickHoverEvent","onClick","eventname","item","mouseX","mouseY","x","y","slices","getData","s","moveTo","angle","isPointInPath","datapoint","data","dataIndex","seriesIndex","cos","sin","findNearbySlice","parseInt","String","pageX","pageY","grid","autoHighlight","h","auto","unhighlight","indexOfHighlight","triggerRedrawOverlay","pos","trigger","splice","hooks","processOptions","legend","bindEvents","eventHolder","hoverable","unbind","bind","clickable","shutdown","processDatapoints","datapoints","getCanvas","parentElement","setData","value","total","combined","numCombined","newdata","Array","isArray","isNaN","parseFloat","isFinite","extend","drawOverlay","octx","translate","scale","drawHighlight","abs","draw","newCtx","canvasWidth","getPlaceholder","canvasHeight","height","legendEl","querySelector","legendWidth","firstElementChild","clientWidth","min","position","match","attempts","clear","drawShadow","drawPie","errorDiv","document","createElement","className","textContent","insertBefore","firstChild","setSeries","insertLegend","clearRect","labels","querySelectorAll","li","remove","shadowLeft","shadowTop","globalAlpha","currentAngle","drawSlice","lineWidth","drawLabel","index","text","lf","labelFormatter","plf","halfAngle","labelSpan","id","style","innerHTML","appendChild","labelTop","clientHeight","labelLeft","bgDiv","css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,EAAIoC,OAAO,EAAG,GAIlBpC,EAAIS,IAAI,EAAG,EAAG1C,EAAQgK,EAAcA,EAAe1F,EAAQ,GAAG,GAC9DrC,EAAIS,IAAI,EAAG,EAAG1C,EAAQgK,EAAe1F,EAAQ,EAAG0F,EAAe1F,GAAO,GACtErC,EAAIY,YAEJmH,GAAgB1F,EAEZ1B,EACAX,EAAIW,OAEJX,EAAIxB,SAEZ,CA6EJ,CACJ,CA3XQoH,CAAKnG,EAAMoG,EAEnB,EA6lBJ,EAmDIlI,QAASA,EACT2L,KAAM,MACNC,QAAS"}
|
package/package.json
CHANGED
package/source/helpers.js
CHANGED
|
@@ -47,6 +47,9 @@ export function extend(deep, target) {
|
|
|
47
47
|
var keys = Object.keys(src);
|
|
48
48
|
for (var k = 0; k < keys.length; k++) {
|
|
49
49
|
var key = keys[k];
|
|
50
|
+
if (key === '__proto__' || key === 'constructor') {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
50
53
|
var val = src[key];
|
|
51
54
|
if (val === undefined) {
|
|
52
55
|
continue;
|
|
@@ -115,10 +118,11 @@ export function removeData(el, key) {
|
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
|
|
121
|
+
// Default trigger: dispatches a native CustomEvent with extra args stashed
|
|
122
|
+
// on `event.detail` (an array). The jQuery adapter overrides this via
|
|
123
|
+
// setTrigger so handlers bound with $(el).on(type, fn) receive the extra
|
|
124
|
+
// args as positional parameters, matching upstream flot/flot behavior.
|
|
125
|
+
var triggerImpl = function(el, type, args) {
|
|
122
126
|
var event = new CustomEvent(type, {
|
|
123
127
|
detail: args || [],
|
|
124
128
|
bubbles: true,
|
|
@@ -126,6 +130,14 @@ export function trigger(el, type, args) {
|
|
|
126
130
|
});
|
|
127
131
|
el.dispatchEvent(event);
|
|
128
132
|
return event;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export function trigger(el, type, args) {
|
|
136
|
+
return triggerImpl(el, type, args);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function setTrigger(fn) {
|
|
140
|
+
triggerImpl = fn;
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
// Bind an event listener, tracking it so unbindAll can remove it later.
|
package/source/jquery-adapter.js
CHANGED
|
@@ -35,6 +35,25 @@ import {
|
|
|
35
35
|
dateTickGenerator,
|
|
36
36
|
composeImages,
|
|
37
37
|
} from './index.js';
|
|
38
|
+
import { setTrigger } from './helpers.js';
|
|
39
|
+
|
|
40
|
+
// Route flot's internal trigger() through jQuery so plugin handlers bound
|
|
41
|
+
// via $(el).on(type, fn) see the same data shape as upstream flot/flot.
|
|
42
|
+
// Two conventions coexist in the plugins, matching upstream:
|
|
43
|
+
// - trigger(el, type, [arg0, arg1, ...]) → $(el).trigger(type, [args])
|
|
44
|
+
// jQuery spreads the array into handler positional params, so
|
|
45
|
+
// function(event, pos, item, items) works (plothover, plotzoom, ...).
|
|
46
|
+
// - trigger(el, type, <non-array>) → $.Event(type, { detail: x })
|
|
47
|
+
// Handlers read event.detail, matching upstream's re-center contract
|
|
48
|
+
// where a plain object (or Event) is attached to event.detail.
|
|
49
|
+
setTrigger(function(el, type, args) {
|
|
50
|
+
if (args === undefined || Array.isArray(args)) {
|
|
51
|
+
$(el).trigger(type, args || []);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var event = $.Event(type, { detail: args });
|
|
55
|
+
$(el).trigger(event);
|
|
56
|
+
});
|
|
38
57
|
|
|
39
58
|
// Register $.plot and $.color on the jQuery object.
|
|
40
59
|
$.plot = function(placeholder, data, options) {
|
|
@@ -221,7 +221,9 @@ var Canvas = function(cls, container) {
|
|
|
221
221
|
layer.style.left = '0px';
|
|
222
222
|
layer.style.bottom = '0px';
|
|
223
223
|
layer.style.right = '0px';
|
|
224
|
-
svgElement
|
|
224
|
+
if (svgElement) {
|
|
225
|
+
svgElement.appendChild(layer);
|
|
226
|
+
}
|
|
225
227
|
this.SVG[classes] = layer;
|
|
226
228
|
}
|
|
227
229
|
|
|
@@ -315,8 +317,8 @@ var Canvas = function(cls, container) {
|
|
|
315
317
|
|
|
316
318
|
element.style.position = 'absolute';
|
|
317
319
|
element.style.maxWidth = width;
|
|
318
|
-
element.setAttributeNS(null, 'x', -9999);
|
|
319
|
-
element.setAttributeNS(null, 'y', -9999);
|
|
320
|
+
element.setAttributeNS(null, 'x', String(-9999));
|
|
321
|
+
element.setAttributeNS(null, 'y', String(-9999));
|
|
320
322
|
|
|
321
323
|
if (typeof font === 'object') {
|
|
322
324
|
element.style.font = textStyle;
|
|
@@ -340,7 +342,9 @@ var Canvas = function(cls, container) {
|
|
|
340
342
|
while (element.firstChild) {
|
|
341
343
|
element.removeChild(element.firstChild);
|
|
342
344
|
}
|
|
343
|
-
element.parentNode
|
|
345
|
+
if (element.parentNode) {
|
|
346
|
+
element.parentNode.removeChild(element);
|
|
347
|
+
}
|
|
344
348
|
}
|
|
345
349
|
|
|
346
350
|
info.measured = true;
|
|
@@ -22,7 +22,7 @@ export var browser = {
|
|
|
22
22
|
isSafari: function() {
|
|
23
23
|
var top = window.top;
|
|
24
24
|
if (!top) return false;
|
|
25
|
-
return /constructor/i.test(top.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!top['safari'] || (typeof top.safari !== 'undefined' && top.safari.pushNotification));
|
|
25
|
+
return /constructor/i.test(/** @type {any} */ (top.HTMLElement)) || (function (/** @type {any} */ p) { return p.toString() === "[object SafariRemoteNotification]"; })(!(/** @type {any} */ (top))['safari'] || (typeof (/** @type {any} */ (top)).safari !== 'undefined' && (/** @type {any} */ (top)).safari.pushNotification));
|
|
26
26
|
},
|
|
27
27
|
|
|
28
28
|
isMobileSafari: function() {
|
|
@@ -165,7 +165,7 @@ import { browser } from './jquery.flot.browser.js';
|
|
|
165
165
|
const utf8Array = new Uint8Array(arrayBuffer);
|
|
166
166
|
const blockSize = 16384;
|
|
167
167
|
for (var i = 0; i < utf8Array.length; i = i + blockSize) {
|
|
168
|
-
const binarySubString = String.fromCharCode.apply(null, utf8Array.subarray(i, i + blockSize));
|
|
168
|
+
const binarySubString = String.fromCharCode.apply(null, /** @type {any} */ (utf8Array.subarray(i, i + blockSize)));
|
|
169
169
|
binaryString = binaryString + binarySubString;
|
|
170
170
|
}
|
|
171
171
|
return binaryString;
|
|
@@ -80,10 +80,10 @@ import { bind, unbind, trigger } from './helpers.js';
|
|
|
80
80
|
newEvent = new CustomEvent('mouseevent');
|
|
81
81
|
|
|
82
82
|
//transform from touch event to mouse event format
|
|
83
|
-
newEvent.pageX = e.detail.changedTouches[0].pageX;
|
|
84
|
-
newEvent.pageY = e.detail.changedTouches[0].pageY;
|
|
85
|
-
newEvent.clientX = e.detail.changedTouches[0].clientX;
|
|
86
|
-
newEvent.clientY = e.detail.changedTouches[0].clientY;
|
|
83
|
+
/** @type {any} */ (newEvent).pageX = e.detail.changedTouches[0].pageX;
|
|
84
|
+
/** @type {any} */ (newEvent).pageY = e.detail.changedTouches[0].pageY;
|
|
85
|
+
/** @type {any} */ (newEvent).clientX = e.detail.changedTouches[0].clientX;
|
|
86
|
+
/** @type {any} */ (newEvent).clientY = e.detail.changedTouches[0].clientY;
|
|
87
87
|
|
|
88
88
|
if (o.grid.hoverable) {
|
|
89
89
|
doTriggerClickHoverEvent(newEvent, eventType.hover, 30);
|
package/source/jquery.flot.js
CHANGED
|
@@ -2822,7 +2822,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2822
2822
|
// Plugin registry. Plugins push to this array to register themselves.
|
|
2823
2823
|
export var plugins = [];
|
|
2824
2824
|
|
|
2825
|
-
export var version = "5.1.
|
|
2825
|
+
export var version = "5.1.2";
|
|
2826
2826
|
|
|
2827
2827
|
// The main plot function.
|
|
2828
2828
|
export function plot(placeholder, data, options) {
|
|
@@ -54,7 +54,7 @@ import { plugins } from './jquery.flot.js';
|
|
|
54
54
|
|
|
55
55
|
var left = 0;
|
|
56
56
|
var columnWidths = [];
|
|
57
|
-
var style = window.getComputedStyle(document.
|
|
57
|
+
var style = window.getComputedStyle(document.body);
|
|
58
58
|
for (i = 0; i < entries.length; ++i) {
|
|
59
59
|
let columnIndex = i % options.legend.noColumns;
|
|
60
60
|
entry = entries[i];
|
|
@@ -790,7 +790,7 @@ import { bind, unbind, trigger, css } from './helpers.js';
|
|
|
790
790
|
ctx.lineJoin = "round";
|
|
791
791
|
var startx = Math.round(panHint.start.x),
|
|
792
792
|
starty = Math.round(panHint.start.y),
|
|
793
|
-
endx, endy;
|
|
793
|
+
endx = 0, endy = 0;
|
|
794
794
|
|
|
795
795
|
if (panAxes) {
|
|
796
796
|
if (panAxes[0].direction === 'x') {
|
|
@@ -660,8 +660,8 @@ import { extend, bind, unbind, trigger, width, height } from './helpers.js';
|
|
|
660
660
|
// event fires before processDatapoints has run.
|
|
661
661
|
var options = plot.getOptions();
|
|
662
662
|
var offset = plot.offset();
|
|
663
|
-
var canvasX = parseInt(e.pageX - offset.left);
|
|
664
|
-
var canvasY = parseInt(e.pageY - offset.top);
|
|
663
|
+
var canvasX = parseInt(String(e.pageX - offset.left));
|
|
664
|
+
var canvasY = parseInt(String(e.pageY - offset.top));
|
|
665
665
|
var item = findNearbySlice(canvasX, canvasY);
|
|
666
666
|
|
|
667
667
|
if (options.grid.autoHighlight) {
|
|
@@ -203,6 +203,7 @@ import { bind, trigger, unbind } from './helpers.js';
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
function triggerSelectedEvent() {
|
|
206
|
+
/** @type {any} */
|
|
206
207
|
var r = getSelection();
|
|
207
208
|
|
|
208
209
|
trigger(plot.getPlaceholder(), "plotselected", [ r ]);
|
|
@@ -285,7 +286,7 @@ import { bind, trigger, unbind } from './helpers.js';
|
|
|
285
286
|
|
|
286
287
|
// function taken from markings support in Flot
|
|
287
288
|
function extractRange(ranges, coord) {
|
|
288
|
-
var axis, from, to, key, axes = plot.getAxes();
|
|
289
|
+
var axis, from, to, /** @type {string|undefined} */ key, axes = plot.getAxes();
|
|
289
290
|
|
|
290
291
|
for (var k in axes) {
|
|
291
292
|
axis = axes[k];
|
|
@@ -305,7 +306,7 @@ import { bind, trigger, unbind } from './helpers.js';
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
// backwards-compat stuff - to be removed in future
|
|
308
|
-
if (!ranges[key]) {
|
|
309
|
+
if (key && !ranges[key]) {
|
|
309
310
|
axis = coord === "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
|
|
310
311
|
from = ranges[coord + "1"];
|
|
311
312
|
to = ranges[coord + "2"];
|
|
@@ -329,9 +329,9 @@ import { saturated } from './jquery.flot.saturated.js';
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
for (var i = 0; i < spec.length - 1; ++i) {
|
|
332
|
-
if (axis.delta < (spec[i][0] * timeUnitSize[spec[i][1]] +
|
|
333
|
-
spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2 &&
|
|
334
|
-
spec[i][0] * timeUnitSize[spec[i][1]] >= minSize) {
|
|
332
|
+
if (axis.delta < (Number(spec[i][0]) * timeUnitSize[spec[i][1]] +
|
|
333
|
+
Number(spec[i + 1][0]) * timeUnitSize[spec[i + 1][1]]) / 2 &&
|
|
334
|
+
Number(spec[i][0]) * timeUnitSize[spec[i][1]] >= minSize) {
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
337
|
}
|
|
@@ -14,6 +14,7 @@ import { plugins } from './jquery.flot.js';
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function initTouchNavigation(plot, options) {
|
|
17
|
+
/** @type {{ twoTouches: boolean, currentTapStart: {x: number, y: number}, currentTapEnd: {x: number, y: number}, prevTap: {x: number, y: number}, currentTap: {x: number, y: number}, interceptedLongTap: boolean, isUnsupportedGesture: boolean, prevTapTime: number | null, tapStartTime: number | null, longTapTriggerId: ReturnType<typeof setTimeout> | null }} */
|
|
17
18
|
var gestureState = {
|
|
18
19
|
twoTouches: false,
|
|
19
20
|
currentTapStart: { x: 0, y: 0 },
|
|
@@ -167,6 +168,7 @@ import { plugins } from './jquery.flot.js';
|
|
|
167
168
|
},
|
|
168
169
|
|
|
169
170
|
isLongTap: function(e) {
|
|
171
|
+
if (gestureState.tapStartTime == null) return false;
|
|
170
172
|
var currentTime = new Date().getTime(),
|
|
171
173
|
tapDuration = currentTime - gestureState.tapStartTime;
|
|
172
174
|
if (tapDuration >= minLongTapDuration && !gestureState.interceptedLongTap) {
|
|
@@ -207,6 +209,7 @@ import { plugins } from './jquery.flot.js';
|
|
|
207
209
|
},
|
|
208
210
|
|
|
209
211
|
isTap: function(e) {
|
|
212
|
+
if (gestureState.tapStartTime == null) return false;
|
|
210
213
|
var currentTime = new Date().getTime(),
|
|
211
214
|
tapDuration = currentTime - gestureState.tapStartTime;
|
|
212
215
|
if (tapDuration <= pressedTapDuration) {
|
|
@@ -259,7 +262,9 @@ import { plugins } from './jquery.flot.js';
|
|
|
259
262
|
|
|
260
263
|
function isDoubleTap(e) {
|
|
261
264
|
var currentTime = new Date().getTime(),
|
|
262
|
-
intervalBetweenTaps =
|
|
265
|
+
intervalBetweenTaps = gestureState.prevTapTime != null
|
|
266
|
+
? currentTime - gestureState.prevTapTime
|
|
267
|
+
: Infinity;
|
|
263
268
|
|
|
264
269
|
if (intervalBetweenTaps >= 0 && intervalBetweenTaps < maxIntervalBetweenTaps) {
|
|
265
270
|
if (distance(gestureState.prevTap.x, gestureState.prevTap.y, gestureState.currentTap.x, gestureState.currentTap.y) < maxDistanceBetweenTaps) {
|