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
68 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.33"},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",eventRectsSingle:"c3-event-rects-single",eventRectsMultiple:"c3-event-rects-multiple",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",legendItemHidden:"c3-legend-item-hidden",legendItemFocused:"c3-legend-item-focused",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)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(a,b){var c,d,e;b&&b.axisX?c=b.axisX:(c=gj.select("."+f.axisX),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=gj.select("."+f.axisY),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=gj.select("."+f.axisY2),a&&(e=e.transition())),gj.attr("transform",Si.main),c.attr("transform",Si.x),d.attr("transform",Si.y),e.attr("transform",Si.y2),gj.select("."+f.chartArcs).attr("transform",Si.arc)}function k(a,b){var c;b&&b.axisSubX?c=b.axisSubX:(c=hj.select("."+f.axisX),a&&(c=c.transition())),hj.attr("transform",Si.context),c.attr("transform",Si.subx)}function l(a){(a?ij.transition():ij).attr("transform",Si.legend)}function m(a,b){j(a,b),Ug&&k(a,b),l(a)}function n(){var a=Q(),b=P(),c=Ti?0:a,d=bh?0:w("x"),e=Ug?Vg+d:0;Uf=r(),Vf=s(),bh?(Nf={top:w("y2"),right:u(),bottom:w("y")+c,left:e+t()},Of={top:Nf.top,right:0/0,bottom:20+c,left:Yi}):(Nf={top:4,right:u(),bottom:d+e+c,left:t()},Of={top:Vf-e-c,right:0/0,bottom:d+c,left:Nf.left}),Pf={top:Ti?0:Vf-a,right:0/0,bottom:0,left:Ti?Uf-b:0},Qf=Uf-Nf.left-Nf.right,Sf=Vf-Nf.top-Nf.bottom,0>Qf&&(Qf=0),0>Sf&&(Sf=0),Rf=bh?Nf.left-Yi-Zi:Qf,Tf=bh?Sf:Vf-Of.top-Of.bottom,0>Rf&&(Rf=0),0>Tf&&(Tf=0),p(),Ti&&ee(yf.data.targets)&&(Pf.left=Qf/2+Xf)}function o(){gj.select("line."+f.xgridFocus).attr("x1",bh?0:-10).attr("x2",bh?Qf:-10).attr("y1",bh?-10:Nf.top).attr("y2",bh?-10:Sf)}function p(){Xf=Sf/2,Wf=.95*Xf,Yf=de(yf.data.targets)?.6*Wf:0}function q(){var a=bh?f.axisX:f.axisY,b=gj.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=xf.select(Af).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return Bf?Bf:x()}function s(){var a=Cf?Cf:y();return a>0?a:320}function t(){return ee(yf.data.targets)?0:Df?Df:bh?ch?v("x"):1:!uh||zh?1:v("y")}function u(){var a=1;return ee(yf.data.targets)?0:Ef?Ef:Ti?P()+(Dh&&!bh?v("y2"):a):Dh?Ih||bh?a:v("y2"):a}function v(a){var b=jb(a);return b.isInner?20+Cb(a):40+Cb(a)}function w(a){return"x"!==a||ch?"x"===a&&rh?rh:"y"!==a||uh?"y2"!==a||Dh?(jb(a).isInner?30:40)+("y2"===a?-10:0):$i:Xg&&!Ti?10:1:0}function x(){return+xf.select(Af).style("width").replace("px","")}function y(){return+xf.select(Af).style("height").replace("px","")
}jj.html(qi(yf.data.targets.map(function(a){return pc(a.values[si])}),$(),wd(ee(yf.data.targets)),Ji)),jj.style("top",ti.top).style("left",ti.left).style("display","block")}null==a.onresize&&(a.onresize=ef()),a.onresize.add&&(a.onresize.add(Kf),a.onresize.add(function(){gf({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})}),a.onresize.add(Lf))}function Xe(a){a.append("rect").attr("class",fd).style("cursor",Jg&&Kg?"pointer":null).on("mouseover",function(a,b){if(!Ei&&!ee(yf.data.targets)){var c,d,e=yf.data.targets.map(function(a){return pc(a.values[b])});if(Object.keys(xg).length>0){d=[];for(var g in xg)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}Vh&&Le(b),Oe(b),gj.selectAll("."+f.shape+"-"+b).each(function(a){Og(a)})}}).on("mouseout",function(a,b){ee(yf.data.targets)||(Sd(),Qd(),Me(b),Pe(),gj.selectAll("."+f.shape+"-"+b).each(function(a){Pg(a)}))}).on("mousemove",function(a,b){var c;Ei||ee(yf.data.targets)||(c=Ic(yf.data.targets).map(function(a){return pc(a.values[b])}),Pd(c,xf.mouse(this)),Rd(c),Jg&&(Kg||gj.selectAll("."+f.shape+"-"+b).filter(function(a){return Lg(a)}).each(function(){var a=xf.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",Ie),ej.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(a){return"circle"===this.nodeName?se(this,Je(a)):"path"===this.nodeName?te(this):void 0}).each(function(){var a=xf.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",Je)),ej.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return ee(yf.data.targets)?void 0:Fi?void(Fi=!1):void gj.selectAll("."+f.shape+"-"+b).each(function(a){Ze(this,a,b)})}).call(xf.behavior.drag().origin(Object).on("drag",function(){$e(xf.mouse(this))}).on("dragstart",function(){_e(xf.mouse(this))}).on("dragend",function(){af()})).call(dj).on("dblclick.zoom",null)}function Ye(a){a.append("rect").attr("x",0).attr("y",0).attr("width",Qf).attr("height",Sf).attr("class",f.eventRect).on("mouseout",function(){ee(yf.data.targets)||(Sd(),Qd(),Me())}).on("mousemove",function(){var a,b,c,d,e=Ic(yf.data.targets);Ei||ee(e)||(a=xf.mouse(this),b=Id(e,a),b&&(c=ie(b)?[b]:Kd(e,b.x),d=c.map(function(a){return pc(a)}),Pd(d,a),Vh&&(Me(),Le(b.index,b.id)),Rd(d),ye(b,a)<100?(ej.select("."+f.eventRect).style("cursor","pointer"),Gi||(Og(b),Gi=!0)):(ej.select("."+f.eventRect).style("cursor",null),Pg(b),Gi=!1)))}).on("click",function(){var a,b,c=Ic(yf.data.targets);ee(c)||(a=xf.mouse(this),b=Id(c,a),b&&ye(b,a)<100&&gj.select("."+f.circles+"-"+ld(b.id)).select("."+f.circle+"-"+b.index).each(function(){Ze(this,b,b.index)}))}).call(xf.behavior.drag().origin(Object).on("drag",function(){$e(xf.mouse(this))}).on("dragstart",function(){_e(xf.mouse(this))}).on("dragend",function(){af()})).call(dj).on("dblclick.zoom",null)}function Ze(a,b,c){var d,e=xf.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=se(a,1.5*Je(b)),d=Ce):"path"===a.nodeName&&(h=te(a),d=Fe),(Kg||h)&&(Jg&&Lg(b)&&(Mg||gj.selectAll("."+f.shapes+(Kg?ld(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=xf.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)),Ng(b,a))}function $e(a){var b,c,d,e,g,h,i,j;ee(yf.data.targets)||Jg&&(!Ff||dj.altDomain)&&Mg&&(b=Di[0],c=Di[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=Kg?Nf.top:Math.min(c,e),j=Kg?Sf:Math.max(c,e),gj.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),gj.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return Lg(a)}).each(function(a,b){var c,d,e,k,l,m,n=xf.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=Ld(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 _e(a){ee(yf.data.targets)||Jg&&(Di=a,gj.select("."+f.chart).append("rect").att
},yf.toPie=function(a){wf(a,"pie",{withTransform:!0})},yf.toDonut=function(a){wf(a,"donut",{withTransform:!0})},yf.groups=function(a){return c(a)?zg:(zg=a,bf(),zg)},yf.xgrids=function(a){return a?(Oh=a,bf(),Oh):Oh},yf.xgrids.add=function(a){return a?yf.xgrids(Oh.concat(a)):void 0},yf.xgrids.remove=function(a){var b=vf(a);return yf.xgrids(Oh.filter(b))},yf.ygrids=function(a){return a?(Qh=a,bf(),Qh):Qh},yf.ygrids.add=function(a){return a?yf.ygrids(Qh.concat(a)):void 0},yf.ygrids.remove=function(a){var b=vf(a);return yf.ygrids(Qh.filter(b))},yf.regions=function(a){return c(a)?mi:(mi=a,bf(),mi)},yf.regions.add=function(a){return c(a)?mi:(mi=mi.concat(a),bf(),mi)},yf.regions.remove=function(a,c){var e=[].concat(a);return c=d(c)?c:{},e.forEach(function(a){var d=b(c.duration)?c.duration:0;ej.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),mi=mi.filter(function(b){return b.classes.indexOf(a)<0})}),mi},yf.data.get=function(a){var b=yf.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},yf.data.getAsTarget=function(a){var b=Fc(function(b){return b.id===a});return b.length>0?b[0]:void 0},yf.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){xg[b]=a[b]}),sf(Cc(yf.data.targets),{withTransition:!0}),xg):xg},yf.x=function(a){return arguments.length&&(qc(yf.data.targets,a),bf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),yf.data.xs},yf.xs=function(a){return arguments.length&&(rc(yf.data.targets,a),bf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),yf.data.xs},yf.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Db())},yf.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(vh=+a.y),b(a.y2)&&(Eh=+a.y2)):vh=Eh=+a,bf())},yf.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(wh=+a.y),b(a.y2)&&(Fh=+a.y2)):wh=Fh=+a,bf())},yf.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&yf.axis.max(a.max),"undefined"!=typeof a.min&&yf.axis.min(a.min))},yf.legend.show=function(a){qf(Dc(a)),bf({withLegend:!0})},yf.legend.hide=function(a){rf(Dc(a)),bf({withLegend:!0})},yf.resize=function(a){Bf=a?a.width:null,Cf=a?a.height:null,gf({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},yf.destroy=function(){yf.data.targets=void 0,yf.data.xs={},kj.html(""),a.onresize=null},"url"in e.data)xf.xhr(e.data.url,function(a,b){var c,d=xf.csv.parseRows(b.response);1===d.length?(c=[{}],d[0].forEach(function(a){c[0][a]=null})):c=xf.csv.parse(b.response),We(c)});else if("rows"in e.data)We(tc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");We(uc(e.data.columns))}return yf},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window);