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
60 KiB

11 years ago
!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={},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.version="0.1.24",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)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(){$h.attr("transform",Lh.main),$h.select("."+f.axisX).attr("transform",Lh.x),$h.select("."+f.axisY).attr("transform",Lh.y),$h.select("."+f.axisY2).attr("transform",Lh.y2),$h.select("."+f.chartArcs).attr("transform",Lh.arc)}function k(){gg&&(_h.attr("transform",Lh.context),_h.select("."+f.axisX).attr("transform",Lh.subx))}function l(a){var b=a!==!1?250:0;jg&&ai.transition().duration(b).attr("transform",Lh.legend)}function m(a){j(a),k(a),l(a)}function n(){gf=q(),hf=r(),jf=P(),kf=O(),_e={top:ng?v("y2"):Sh,right:t(),bottom:v(ng?"y":"x")+(ng?0:hg)+(Mh?0:jf),left:(ng?hg+Rh:0)+s()},cf=gf-_e.left-_e.right,ef=hf-_e.top-_e.bottom,0>cf&&(cf=0),0>ef&&(ef=0),af={top:ng?_e.top:hf-hg-(Mh?0:jf),right:0/0,bottom:20+(Mh?0:jf),left:ng?Qh:_e.left},df=ng?_e.left-Qh-Rh:cf,ff=ng?ef:hf-af.top-af.bottom,0>df&&(df=0),0>ff&&(ff=0),bf={top:Mh?0:hf-jf,right:0/0,bottom:0,left:Mh?gf-kf:0},o(),Mh&&Dd(Oe.data.targets)&&(bf.left=cf/2+mf)}function o(){mf=ef/2,lf=.95*mf,nf=Cd(Oe.data.targets)?.6*lf:0}function p(){var a=ng?f.axisX:f.axisY,b=Ne.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Ne.select(Qe).node().getBoundingClientRect(),e=c.right-d.left-s();return e>0?e:0}function q(){return Re?Re:w()}function r(){var a=Se?Se:x();return a>0?a:320}function s(){return Dd(Oe.data.targets)?0:Te?Te:ng||!yg||Dg?1:u("y")}function t(){var a=1;return Dd(Oe.data.targets)?0:Ue?Ue:Mh?kf+(Hg&&!ng?u("y2"):a):Hg?Mg||ng?a:u("y2"):a}function u(a){var b=eb(a);return b.isInner?20+xb(a):40+xb(a)}function v(a){return"y"!==a||yg?"y2"!==a||Hg?(eb(a).isInner?30:40)+("y2"===a?-10:0):Sh:jg&&!Mh?10:1}function w(){return+Ne.select(Qe).style("width").replace("px","")}function x(){return+Ne.select(Qe).style("height").replace("px","")}function y(a){return a?-5:-(_e.left-1)}function z(a){return a?-20:-1}function A(){return y(!ng)}function B(){return z(!ng)}function C(){return y(ng)}function D(){return z(ng)}function E(a){return a?cf+2+4:_e.left+20}function F(a){return a?80:ef+2}function G(){return E(!ng)}function H(){return F(!ng)}function I(){return E(ng)}function J(){return F(ng)}function K(){var a=ng?ef:cf,b=qc(),c=Sb()*(zd(Oe.data.targets)?(b-(yh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function L(a){Nh=a}function M(a){Oh=a}function N(a){Ph=a}function O(){return jg?Mh?Oh*(Nh+1)
})}).call(Ne.behavior.drag().origin(Object).on("drag",function(){se(Ne.mouse(this))}).on("dragstart",function(){te(Ne.mouse(this))}).on("dragend",function(){ue()})).call(Xh).on("dblclick.zoom",null)}function qe(a){a.append("rect").attr("x",0).attr("y",0).attr("width",cf).attr("height",ef).attr("class",f.eventRect).on("mouseout",function(){Dd(Oe.data.targets)||(pd(),nd(),ee())}).on("mousemove",function(){var a,b,c;Bh||Dd(Oe.data.targets)||(a=Ne.mouse(this),b=gd(Oe.data.targets,a),c=[gc(b)],md(c,a),Zg&&(ee(),de(b.index,b.id)),od(c),Vd(b,a)<100?(Yh.select("."+f.eventRect).style("cursor","pointer"),Dh||(ag(b),Dh=!0)):(Yh.select("."+f.eventRect).style("cursor",null),bg(b),Dh=!1))}).on("click",function(){var a,b;Dd(Oe.data.targets)||(a=Ne.mouse(this),b=gd(Oe.data.targets,a),Vd(b,a)<100&&$h.select("."+f.circles+"-"+Sc(b.id)).select("."+f.circle+"-"+b.index).each(function(){re(this,b,b.index)}))}).call(Ne.behavior.drag().origin(Object).on("drag",function(){se(Ne.mouse(this))}).on("dragstart",function(){te(Ne.mouse(this))}).on("dragend",function(){ue()})).call(Xh).on("dblclick.zoom",null)}function re(a,b,c){var d,e=Ne.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=Qd(a,1.5*_g),d=Zd):"path"===a.nodeName&&(h=Rd(a),d=ae),(Yf||h)&&(Xf&&Zf(b)&&($f||$h.selectAll("."+f.shapes+(Yf?Sc(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Ne.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)),_f(b,a))}function se(a){var b,c,d,e,g,h,i,j;Dd(Oe.data.targets)||Xf&&(!Ve||Xh.altDomain)&&$f&&(b=Ah[0],c=Ah[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=Yf?_e.top:Math.min(c,e),j=Yf?ef:Math.max(c,e),$h.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),$h.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return Zf(a)}).each(function(a,b){var c,d,e,k,l,m,n=Ne.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=Zd,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=id(this),c=m.x,d=m.y,e=m.width,k=m.height,l=ae,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 te(a){Dd(Oe.data.targets)||Xf&&(Ah=a,$h.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Bh=!0,eg())}function ue(){Dd(Oe.data.targets)||Xf&&($h.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),$h.selectAll("."+f.shape).classed(f.INCLUDED,!1),Bh=!1,fg())}function ve(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=sd(),J=Dd(Oe.data.targets),L=wc(Oe.data.targets);if(0!==L.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?$e:0,G=d(a.durationForExit)?a.durationForExit:F,H=d(a.durationForAxis)?a.durationForAxis:F,A&&jg&&Je(Oe.data.targets,a),z&&(Af.domain(Ne.extent(Wb(L))),di=Af.domain(),Ve&&Xh.scale(Af).updateScaleExtent(),Df.domain(Af.domain()),Th.scale(Df)),y&&(Af.domain(Th.empty()?di:Th.extent()),Ve&&Xh.scale(Af).updateScaleExtent()),Bf.domain(Rb(L,"y")),Cf.domain(Rb(L,"y2")),$h.select("."+f.axisX).style("opacity",J?0:1).transition().duration(H).call(Gf),$h.select("."+f.axisY).style("opacity",J?0:1).transition().duration(H).call(Hf),$h.select("."+f.axisY2).style("opacity",J?0:1).transition().duration(H).call(If),B=ie(I),D=je(I,!0),E=je(I,!1),$h.select("."+f.axisX+" ."+f.axisXLabel).attr("x",lb),$h.select("."+f.axisY+" ."+f.axisYLabel).attr("x",mb).attr("dy",sb),$h.select("."+f.axisY2+" ."+f.axisY2Label).attr("x",nb).attr("dy",tb),Ef.domain(Bf.domain()),Ff.domain(Cf.domain()),bi.style("display","none"),$h.select("line."+f.xgridFocus).style("visibility","hidden"),Qg){if("year"===Rg){e=[];for(var M=Wb(),N=M[0].getFullYear(),O=M[1].getFullYear(),P=N;O>=P;P++)e.push(new Date(P+"-01-01 00:00:00"))}else e=Af.t