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.

3 lines
64 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(a){var b=a!==!1?250:0;xi.attr("transform",ii.main),xi.select("."+f.axisX).transition().duration(b).attr("transform",ii.x),xi.select("."+f.axisY).transition().duration(b).attr("transform",ii.y),xi.select("."+f.axisY2).attr("transform",ii.y2),xi.select("."+f.chartArcs).attr("transform",ii.arc)}function k(){xg&&(yi.attr("transform",ii.context),yi.select("."+f.axisX).attr("transform",ii.subx))}function l(a){var b=a!==!1?250:0;zi.transition().duration(b).attr("transform",ii.legend)}function m(a){j(a),k(a),l(a)}function n(){var a=Q(),b=P();zf=r(),Af=s(),sf={top:Eg?w("y2"):pi,right:u(),bottom:w(Eg?"y":"x")+(Eg?0:yg)+(ji?0:a),left:(Eg?yg+oi:0)+t()},vf=zf-sf.left-sf.right,xf=Af-sf.top-sf.bottom,0>vf&&(vf=0),0>xf&&(xf=0),tf={top:Eg?sf.top:Af-yg-(ji?0:a),right:0/0,bottom:20+(ji?0:a),left:Eg?ni:sf.left},wf=Eg?sf.left-ni-oi:vf,yf=Eg?xf:Af-tf.top-tf.bottom,0>wf&&(wf=0),0>yf&&(yf=0),uf={top:ji?0:Af-a,right:0/0,bottom:0,left:ji?zf-b:0},p(),ji&&Rd(ef.data.targets)&&(uf.left=vf/2+Cf)}function o(){xi.select("line."+f.xgridFocus).attr("x1",Eg?0:-10).attr("x2",Eg?vf:-10).attr("y1",Eg?-10:sf.top).attr("y2",Eg?-10:xf)}function p(){Cf=xf/2,Bf=.95*Cf,Df=Qd(ef.data.targets)?.6*Bf:0}function q(){var a=Eg?f.axisX:f.axisY,b=df.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=df.select(gf).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return hf?hf:x()}function s(){var a=jf?jf:y();return a>0?a:320}function t(){return Rd(ef.data.targets)?0:kf?kf:Eg||!Rg||Wg?1:v("y")}function u(){var a=1;return Rd(ef.data.targets)?0:lf?lf:ji?P()+($g&&!Eg?v("y2"):a):$g?dh||Eg?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||Rg?"y2"!==a||$g?(gb(a).isInner?30:40)+("y2"===a?-10:0):pi:Ag&&!ji?10:1}function x(){return+df.select(gf).style("width").replace("px","")}function y(){return+df.select(gf).style("height").replace("px","")}function z(a){return a?-5:-(sf.left-1)}function A(a){return a?-20:-1}function B(){return z(!Eg)}function C(){return A(!Eg)}function D(){return z(Eg)}function E(){return A(Eg)}function F(a){return a?vf+2+4:sf.left+20}function G(a){return a?80:xf+2}function H(){return F(!Eg)}function I(){return G(!Eg)}function J(){return F(Eg)}function K(){return G(E
}Ai.html(Kh(ef.data.targets.map(function(a){return jc(a.values[Mh])}),$(),kd,ai)),Ai.style("top",Nh.top).style("left",Nh.left).style("display","block")}null==a.onresize&&(a.onresize=Ne()),a.onresize.add&&a.onresize.add(function(){Pe({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})})}function Ee(a){a.append("rect").attr("class",$c).style("cursor",mg&&ng?"pointer":null).on("mouseover",function(a,b){if(!Yh&&!Rd(ef.data.targets)){var c,d,e=ef.data.targets.map(function(a){return jc(a.values[b])});if(Object.keys(cg).length>0){d=[];for(var g in cg)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}qh&&se(b),ve(b),xi.selectAll("."+f.shape+"-"+b).each(function(a){rg(a)})}}).on("mouseout",function(a,b){Rd(ef.data.targets)||(Dd(),Bd(),te(b),we(),xi.selectAll("."+f.shape+"-"+b).each(function(a){sg(a)}))}).on("mousemove",function(a,b){var c;Yh||Rd(ef.data.targets)||(c=Bc(ef.data.targets).map(function(a){return jc(a.values[b])}),Ad(c,df.mouse(this)),Cd(c),mg&&(ng||xi.selectAll("."+f.shape+"-"+b).filter(function(a){return og(a)}).each(function(){var a=df.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",rh),vi.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?ce(this,sh):"path"===this.nodeName?de(this):void 0}).each(function(){var a=df.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",sh)),vi.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Rd(ef.data.targets)?void 0:Zh?void(Zh=!1):void xi.selectAll("."+f.shape+"-"+b).each(function(a){Ge(this,a,b)})}).call(df.behavior.drag().origin(Object).on("drag",function(){He(df.mouse(this))}).on("dragstart",function(){Ie(df.mouse(this))}).on("dragend",function(){Je()})).call(ui).on("dblclick.zoom",null)}function Fe(a){a.append("rect").attr("x",0).attr("y",0).attr("width",vf).attr("height",xf).attr("class",f.eventRect).on("mouseout",function(){Rd(ef.data.targets)||(Dd(),Bd(),te())}).on("mousemove",function(){var a,b,c,d;Yh||Rd(ef.data.targets)||(a=df.mouse(this),b=td(ef.data.targets,a),c=vd(ef.data.targets,b.x),d=c.map(function(a){return jc(a)}),Ad(d,a),qh&&(te(),se(b.index,b.id)),Cd(d),ie(b,a)<100?(vi.select("."+f.eventRect).style("cursor","pointer"),$h||(rg(b),$h=!0)):(vi.select("."+f.eventRect).style("cursor",null),sg(b),$h=!1))}).on("click",function(){var a,b;Rd(ef.data.targets)||(a=df.mouse(this),b=td(ef.data.targets,a),ie(b,a)<100&&xi.select("."+f.circles+"-"+_c(b.id)).select("."+f.circle+"-"+b.index).each(function(){Ge(this,b,b.index)}))}).call(df.behavior.drag().origin(Object).on("drag",function(){He(df.mouse(this))}).on("dragstart",function(){Ie(df.mouse(this))}).on("dragend",function(){Je()})).call(ui).on("dblclick.zoom",null)}function Ge(a,b,c){var d,e=df.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=ce(a,1.5*sh),d=me):"path"===a.nodeName&&(h=de(a),d=pe),(ng||h)&&(mg&&og(b)&&(pg||xi.selectAll("."+f.shapes+(ng?_c(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=df.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)),qg(b,a))}function He(a){var b,c,d,e,g,h,i,j;Rd(ef.data.targets)||mg&&(!mf||ui.altDomain)&&pg&&(b=Xh[0],c=Xh[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=ng?sf.top:Math.min(c,e),j=ng?xf:Math.max(c,e),xi.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),xi.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return og(a)}).each(function(a,b){var c,d,e,k,l,m,n=df.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=me,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=wd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=pe,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 Ie(a){Rd(ef.data.targets)||mg&&(Xh=a,xi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Yh=!0,vg())}functi
},ef.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Tg=+a.y),b(a.y2)&&(ah=+a.y2)):Tg=ah=+a,Ke())},ef.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&ef.axis.max(a.max),"undefined"!=typeof a.min&&ef.axis.min(a.min))},ef.legend.show=function(a){Ag||(Ag=!0,zi.style("visibility","visible")),Ye(wc(a)),Ke({withTransitionForHorizontalAxis:!1})},ef.legend.hide=function(a){Ag&&fe(a)&&(Ag=!1,zi.style("visibility","hidden")),Ze(wc(a)),Ke({withTransitionForHorizontalAxis:!1})},ef.resize=function(a){hf=a?a.width:null,jf=a?a.height:null,Pe({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},ef.destroy=function(){ef.data.targets=void 0,ef.data.x={},Bi.html(""),a.onresize=null},"url"in e.data)df.csv(e.data.url,function(a,b){De(b)});else if("rows"in e.data)De(nc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");De(oc(e.data.columns))}return ef},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window);