Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
62 KiB

!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}var e={version:"0.1.28"},f={target:"c3-target",chart:"c3-chart",chartLine:"c3-chart-line",chartLines:"c3-chart-lines",chartBar:"c3-chart-bar",chartBars:"c3-chart-bars",chartText:"c3-chart-text",chartTexts:"c3-chart-texts",chartArc:"c3-chart-arc",chartArcs:"c3-chart-arcs",chartArcsTitle:"c3-chart-arcs-title",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",text:"c3-text",texts:"c3-texts",grid:"c3-grid",xgrid:"c3-xgrid",xgrids:"c3-xgrids",xgridLine:"c3-xgrid-line",xgridLines:"c3-xgrid-lines",xgridFocus:"c3-xgrid-focus",ygrid:"c3-ygrid",ygrids:"c3-ygrids",ygridLine:"c3-ygrid-line",ygridLines:"c3-ygrid-lines",axisX:"c3-axis-x",axisXLabel:"c3-axis-x-label",axisY:"c3-axis-y",axisYLabel:"c3-axis-y-label",axisY2:"c3-axis-y2",axisY2Label:"c3-axis-y2-label",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};e.generate=function(e){function g(a,b){if(!(a in e))throw Error(b)}function h(a,b){var c,d,f,g=e;for(c=0;c<a.length;c++){if("object"==typeof g&&!(a[c]in g))return b;if(d=c===a.length-1,f=g[a[c]],!d&&"object"!=typeof f||d&&"object"!=typeof b&&"object"==typeof f&&null!==f)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(){qi.attr("transform",bi.main),qi.select("."+f.axisX).attr("transform",bi.x),qi.select("."+f.axisY).attr("transform",bi.y),qi.select("."+f.axisY2).attr("transform",bi.y2),qi.select("."+f.chartArcs).attr("transform",bi.arc)}function k(){rg&&(ri.attr("transform",bi.context),ri.select("."+f.axisX).attr("transform",bi.subx))}function l(a){var b=a!==!1?250:0;ug&&si.transition().duration(b).attr("transform",bi.legend)}function m(a){j(a),k(a),l(a)}function n(){rf=r(),sf=s(),tf=Q(),uf=P(),kf={top:yg?w("y2"):ii,right:u(),bottom:w(yg?"y":"x")+(yg?0:sg)+(ci?0:tf),left:(yg?sg+hi:0)+t()},nf=rf-kf.left-kf.right,pf=sf-kf.top-kf.bottom,0>nf&&(nf=0),0>pf&&(pf=0),lf={top:yg?kf.top:sf-sg-(ci?0:tf),right:0/0,bottom:20+(ci?0:tf),left:yg?gi:kf.left},of=yg?kf.left-gi-hi:nf,qf=yg?pf:sf-lf.top-lf.bottom,0>of&&(of=0),0>qf&&(qf=0),mf={top:ci?0:sf-tf,right:0/0,bottom:0,left:ci?rf-uf:0},p(),ci&&Md(Ye.data.targets)&&(mf.left=nf/2+wf)}function o(){qi.select("line."+f.xgridFocus).attr("x1",yg?0:-10).attr("x2",yg?nf:-10).attr("y1",yg?-10:kf.top).attr("y2",yg?-10:pf)}function p(){wf=pf/2,vf=.95*wf,xf=Ld(Ye.data.targets)?.6*vf:0}function q(){var a=yg?f.axisX:f.axisY,b=Xe.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Xe.select($e).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return _e?_e:x()}function s(){var a=af?af:y();return a>0?a:320}function t(){return Md(Ye.data.targets)?0:bf?bf:yg||!Lg||Qg?1:v("y")}function u(){var a=1;return Md(Ye.data.targets)?0:cf?cf:ci?uf+(Ug&&!yg?v("y2"):a):Ug?Zg||yg?a:v("y2"):a}function v(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function w(a){return"y"!==a||Lg?"y2"!==a||Ug?(gb(a).isInner?30:40)+("y2"===a?-10:0):ii:ug&&!ci?10:1}function x(){return+Xe.select($e).style("width").replace("px","")}function y(){return+Xe.select($e).style("height").replace("px","")}function z(a){return a?-5:-(kf.left-1)}function A(a){return a?-20:-1}function B(){return z(!yg)}function C(){return A(!yg)}function D(){return z(yg)}function E(){return A(yg)}function F(a){return a?nf+2+4:kf.left+20}function G(a){return a?80:pf+2}function H(){return F(!yg)}function I(){return G(!yg)}function J(){return F(yg)}function K(){return G(yg)}function L(){var a=yg?pf:nf,b=tc(),c=Vb()*(Id(Ye.data.targets
});if(Object.keys(Yf).length>0){d=[];for(var g in Yf)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}kh&&me(b),pe(b),qi.selectAll("."+f.shape+"-"+b).each(function(a){lg(a)})}}).on("mouseout",function(a,b){Md(Ye.data.targets)||(yd(),wd(),ne(b),qe(),qi.selectAll("."+f.shape+"-"+b).each(function(a){mg(a)}))}).on("mousemove",function(a,b){var c;Sh||Md(Ye.data.targets)||(c=Ac(Ye.data.targets).map(function(a){return jc(a.values[b])}),vd(c,Xe.mouse(this)),xd(c),gg&&(hg||qi.selectAll("."+f.shape+"-"+b).filter(function(a){return ig(a)}).each(function(){var a=Xe.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",lh),oi.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?Zd(this,mh):"path"===this.nodeName?$d(this):void 0}).each(function(){var a=Xe.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",mh)),oi.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Md(Ye.data.targets)?void 0:Th?void(Th=!1):void qi.selectAll("."+f.shape+"-"+b).each(function(a){Ae(this,a,b)})}).call(Xe.behavior.drag().origin(Object).on("drag",function(){Be(Xe.mouse(this))}).on("dragstart",function(){Ce(Xe.mouse(this))}).on("dragend",function(){De()})).call(ni).on("dblclick.zoom",null)}function ze(a){a.append("rect").attr("x",0).attr("y",0).attr("width",nf).attr("height",pf).attr("class",f.eventRect).on("mouseout",function(){Md(Ye.data.targets)||(yd(),wd(),ne())}).on("mousemove",function(){var a,b,c,d;Sh||Md(Ye.data.targets)||(a=Xe.mouse(this),b=od(Ye.data.targets,a),c=qd(Ye.data.targets,b.x),d=c.map(function(a){return jc(a)}),vd(d,a),kh&&(ne(),me(b.index,b.id)),xd(d),ce(b,a)<100?(oi.select("."+f.eventRect).style("cursor","pointer"),Uh||(lg(b),Uh=!0)):(oi.select("."+f.eventRect).style("cursor",null),mg(b),Uh=!1))}).on("click",function(){var a,b;Md(Ye.data.targets)||(a=Xe.mouse(this),b=od(Ye.data.targets,a),ce(b,a)<100&&qi.select("."+f.circles+"-"+Yc(b.id)).select("."+f.circle+"-"+b.index).each(function(){Ae(this,b,b.index)}))}).call(Xe.behavior.drag().origin(Object).on("drag",function(){Be(Xe.mouse(this))}).on("dragstart",function(){Ce(Xe.mouse(this))}).on("dragend",function(){De()})).call(ni).on("dblclick.zoom",null)}function Ae(a,b,c){var d,e=Xe.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=Zd(a,1.5*mh),d=ge):"path"===a.nodeName&&(h=$d(a),d=je),(hg||h)&&(gg&&ig(b)&&(jg||qi.selectAll("."+f.shapes+(hg?Yc(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Xe.select(this);c.classed(f.SELECTED)&&d(!1,c.classed(f.SELECTED,!1),a,b)}),e.classed(f.SELECTED,!g),d(!g,e,b,c)),kg(b,a))}function Be(a){var b,c,d,e,g,h,i,j;Md(Ye.data.targets)||gg&&(!df||ni.altDomain)&&jg&&(b=Rh[0],c=Rh[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=hg?kf.top:Math.min(c,e),j=hg?pf:Math.max(c,e),qi.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),qi.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return ig(a)}).each(function(a,b){var c,d,e,k,l,m,n=Xe.select(this),o=n.classed(f.SELECTED),p=n.classed(f.INCLUDED),q=!1;"circle"===this.nodeName?(c=1*n.attr("cx"),d=1*n.attr("cy"),l=ge,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=rd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=je,q=!(c>h||g>c+e||d>j||i>d+k)),q^p&&(n.classed(f.INCLUDED,!p),n.classed(f.SELECTED,!o),l(!o,n,a,b))}))}function Ce(a){Md(Ye.data.targets)||gg&&(Rh=a,qi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Sh=!0,pg())}function De(){Md(Ye.data.targets)||gg&&(qi.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),qi.selectAll("."+f.shape).classed(f.INCLUDED,!1),Sh=!1,qg())}function Ee(a){var c,e,g,h,i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P=Bd(),Q=Md(Ye.data.targets),R=Ac(Ye.data.targets);if(0!==R.length){if(a=d(a)?a:{},v=d(a.withY)?a.withY:!0,w=d(a.withSubchart)?a.withSubchart:!0,x=d(a.withTransition)?a.withTransition:!0,A=d(a.withTransform)?a.withTransform:!1,B=d(a.withUpdateXD