UNPKG

pivottable

Version:

Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop

3 lines (2 loc) 2.56 kB
(function(){var t;(t=function(t){return"object"==typeof exports&&"object"==typeof module?t(require("jquery"),require("plotly.js")):"function"==typeof define&&define.amd?define(["jquery","plotly.js"],t):t(jQuery,Plotly)})(function(t,e){var o,n;return o=function(o,n,r){return null==o&&(o={}),null==n&&(n={}),null==r&&(r=!1),function(i,l){var a,s,d,p,h,u,y,g,c,v,j,f,b;return p={localeStrings:{vs:"vs",by:"by"},plotly:{}},l=t.extend(!0,{},p,l),j=i.getRowKeys(),a=i.getColKeys(),b=r?a:j,0===b.length&&b.push([]),d=r?j:a,0===d.length&&d.push([]),h=i.aggregatorName,i.valAttrs.length&&(h+="("+i.valAttrs.join(", ")+")"),s=b.map(function(e){var n,l,a,s,p,u,y;for(y=[],a=[],l=0,s=d.length;l<s;l++)n=d[l],u=parseFloat(i.getAggregator(r?n:e,r?e:n).value()),y.push(isFinite(u)?u:null),a.push(n.join("-")||" ");return p={name:e.join("-")||h},p.x=r?y:a,p.y=r?a:y,t.extend(p,o)}),r?(y=i.rowAttrs.join("-"),u=i.colAttrs.join("-")):(y=i.colAttrs.join("-"),u=i.rowAttrs.join("-")),f=h,""!==y&&(f+=" "+l.localeStrings.vs+" "+y),""!==u&&(f+=" "+l.localeStrings.by+" "+u),g={title:f,hovermode:"closest",width:window.innerWidth/1.4,height:window.innerHeight/1.4-50},r?g.xaxis={domain:[.1,1],title:h}:g.yaxis={title:h},c=t("<div>",{style:"display:none;"}).appendTo(t("body")),v=t("<div>").appendTo(c),e.plot(v[0],s,t.extend(g,n,l.plotly)),v.detach(),c.remove(),v}},n=function(){return function(o,n){var r,i,l,a,s,d,p,h,u,y,g,c,v,j;for(a={localeStrings:{vs:"vs",by:"by"},plotly:{}},n=t.extend(!0,{},a,n),v=o.getRowKeys(),0===v.length&&v.push([]),i=o.getColKeys(),0===i.length&&i.push([]),l={x:[],y:[],text:[],type:"scatter",mode:"markers"},s=0,h=v.length;s<h;s++)for(c=v[s],d=0,u=i.length;d<u;d++)r=i[d],j=o.getAggregator(c,r).value(),null!=j&&(l.x.push(r.join("-")),l.y.push(c.join("-")),l.text.push(j));return p={title:o.rowAttrs.join("-")+" vs "+o.colAttrs.join("-"),hovermode:"closest",xaxis:{title:o.colAttrs.join("-"),domain:[.1,1]},yaxis:{title:o.rowAttrs.join("-")},width:window.innerWidth/1.5,height:window.innerHeight/1.4-50},y=t("<div>",{style:"display:none;"}).appendTo(t("body")),g=t("<div>").appendTo(y),e.plot(g[0],[l],t.extend(p,n.plotly)),g.detach(),y.remove(),g}},t.pivotUtilities.plotly_renderers={"Horizontal Bar Chart":o({type:"bar",orientation:"h"},{barmode:"group"},!0),"Horizontal Stacked Bar Chart":o({type:"bar",orientation:"h"},{barmode:"stack"},!0),"Bar Chart":o({type:"bar"},{barmode:"group"}),"Stacked Bar Chart":o({type:"bar"},{barmode:"stack"}),"Line Chart":o(),"Scatter Chart":n()}})}).call(this); //# sourceMappingURL=plotly_renderers.min.js.map