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
62 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(){oi.attr("transform",_h.main),oi.select("."+f.axisX).attr("transform",_h.x),oi.select("."+f.axisY).attr("transform",_h.y),oi.select("."+f.axisY2).attr("transform",_h.y2),oi.select("."+f.chartArcs).attr("transform",_h.arc)}function k(){pg&&(pi.attr("transform",_h.context),pi.select("."+f.axisX).attr("transform",_h.subx))}function l(a){var b=a!==!1?250:0;sg&&qi.transition().duration(b).attr("transform",_h.legend)}function m(a){j(a),k(a),l(a)}function n(){pf=r(),qf=s(),rf=Q(),sf=P(),hf={top:wg?w("y2"):gi,right:u(),bottom:w(wg?"y":"x")+(wg?0:qg)+(ai?0:rf),left:(wg?qg+fi:0)+t()},lf=pf-hf.left-hf.right,nf=qf-hf.top-hf.bottom,0>lf&&(lf=0),0>nf&&(nf=0),jf={top:wg?hf.top:qf-qg-(ai?0:rf),right:0/0,bottom:20+(ai?0:rf),left:wg?ei:hf.left},mf=wg?hf.left-ei-fi:lf,of=wg?nf:qf-jf.top-jf.bottom,0>mf&&(mf=0),0>of&&(of=0),kf={top:ai?0:qf-rf,right:0/0,bottom:0,left:ai?pf-sf:0},p(),ai&&Kd(We.data.targets)&&(kf.left=lf/2+uf)}function o(){oi.select("line."+f.xgridFocus).attr("x1",wg?0:-10).attr("x2",wg?lf:-10).attr("y1",wg?-10:hf.top).attr("y2",wg?-10:nf)}function p(){uf=nf/2,tf=.95*uf,vf=Jd(We.data.targets)?.6*tf:0}function q(){var a=wg?f.axisX:f.axisY,b=Ve.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Ve.select(Ye).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return Ze?Ze:x()}function s(){var a=$e?$e:y();return a>0?a:320}function t(){return Kd(We.data.targets)?0:_e?_e:wg||!Jg||Og?1:v("y")}function u(){var a=1;return Kd(We.data.targets)?0:af?af:ai?sf+(Sg&&!wg?v("y2"):a):Sg?Xg||wg?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||Jg?"y2"!==a||Sg?(gb(a).isInner?30:40)+("y2"===a?-10:0):gi:sg&&!ai?10:1}function x(){return+Ve.select(Ye).style("width").replace("px","")}function y(){return+Ve.select(Ye).style("height").replace("px","")}function z(a){return a?-5:-(hf.left-1)}function A(a){return a?-20:-1}function B(){return z(!wg)}function C(){return A(!wg)}function D(){return z(wg)}function E(){return A(wg)}function F(a){return a?lf+2+4:hf.left+20}function G(a){return a?80:nf+2}function H(){return F(!wg)}function I(){return G(!wg)}function J(){return F(wg)}function K(){return G(wg)}function L(){var a=wg?nf:lf,b=tc(),c=Vb()*(Gd(We.data.targets
});if(Object.keys(Wf).length>0){d=[];for(var g in Wf)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}ih&&ke(b),ne(b),oi.selectAll("."+f.shape+"-"+b).each(function(a){jg(a)})}}).on("mouseout",function(a,b){Kd(We.data.targets)||(wd(),ud(),le(b),oe(),oi.selectAll("."+f.shape+"-"+b).each(function(a){kg(a)}))}).on("mousemove",function(a,b){var c;Qh||Kd(We.data.targets)||(c=zc(We.data.targets).map(function(a){return jc(a.values[b])}),td(c,Ve.mouse(this)),vd(c),eg&&(fg||oi.selectAll("."+f.shape+"-"+b).filter(function(a){return gg(a)}).each(function(){var a=Ve.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",jh),mi.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?Xd(this,kh):"path"===this.nodeName?Yd(this):void 0}).each(function(){var a=Ve.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",kh)),mi.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Kd(We.data.targets)?void 0:Rh?void(Rh=!1):void oi.selectAll("."+f.shape+"-"+b).each(function(a){ye(this,a,b)})}).call(Ve.behavior.drag().origin(Object).on("drag",function(){ze(Ve.mouse(this))}).on("dragstart",function(){Ae(Ve.mouse(this))}).on("dragend",function(){Be()})).call(li).on("dblclick.zoom",null)}function xe(a){a.append("rect").attr("x",0).attr("y",0).attr("width",lf).attr("height",nf).attr("class",f.eventRect).on("mouseout",function(){Kd(We.data.targets)||(wd(),ud(),le())}).on("mousemove",function(){var a,b,c,d;Qh||Kd(We.data.targets)||(a=Ve.mouse(this),b=md(We.data.targets,a),c=od(We.data.targets,b.x),d=c.map(function(a){return jc(a)}),td(d,a),ih&&(le(),ke(b.index,b.id)),vd(d),ae(b,a)<100?(mi.select("."+f.eventRect).style("cursor","pointer"),Sh||(jg(b),Sh=!0)):(mi.select("."+f.eventRect).style("cursor",null),kg(b),Sh=!1))}).on("click",function(){var a,b;Kd(We.data.targets)||(a=Ve.mouse(this),b=md(We.data.targets,a),ae(b,a)<100&&oi.select("."+f.circles+"-"+Xc(b.id)).select("."+f.circle+"-"+b.index).each(function(){ye(this,b,b.index)}))}).call(Ve.behavior.drag().origin(Object).on("drag",function(){ze(Ve.mouse(this))}).on("dragstart",function(){Ae(Ve.mouse(this))}).on("dragend",function(){Be()})).call(li).on("dblclick.zoom",null)}function ye(a,b,c){var d,e=Ve.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=Xd(a,1.5*kh),d=ee):"path"===a.nodeName&&(h=Yd(a),d=he),(fg||h)&&(eg&&gg(b)&&(hg||oi.selectAll("."+f.shapes+(fg?Xc(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Ve.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)),ig(b,a))}function ze(a){var b,c,d,e,g,h,i,j;Kd(We.data.targets)||eg&&(!bf||li.altDomain)&&hg&&(b=Ph[0],c=Ph[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=fg?hf.top:Math.min(c,e),j=fg?nf:Math.max(c,e),oi.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),oi.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return gg(a)}).each(function(a,b){var c,d,e,k,l,m,n=Ve.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=ee,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=pd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=he,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 Ae(a){Kd(We.data.targets)||eg&&(Ph=a,oi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Qh=!0,ng())}function Be(){Kd(We.data.targets)||eg&&(oi.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),oi.selectAll("."+f.shape).classed(f.INCLUDED,!1),Qh=!1,og())}function Ce(a){var c,e,g,h,i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P=zd(),Q=Kd(We.data.targets),R=zc(We.data.targets);if(0!==R.length){if(a=d(a)?a:{},v=d(a.withY)?a.withY:!0,w=d(a.withSubchart)?a.withSubchart:!0,x=d(a.withTransition)?a.withTransition:!0,A=d(a.withTransform)?a.withTransform:!1,B=d(a.withUpdateXD