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
61 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.26"},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(){ii.attr("transform",Vh.main),ii.select("."+f.axisX).attr("transform",Vh.x),ii.select("."+f.axisY).attr("transform",Vh.y),ii.select("."+f.axisY2).attr("transform",Vh.y2),ii.select("."+f.chartArcs).attr("transform",Vh.arc)}function k(){lg&&(ji.attr("transform",Vh.context),ji.select("."+f.axisX).attr("transform",Vh.subx))}function l(a){var b=a!==!1?250:0;og&&ki.transition().duration(b).attr("transform",Vh.legend)}function m(a){j(a),k(a),l(a)}function n(){mf=q(),nf=r(),of=P(),pf=O(),ef={top:sg?v("y2"):ai,right:t(),bottom:v(sg?"y":"x")+(sg?0:mg)+(Wh?0:of),left:(sg?mg+_h:0)+s()},hf=mf-ef.left-ef.right,kf=nf-ef.top-ef.bottom,0>hf&&(hf=0),0>kf&&(kf=0),ff={top:sg?ef.top:nf-mg-(Wh?0:of),right:0/0,bottom:20+(Wh?0:of),left:sg?$h:ef.left},jf=sg?ef.left-$h-_h:hf,lf=sg?kf:nf-ff.top-ff.bottom,0>jf&&(jf=0),0>lf&&(lf=0),gf={top:Wh?0:nf-of,right:0/0,bottom:0,left:Wh?mf-pf:0},o(),Wh&&Id(Te.data.targets)&&(gf.left=hf/2+rf)}function o(){rf=kf/2,qf=.95*rf,sf=Hd(Te.data.targets)?.6*qf:0}function p(){var a=sg?f.axisX:f.axisY,b=Se.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Se.select(Ve).node().getBoundingClientRect(),e=c.right-d.left-s();return e>0?e:0}function q(){return We?We:w()}function r(){var a=Xe?Xe:x();return a>0?a:320}function s(){return Id(Te.data.targets)?0:Ye?Ye:sg||!Eg||Jg?1:u("y")}function t(){var a=1;return Id(Te.data.targets)?0:Ze?Ze:Wh?pf+(Ng&&!sg?u("y2"):a):Ng?Sg||sg?a:u("y2"):a}function u(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function v(a){return"y"!==a||Eg?"y2"!==a||Ng?(gb(a).isInner?30:40)+("y2"===a?-10:0):ai:og&&!Wh?10:1}function w(){return+Se.select(Ve).style("width").replace("px","")}function x(){return+Se.select(Ve).style("height").replace("px","")}function y(a){return a?-5:-(ef.left-1)}function z(a){return a?-20:-1}function A(){return y(!sg)}function B(){return z(!sg)}function C(){return y(sg)}function D(){return z(sg)}function E(a){return a?hf+2+4:ef.left+20}function F(a){return a?80:kf+2}function G(){return E(!sg)}function H(){return F(!sg)}function I(){return E(sg)}function J(){return F(sg)}function K(){var a=sg?kf:hf,b=tc(),c=Vb()*(Ed(Te.data.targets)?(b-(Ih?.25:1))/b:.98);return b>1?a*c/(b-1):a}function L(a){Xh=a}function M(a){Yh=a}function N(a){Zh=a}function O(){return og?Wh?Yh
}),rd(c,Se.mouse(this)),td(c),ag&&(bg||ii.selectAll("."+f.shape+"-"+b).filter(function(a){return cg(a)}).each(function(){var a=Se.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",eh),gi.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?Vd(this,fh):"path"===this.nodeName?Wd(this):void 0}).each(function(){var a=Se.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",fh)),gi.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Id(Te.data.targets)?void 0:Mh?void(Mh=!1):void ii.selectAll("."+f.shape+"-"+b).each(function(a){we(this,a,b)})}).call(Se.behavior.drag().origin(Object).on("drag",function(){xe(Se.mouse(this))}).on("dragstart",function(){ye(Se.mouse(this))}).on("dragend",function(){ze()})).call(fi).on("dblclick.zoom",null)}function ve(a){a.append("rect").attr("x",0).attr("y",0).attr("width",hf).attr("height",kf).attr("class",f.eventRect).on("mouseout",function(){Id(Te.data.targets)||(ud(),sd(),je())}).on("mousemove",function(){var a,b,c;Lh||Id(Te.data.targets)||(a=Se.mouse(this),b=ld(Te.data.targets,a),c=[jc(b)],rd(c,a),dh&&(je(),ie(b.index,b.id)),td(c),$d(b,a)<100?(gi.select("."+f.eventRect).style("cursor","pointer"),Nh||(fg(b),Nh=!0)):(gi.select("."+f.eventRect).style("cursor",null),gg(b),Nh=!1))}).on("click",function(){var a,b;Id(Te.data.targets)||(a=Se.mouse(this),b=ld(Te.data.targets,a),$d(b,a)<100&&ii.select("."+f.circles+"-"+Wc(b.id)).select("."+f.circle+"-"+b.index).each(function(){we(this,b,b.index)}))}).call(Se.behavior.drag().origin(Object).on("drag",function(){xe(Se.mouse(this))}).on("dragstart",function(){ye(Se.mouse(this))}).on("dragend",function(){ze()})).call(fi).on("dblclick.zoom",null)}function we(a,b,c){var d,e=Se.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=Vd(a,1.5*fh),d=ce):"path"===a.nodeName&&(h=Wd(a),d=fe),(bg||h)&&(ag&&cg(b)&&(dg||ii.selectAll("."+f.shapes+(bg?Wc(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Se.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)),eg(b,a))}function xe(a){var b,c,d,e,g,h,i,j;Id(Te.data.targets)||ag&&(!$e||fi.altDomain)&&dg&&(b=Kh[0],c=Kh[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=bg?ef.top:Math.min(c,e),j=bg?kf:Math.max(c,e),ii.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),ii.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return cg(a)}).each(function(a,b){var c,d,e,k,l,m,n=Se.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=ce,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=nd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=fe,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 ye(a){Id(Te.data.targets)||ag&&(Kh=a,ii.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Lh=!0,jg())}function ze(){Id(Te.data.targets)||ag&&(ii.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),ii.selectAll("."+f.shape).classed(f.INCLUDED,!1),Lh=!1,kg())}function Ae(a){var c,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J=xd(),L=Id(Te.data.targets),M=zc(Te.data.targets);if(0!==M.length){if(a=d(a)?a:{},u=d(a.withY)?a.withY:!0,v=d(a.withSubchart)?a.withSubchart:!0,w=d(a.withTransition)?a.withTransition:!0,x=d(a.withTransform)?a.withTransform:!1,y=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,z=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,A=d(a.withLegend)?a.withLegend:!1,F=w?df:0,G=d(a.durationForExit)?a.durationForExit:F,H=d(a.durationForAxis)?a.durationForAxis:F,A&&og&&Oe(Te.data.targets,a),z&&(Ff.domain(Se.extent(Zb(M))),ni=Ff.domain(),$e&&fi.scale(Ff).updateScaleExtent(),If.domain(Ff.domain()),bi.scale(If)),y&&(Ff.domain(bi.empty()?ni:bi.extent()),$e&&fi.scale(Ff).updateScaleExtent()),Gf.domain(Ub(M,"y")),Hf.domain(Ub(M,"y2")),zg&&(I=Ac(M),Lf.tickValues(I),Of.tickVal