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

!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(){fi.attr("transform",Sh.main),fi.select("."+f.axisX).attr("transform",Sh.x),fi.select("."+f.axisY).attr("transform",Sh.y),fi.select("."+f.axisY2).attr("transform",Sh.y2),fi.select("."+f.chartArcs).attr("transform",Sh.arc)}function k(){jg&&(gi.attr("transform",Sh.context),gi.select("."+f.axisX).attr("transform",Sh.subx))}function l(a){var b=a!==!1?250:0;mg&&hi.transition().duration(b).attr("transform",Sh.legend)}function m(a){j(a),k(a),l(a)}function n(){kf=q(),lf=r(),mf=P(),nf=O(),cf={top:qg?v("y2"):Zh,right:t(),bottom:v(qg?"y":"x")+(qg?0:kg)+(Th?0:mf),left:(qg?kg+Yh:0)+s()},ff=kf-cf.left-cf.right,hf=lf-cf.top-cf.bottom,0>ff&&(ff=0),0>hf&&(hf=0),df={top:qg?cf.top:lf-kg-(Th?0:mf),right:0/0,bottom:20+(Th?0:mf),left:qg?Xh:cf.left},gf=qg?cf.left-Xh-Yh:ff,jf=qg?hf:lf-df.top-df.bottom,0>gf&&(gf=0),0>jf&&(jf=0),ef={top:Th?0:lf-mf,right:0/0,bottom:0,left:Th?kf-nf:0},o(),Th&&Gd(Re.data.targets)&&(ef.left=ff/2+pf)}function o(){pf=hf/2,of=.95*pf,qf=Fd(Re.data.targets)?.6*of:0}function p(){var a=qg?f.axisX:f.axisY,b=Qe.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Qe.select(Te).node().getBoundingClientRect(),e=c.right-d.left-s();return e>0?e:0}function q(){return Ue?Ue:w()}function r(){var a=Ve?Ve:x();return a>0?a:320}function s(){return Gd(Re.data.targets)?0:We?We:qg||!Bg||Gg?1:u("y")}function t(){var a=1;return Gd(Re.data.targets)?0:Xe?Xe:Th?nf+(Kg&&!qg?u("y2"):a):Kg?Pg||qg?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||Bg?"y2"!==a||Kg?(gb(a).isInner?30:40)+("y2"===a?-10:0):Zh:mg&&!Th?10:1}function w(){return+Qe.select(Te).style("width").replace("px","")}function x(){return+Qe.select(Te).style("height").replace("px","")}function y(a){return a?-5:-(cf.left-1)}function z(a){return a?-20:-1}function A(){return y(!qg)}function B(){return z(!qg)}function C(){return y(qg)}function D(){return z(qg)}function E(a){return a?ff+2+4:cf.left+20}function F(a){return a?80:hf+2}function G(){return E(!qg)}function H(){return F(!qg)}function I(){return E(qg)}function J(){return F(qg)}function K(){var a=qg?hf:ff,b=sc(),c=Ub()*(Cd(Re.data.targets)?(b-(Fh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function L(a){Uh=a}function M(a){Vh=a}function N(a){Wh=a}function O(){return mg?Th?Vh*(Uh+1)
a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",ch)),di.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Gd(Re.data.targets)?void 0:Jh?void(Jh=!1):void fi.selectAll("."+f.shape+"-"+b).each(function(a){ue(this,a,b)})}).call(Qe.behavior.drag().origin(Object).on("drag",function(){ve(Qe.mouse(this))}).on("dragstart",function(){we(Qe.mouse(this))}).on("dragend",function(){xe()})).call(ci).on("dblclick.zoom",null)}function te(a){a.append("rect").attr("x",0).attr("y",0).attr("width",ff).attr("height",hf).attr("class",f.eventRect).on("mouseout",function(){Gd(Re.data.targets)||(sd(),qd(),he())}).on("mousemove",function(){var a,b,c;Ih||Gd(Re.data.targets)||(a=Qe.mouse(this),b=jd(Re.data.targets,a),c=[ic(b)],pd(c,a),ah&&(he(),ge(b.index,b.id)),rd(c),Yd(b,a)<100?(di.select("."+f.eventRect).style("cursor","pointer"),Kh||(dg(b),Kh=!0)):(di.select("."+f.eventRect).style("cursor",null),eg(b),Kh=!1))}).on("click",function(){var a,b;Gd(Re.data.targets)||(a=Qe.mouse(this),b=jd(Re.data.targets,a),Yd(b,a)<100&&fi.select("."+f.circles+"-"+Uc(b.id)).select("."+f.circle+"-"+b.index).each(function(){ue(this,b,b.index)}))}).call(Qe.behavior.drag().origin(Object).on("drag",function(){ve(Qe.mouse(this))}).on("dragstart",function(){we(Qe.mouse(this))}).on("dragend",function(){xe()})).call(ci).on("dblclick.zoom",null)}function ue(a,b,c){var d,e=Qe.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=Td(a,1.5*ch),d=ae):"path"===a.nodeName&&(h=Ud(a),d=de),(_f||h)&&($f&&ag(b)&&(bg||fi.selectAll("."+f.shapes+(_f?Uc(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Qe.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)),cg(b,a))}function ve(a){var b,c,d,e,g,h,i,j;Gd(Re.data.targets)||$f&&(!Ye||ci.altDomain)&&bg&&(b=Hh[0],c=Hh[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=_f?cf.top:Math.min(c,e),j=_f?hf:Math.max(c,e),fi.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),fi.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return ag(a)}).each(function(a,b){var c,d,e,k,l,m,n=Qe.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=ae,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=ld(this),c=m.x,d=m.y,e=m.width,k=m.height,l=de,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 we(a){Gd(Re.data.targets)||$f&&(Hh=a,fi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Ih=!0,hg())}function xe(){Gd(Re.data.targets)||$f&&(fi.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),fi.selectAll("."+f.shape).classed(f.INCLUDED,!1),Ih=!1,ig())}function ye(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=vd(),J=Gd(Re.data.targets),L=yc(Re.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?bf:0,G=d(a.durationForExit)?a.durationForExit:F,H=d(a.durationForAxis)?a.durationForAxis:F,A&&mg&&Me(Re.data.targets,a),z&&(Df.domain(Qe.extent(Yb(L))),ki=Df.domain(),Ye&&ci.scale(Df).updateScaleExtent(),Gf.domain(Df.domain()),$h.scale(Gf)),y&&(Df.domain($h.empty()?ki:$h.extent()),Ye&&ci.scale(Df).updateScaleExtent()),Ef.domain(Tb(L,"y")),Ff.domain(Tb(L,"y2")),fi.select("."+f.axisX).style("opacity",J?0:1).transition().duration(H).call(Jf),fi.select("."+f.axisY).style("opacity",J?0:1).transition().duration(H).call(Kf),fi.select("."+f.axisY2).style("opacity",J?0:1).transition().duration(H).call(Lf),B=le(I),D=me(I,!0),E=me(I,!1),fi.select("."+f.axisX+" ."+f.axisXLabel).attr("x",nb).text(hb),fi.select("."+f.axisY+" ."+f.axisYLabel).attr("x",ob).attr("dy",ub).text(ib),fi.select("."+f.axisY2+" ."+f.axis