diff --git a/docs/src/linked-charts.min.js b/docs/src/linked-charts.min.js index 993063b..8f3a6c1 100644 --- a/docs/src/linked-charts.min.js +++ b/docs/src/linked-charts.min.js @@ -7,4 +7,4 @@ /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ var saveAs=saveAs||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),c=e.webkitRequestFileSystem,d=e.requestFileSystem||c||e.mozRequestFileSystem,u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",f=0,l=4e4,v=function(e){var t=function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()};setTimeout(t,l)},p=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(i){u(i)}}},w=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e},y=function(t,u,l){l||(t=w(t));var y,m,S,h=this,R=t.type,O=!1,g=function(){p(h,"writestart progress write writeend".split(" "))},b=function(){if(m&&a&&"undefined"!=typeof FileReader){var o=new FileReader;return o.onloadend=function(){var e=o.result;m.location.href="data:attachment/file"+e.slice(e.search(/[,;]/)),h.readyState=h.DONE,g()},o.readAsDataURL(t),void(h.readyState=h.INIT)}if((O||!y)&&(y=n().createObjectURL(t)),m)m.location.href=y;else{var r=e.open(y,"_blank");void 0===r&&a&&(e.location.href=y)}h.readyState=h.DONE,g(),v(y)},E=function(e){return function(){return h.readyState!==h.DONE?e.apply(this,arguments):void 0}},N={create:!0,exclusive:!1};return h.readyState=h.INIT,u||(u="download"),r?(y=n().createObjectURL(t),void setTimeout(function(){o.href=y,o.download=u,i(o),g(),v(y),h.readyState=h.DONE})):(e.chrome&&R&&R!==s&&(S=t.slice||t.webkitSlice,t=S.call(t,0,t.size,s),O=!0),c&&"download"!==u&&(u+=".download"),(R===s||c)&&(m=e),d?(f+=t.size,void d(e.TEMPORARY,f,E(function(e){e.root.getDirectory("saved",N,E(function(e){var n=function(){e.getFile(u,N,E(function(e){e.createWriter(E(function(n){n.onwriteend=function(t){m.location.href=e.toURL(),h.readyState=h.DONE,p(h,"writeend",t),v(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&b()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=h["on"+e]}),n.write(t),h.abort=function(){n.abort(),h.readyState=h.DONE},h.readyState=h.WRITING}),b)}),b)};e.getFile(u,{create:!1},E(function(e){e.remove(),n()}),E(function(e){e.code===e.NOT_FOUND_ERR?n():b()}))}),b)}),b)):void b())},m=y.prototype,S=function(e,t,n){return new y(e,t,n)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return n||(e=w(e)),navigator.msSaveOrOpenBlob(e,t||"download")}:(m.abort=function(){var e=this;e.readyState=e.DONE,p(e,"abort")},m.readyState=m.INIT=0,m.WRITING=1,m.DONE=2,m.error=m.onwritestart=m.onprogress=m.onwrite=m.onabort=m.onerror=m.onwriteend=null,S)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define([],function(){return saveAs}); -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).lc={})}(this,function(t){"use strict";function h(){var n={propList:[],add_property:function(t,e,a){n.propList.push(t);var r="get_"+t;return n[t]=function(t){return void 0===t?n[r]():("function"==typeof a&&(t=a(t)),n[r]="function"==typeof t?t:function(){return t},!n.layers&&n.chart||n)},n[r]="function"==typeof e?e:function(){return e},n},wrapSetter:function(t,e){if("function"!=typeof e)throw"Error in 'wrapSetter': wrapper is not a function.";if(-1==n.propList.indexOf(t))throw"Error in 'wrapSetter': this object doesn't have "+t+" property";var a=n[t];return n[t]=function(){return 0==arguments.length?n["get_"+t]():e(a).apply(n,arguments)},n}};return n}function f(t){var e={};return function(){if("clear"!==arguments[0])return arguments in Object.keys(e)||0==arguments.length&&0!=Object.keys(e).length||(e[arguments]=t.apply(void 0,arguments)),e[arguments];e={}}}function m(t,e){if(t.length!=e.length)throw"Error in getEuclideanDistance: length of theinput vectors is not the same";for(var a=0,r=0;r=r?(t.call(this,e),n.prev_time=d3.now()):n.timer=d3.timeout(t,1.5*r)}};return n}function x(t,r){return"number_nonneg"==t?function(t){if("function"==typeof t)return t;if("number"!=typeof(t=a(+t)?t:+t))throw"Error in 'typeCheck' for property '"+r+"': numeric value is required.";if(0<=t)return t;throw"Error in 'typeCheck' for property '"+r+"': negative values are not allowed."}:"array"==t?function(t){if("function"==typeof t)return t;if(Array.isArray(t))return t;if("object"==typeof t){var e=[];for(el in t){if("string"!=typeof t[el]&&"number"!=typeof t[el])throw"Error in 'typeCheck' for property '"+r+"': the value is not an array.";e.push(t[el])}return e}if("number"==typeof t||"string"==typeof t)return[t];throw"Error in 'typeCheck' for property '"+r+"': the value is not an array."}:"array_fun"==t?function(e){return e&&"object"==typeof e?function(t){return e[t]}:e}:(t="matrix_fun",function(a){if("function"==typeof a)return a;var t;if(a&&"object"==typeof a)return t=Object.keys(a),"object"==typeof a[t[0]]?function(t,e){return a[t][e]}:function(t){return a[t]};throw"Error in 'typeCheck' for property '"+r+"': the value is not an array or an object."})}function a(t){return null==t||"NA"==t||"NaN"==t||"NAN"==t||"na"==t||"Infinity"==t||"Inf"==t}function s(t){function l(){return"default"==c.mode()?2500ID: "+c.get_label(t)},x("array_fun","opacity"));c.propList=c.propList.concat(["updateElementStyle","updateElements","updateElementPosition"]),c.id=t,c.marked=[],c.wrapSetter("nelements",function(t){return function(){return c.get_elementIds=function(){return d3.range(t())},t.apply(c,arguments)}}),c.wrapSetter("elementIds",function(t){return function(){return c.get_nelements=function(){return t().length},t.apply(c,arguments)}}),c.wrapSetter("colour",function(t){return function(){return c.addColourScaleToLegend(!1),t.apply(c,arguments)}}),c.colourDomain(function(){var t=c.elementIds().map(t=>c.get_colourValue(t));if(0!=t.length){if(1==t.length)return void 0===t[0]?[]:t;var e=-1;if("number"==typeof t[1]&&"number"==typeof t[2])for(a=t[1]>t[0]?[t[0],t[1]]:[t[1],t[0]],e=2;et[e]&&(a[0]=t[e]),a[1]!lc.isNaN(t));for(var o=0;o/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t)).length!=t.length&&(t=[d3.min(t),d3.max(t)]),1==l.length&&l.push(l[0]),l.length>t.length){for(var i=[],o=0;o_[t].type).indexOf("colour"))){var n={};if(n.scale="function"==typeof t?t:function(){return t},void 0!==r&&(n.layer=r),-1==["colour","size","symbol","dash"].indexOf(e))throw"Error in 'legend.add_block': "+e+" is not a suitable type of legend block. Please, use one of these: 'colour', 'size', 'symbol', 'dash'";n.type=e,_[a]=n,h.container()&&o()}return h.chart},h.updateScale=function(t,e){if(void 0===_[e])throw"Error in 'legend.updateScale': A block with ID "+e+" is not defined";return _[e].scale=t,h.updateBlock(e),h.chart},h.removeBlock=function(t){if(void 0===_[t])throw"Error in 'legend.remove': block with ID "+t+" doesn't exist";return void 0!==_[t].layer&&_[t].layer.legendBlocks.splice(_[t].layer.legendBlocks.indexOf(t),1),delete _[t],h.legendTable.select("#"+t).remove(),o(),h.chart},h.renameBlock=function(t,e){return _[e]=_[t],delete _[t],void 0!==_[e].layer&&_[e].layer.legendBlocks.splice(_[e].layer.legendBlocks.indexOf(t),1,e),h.legendTable&&(h.legendTable.select("#"+t).attr("id",e),h.updateBlock(e)),h.chart},function(){var a,t=Object.keys(_).length;if(void 0===h.ncol()){for(var e,r=1+t,n=1,o=2;o<=Math.ceil(Math.sqrt(t));o++)o+(e=Math.ceil(t/o))<=r&&(r=o+e,n=o);a=Math.ceil(t/n)}else a=h.ncol(),n=Math.ceil(t/a);for(o in h.legendTable&&h.legendTable.remove(),h.legendTable=h.container().append("table").attr("class","legendTable linked-charts"),h.legendTable.selectAll("tr").data(d3.range(n)).enter().append("tr"),h.legendTable.selectAll("tr").selectAll("td").data(function(e){return d3.range(a).map(function(t){return[e,t]})}).enter().append("td").attr("id",function(t){try{return Object.keys(_)[t[0]*a+t[1]].replace(/[ .]/g,"_")}catch(t){}}),_)h.updateBlock(o)});return h.updateBlock=function(a){if(void 0===_[a])throw"Error in 'legend.updateBlock': block with ID "+a+" is not defined";for(var t,e,r=function(t){var e,a;if("function"!=typeof(e=void 0===(e="function"==typeof _[t].scale?_[t].scale():e)||"function"!=typeof e&&void 0===e.splice?_[t].scale:e)){var r=!1,n=!1;if(1==e.length)throw"Error in 'legend.convertScale': range of the scale is not defined.";2==e[0].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(r=!0),"colour"==_[t].type&&e[0].length!=e[1].length&&(n=!0),2==e[1].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(n=!0),r&&n&&(a=d3.scaleLinear().domain(e[0]).range(e[1]),e.steps?a.steps=e.steps:a.steps=9),r&&!n&&((a=d3.scaleQuantize().domain(e[0]).range(e[1])).steps=e[1].length),!r&&n&&((a=d3.scalePoint().domain(e[0]).range(e[1])).steps=e[0].length),r||n||(e[0].length>e[1].length&&e[0].splice(e[1].length),e[1].length>e[0].length&&e[1].splice(e[0].length),(a=d3.scaleOrdinal().domain(e[0]).range(e[1])).steps=e[0].length),_[t].domain=e[0],void 0===a.domain&&(a.domain=_[t].domain)}else{var o="function"==typeof e.domain?e.domain():e.domain;if(void 0===o)throw"Error in 'legend.convertScale': the domain of the scale is not defined.";for(var l=0;lt),f=[0];n.each(function(){f[0]"+n.innerHTML+"",s.container().selectAll("tr").each(function(t,e){g=0,u=[],d3.select(this).selectAll("td").each(function(t,e){c=d3.select(this).selectAll("svg"),p+=""+c.node().innerHTML+"",u.push(c.attr("height")),g+=+c.attr("width")}),d+=+d3.max(u)}),""+p+""):(new XMLSerializer).serializeToString(n),(n=new Image).onload=function(){l.drawImage(this,0,0),a.canvas&&a.canvas.classed("active")&&l.drawImage(a.canvas.node(),a.paddings().left,a.paddings().top),i()},n.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(p)}function c(t){for(var e,a,r,n,o,l,i=t.svg.node().cloneNode(!0),s=0;s"+i.innerHTML+"",t.legend.container().selectAll("tr").each(function(){e=0,n=[],d3.select(this).selectAll("td").each(function(){r=d3.select(this).selectAll("svg"),o+=""+r.node().innerHTML+"",n.push(r.attr("height")),e+=+r.attr("width")}),a+=+d3.max(n)}),""+o+""):t.svg.attr("xmlns","http://www.w3.org/2000/svg").node().parentNode.innerHTML,l=new Blob([o],{type:"image/svg+xml"}),saveAs(l,"export_"+Date.now()+".svg")):(t.container.append("div").attr("class","hint").attr("id","errMessage").style("left",t.width()/3+"px").style("top",t.height()/3+"px").style("width",t.width()/3+"px").text("Chart in canvas mode cannot be saved as SVG."),setTimeout(function(){t.container.select("#errMessage").remove()},2e3))}function u(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.selectMode(!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.selectMode(!0),(e=t.panel.g.selectAll("#b_pan")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function p(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.pan("mode",!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.pan("mode",!0),(e=t.panel.g.selectAll("#b_selection")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function g(a){var t=a.get_marked(),e=(0==(t=a.layers?Object.keys(a.layers).map(e=>t[e].map(t=>[e,t])).flat():t).length&&(t=a.layers?Object.keys(a.layers).map(e=>a.get_layer(e).elementIds().map(t=>[e,t])).flat():a.elementIds()),{x:[],y:[]}),r=(t.map(function(t){t=a.get_position(t);t&&(e.x.push(t[0]),e.y.push(t[1]))}),d3.extent(e.x)),n=d3.extent(e.y);a.zoom([r[0],n[0]],[r[1],n[1]])}function n(){function t(r){return function(){var e;if(u["get_singleScale"+r]()){var t=!0;for(a in u.layers)t=t&&u.get_layer(a)["get_contScale"+r]();if(t)for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(void 0===e?e=u.get_layer(a)["get_layerDomain"+r]():(e[0]=d3.min([e[0],u.get_layer(a)["get_layerDomain"+r]()[0]]),e[1]=d3.max([e[1],u.get_layer(a)["get_layerDomain"+r]()[1]])));else for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(e=void 0===e?u.get_layer(a)["get_layerDomain"+r]():e.concat(u.get_layer(a)["get_layerDomain"+r]().filter(function(t){return e.indexOf(t)<0})))}return void 0===e&&(e=[0,1]),t&&(u["logScale"+r]()?(e[1]=2*e[1],e[0]=e[0]/2):(e[1]=e[1]+.03*(e[1]-e[0]),e[0]=e[0]-.03*(e[1]-e[0]))),e}}var u=r(),e=(u.add_property("singleScaleX",!0).add_property("singleScaleY",!0).add_property("domainX",void 0,x("array","domainX")).add_property("domainY",void 0,x("array","domainY")).add_property("aspectRatio",void 0,x("number_nonneg","aspectRatio")).add_property("axisTitleX","").add_property("axisTitleY","").add_property("axisTitlePos",{x:{across:"up",along:"end"},y:{across:"up",along:"end"}},function(t){var e={x:{across:"up",along:"end"},y:{across:"up",along:"end"}};if(t.x){if(!t.x.split)throw"Error in 'typeCheck' for property 'axisTitlePos': 'x' must be a string.";var a=t.x.split(" ").map(t=>t.toLowerCase());-1t.toLowerCase());-1=t[0]&&a.push(r[n]),n++;0=t[1];)u.axes.scale_y(l[n])<=e[1]&&o.push(l[n]),n++;0=d3.max([0,o-r]);i--)e.unshift(n[i]);for(i=l+1;i=d3.max([0,o-r]);i--)a.unshift(s[i]);for(i=l+1;i":i+=">",i+=a[o][r]+"";l.push(i)}else l=a[1];e.tickFormat=function(t){return l[e.tickValues.indexOf(t)]}}return e}function g(t){var e=u["get_domain"+t]();void 0===u.axes["scale_"+t.toLowerCase()]&&(u.axes["scale_"+t.toLowerCase()]={},u.axes["shiftScale"+t]=d3.scaleLinear().domain([0,1])),2==e.length&&"number"==typeof(e[0]+e[1])?((e=u["logScale"+t]())&&0r.get_on_click(e,t)).on("mouseover",(t,e)=>r.get_on_mouseover(e,t)).on("mouseout",(t,e)=>r.get_on_mouseout(e,t))},r.dresser(function(t){t.attr("stroke",function(t){return r.get_colour(t)}).attr("stroke-width",function(t){return r.get_lineWidth(t)}).attr("stroke-dasharray",function(t){return r.get_dasharray(t)}).attr("opacity",function(t){return r.get_opacity(t)}).attr("fill",function(t){return r.get_fill(t)})}),r.findElements=function(s,d){var t=d3.max([10,2*r.lineWidth()]);return s[0]-d[0]"+i.get_label(t)+";
x = "+e+";
y = "+a}),i.nelements(function(){for(var t,e=0;e<1e5;e++){try{t=i.get_x(e)}catch(t){return 0<=e?e:0}if(void 0===t)return 0<=e?e:0}throw"There seem to be very many data points. Please supply a number via 'nelements'."}),i.get_scaledShiftX=function(){return 0},i.get_scaledShiftY=function(){return 0},i.findElements=function(a,r){return i.elementIds().filter(function(t){var e=[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)];return e[0]-i.get_size(t)-1<=r[0]&&e[1]-i.get_size(t)-1<=r[1]&&e[0]+i.get_size(t)+1>=a[0]&&e[1]+i.get_size(t)+1>=a[1]})},i.get_position=function(t){return[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)]},i.layerDomainX(function(){var t=i.elementIds().map(function(t){return i.get_x(t)}).filter(function(t){return!lc.isNaN(t)}),e=!0,a=0;if(i.chart.logScaleX())return d3.extent(t.filter(function(t){return 0a[1]||i.get_x(t)r[1]||i.get_y(t)r[1]||i.get_y(t)a[1]||i.get_x(t)i.get_on_click(e,t)).on("mouseover",(t,e)=>i.get_on_mouseover(e,t)).on("mouseout",(t,e)=>i.get_on_mouseout(e,t))):i.updateStarted||i.updateCanvas()),l},i.updateCanvas=function(){var t,e,a,r=i.elementIds(),n=i.canvas.node().getContext("2d");n.clearRect(0,0,l.plotWidth(),l.plotHeight());for(var o=0;oi.chart.plotWidth()?(e=i.chart.plotWidth(),t+="-15 "):t+="0 ",a<0?(a=0,t+="15"):a>i.chart.plotHeight()?(a=i.chart.plotHeight(),t+="-15"):t+="0"),n.translate(e,a),t=new Path2D(t),n.stroke(t),n.fill(t),n.translate(-e,-a)},l}function L(t,e){void 0===e&&(e=n()),C(t=void 0===t?"layer"+e.get_nlayers():t,e);var a=e.get_layer(t),r=(a.add_property("valueAxis","y",function(t){if("x"!=t&&"y"!=t&&"function"!=typeof t)throw"Error in 'typeCheck' for 'valueAxis': axis nameshould be 'x' or 'y'";return t}),e.syncProperties(a),a.type="beeswarm",a.updateElementPosition);return a.updateElementPosition=function(){a.valueAxis();var e=d3.beeswarm().data(a.elementIds().filter(function(t){var e="x"==a.valueAxis()?"y":"x";return void 0!==a.chart.axes["scale_"+e](a["get_"+e](t))}).sort(function(t,e){return a["get_"+a.valueAxis()](t)-a["get_"+a.valueAxis()](e)})).distributeOn(function(t){return a.chart.axes["scale_"+a.valueAxis()](a["get_"+a.valueAxis()](t))}).axis(function(t){return"x"==a.valueAxis()?a.chart.axes.scale_y(a.get_y(t)):a.chart.axes.scale_x(a.get_x(t))}).radius(a.size()).arrange();e.res={};for(var t=0;tt,x("array_fun","stackLabel")).add_property("groupLabel",t=>t,x("array_fun","groupLabel")).add_property("barLabel",t=>t,x("array_fun","barLabel")).add_property("value",void 0,function(r){if("function"==typeof r)return r;var n;if("object"==typeof r){r.__inds__&&(n=r.__inds__,r.__inds__=null);var t=Object.keys(r);if("object"==typeof r[t[0]]){var e,a=Object.keys(r[t[0]]);if("object"==typeof r[t[0]][a[0]])return e=Object.keys(r[t[0]][a[0]]),"object"==typeof r[t[0]][a[0]][e[0]]?function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a][0]}:function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a]}}}throw"Error in 'typeCheck' for property 'value': the value is not an array or an object."}).add_property("groupWidth",.6).add_property("stroke","#444").add_property("strokeWidth",0);return s.chart.syncProperties(s),s.type="barchart",s.chart.informText(function(t,e,a){var r=s.get_groupLabel(t),n=s.get_barLabel(e),o=s.get_stackLabel(a);return 1"+r+";
value = "+s.get_value(t,e,a).toFixed(2)}),["group","bar","stack"].forEach(function(e){s.wrapSetter("n"+e+"s",function(t){return function(){return s["get_"+e+"Ids"]=function(){return d3.range(t())},t.apply(s,arguments)}}),s.wrapSetter(e+"Ids",function(t){return function(){return s["get_n"+e+"s"]=function(){return t().length},t.apply(s,arguments)}})}),s.nbars(1),s.nstacks(1),s.contScaleX(!1),s.elementIds(function(){if(void 0===s.groupIds()||0==s.groupIds().length)return[];if(1==s.nbars()&&(0==s.barIds()[0]||1==s.barIds()[0]))return s.stackIds();for(var t=[],e=s.barIds(),a=s.stackIds(),r=0;rs.get_groupLabel(t));return s.contScaleX()?[d3.min(t),d3.max(t)]:t}),s.layerDomainY(function(){for(var t=s.barIds(),e=s.groupIds(),a=s.stackIds(),r=0,n=0;nt&&n[1]<=e+r&&o[1]>e}).data()},s.get_position=function(t){return[s.g.select("#p"+t.join("_")).attr("x"),s.g.select("#p"+t.join("_")).attr("y")]},s.updateElementPosition=function(){var t,e,a,r,n,o;return void 0!==s.groupIds()&&(t=s.groupIds().map(t=>s.get_groupLabel(t)),e=(t=s.contScaleX()?Math.abs(s.chart.axes.scale_x(t[1])-s.chart.axes.scale_x(t[0]))*s.groupWidth():s.chart.axes.scale_x.step()*s.groupWidth())/s.nbars(),a=Math.abs(s.chart.axes.scale_y(1)-s.chart.axes.scale_y(0)),r=d3.scaleLinear().domain([0,s.nbars()-1]).range([-t/2,t/2-e]),n=s.barIds(),o=s.stackIds(),0e&&g.midpoint(e),g.midpoint()-td3.interpolateRdYlBu(1-t),function(e){if("string"==typeof e){if(d3[e])return d3[e];throw"Error in 'typeCheck' for 'palette': invalid palette name, must be one of d3 interpolators (e.g. 'interpolateOrRd')."}if(Array.isArray(e))return e=e.map(t=>/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t),d3.scaleLinear().domain(d3.range(e.length).map(function(t){return t/e.length})).range(e);if("function"==typeof e)return e;throw"Error in 'typeCheck' for 'palette': invalid type. Palette must be a name of a d3 interpolator, an array of colours or a function."}).add_property("colourDomain",function(){return u.dataRange()},x("array","colourDomain")).add_property("clusterRowMetric",m).add_property("clusterColMetric",m).add_property("on_click",function(){}).add_property("rowTitle","").add_property("showValue",!1).add_property("valueTextColour",(t,e)=>{t=d3.hsl(u.get_colour(u.get_value(t,e)));return t.h=(t.h+180)%360,t.s=Math.sqrt(t.s),t.l=1-t.l,t},function(t){if("function"==typeof t)return t;if("string"==typeof t)return t;throw"Error in 'typeCheck' for 'valueTextColour': invalid type. valueTextColour must be a colour name or a function."}).add_property("showInform",!0).add_property("colTitle","").add_property("on_mouseover").add_property("on_mouseout").add_property("on_labelClickRow").add_property("on_labelClickCol").add_property("clusterRows",!1).add_property("clusterCols",!1).add_property("informText",function(t,e){var a=u.get_value(t,e);return"number"==typeof a&&(a=a.toFixed(2)),"Row: "+u.get_rowLabel(t)+";
Col: "+u.get_colLabel(e)+";
value = "+a},x("matrix_fun","value"))).paddings({top:100,left:100,right:10,bottom:40}),u.legend.width(75),["col","row"].forEach(function(a){u.wrapSetter("n"+a+"s",function(t){return function(){return u["get_"+a+"Ids"]=function(){return d3.range(t())},t.apply(u,arguments)}}),u.wrapSetter(a+"Ids",function(e){return function(){u["get_n"+a+"s"]=function(){return e().length};var t=a[0].toUpperCase()+a.slice(1);return e.apply(u,arguments),u["get_disp"+t+"Ids"]=u["get_"+a+"Ids"],u}})}),u.wrapSetter("colour",function(a){return function(){var t=a.apply(u,arguments),e=u.get_colour;return u.get_colour=function(){return 1==arguments.length&&void 0===arguments[0]?"#eee":e.apply(u,arguments)},t}}),["col","row"].forEach(function(t){var a="col"==t?"bottom":"right";u.wrapSetter(t+"Title",function(e){return function(){var t={};return t[a]=d3.max([u.paddings()[a],20]),u.set_paddings(t),e.apply(u,arguments)}})}),u.colour(function(t){return u.colourScale(t)}),u.axes={},u.marked=[],a={Row:u.showDendogramRow(),Col:u.showDendogramCol()},u.showDendogram=function(t,e){return void 0===e?a[t]:(a[t]=e&&u["showDendogram"+t](),u)},u.showDendogram("Row",!1).showDendogram("Col",!1);var a,e=u.put_static_content,i=(u.put_static_content=function(t){e(t),_(u),u.svg.append("g").attr("class","row label_panel"),u.svg.append("g").attr("class","col label_panel"),u.canvas=u.container.append("canvas").style("position","absolute").style("z-index",-5).attr("id","hCanvas"),u.g=u.svg.select(".plotArea").append("g").attr("class","chart_g"),u.text=u.g.append("g").attr("class","text_g"),u.axes.x_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end"),u.axes.y_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end").attr("transform","rotate(-90)"),("svg"==i()?u.g:u.canvas).classed("active",!0),u.svg.select(".clickPanel").on("mouseover",function(){u.container.select(".inform").classed("hidden",!1)}).on("mouseout",function(){u.container.select(".inform").classed("hidden",!0)}),u.showPanel()&&(u.panel.add_button("Zoom in","#zoomIn",function(t){var e=-Math.ceil(.1*t.dispRowIds().length),a=-Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Zoom out","#zoomOut",function(t){var e=Math.ceil(.1*t.dispRowIds().length),a=Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateCellColour(),t.updateLabelText(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Cluster rows","#clusterRows",function(t){t.cluster("Row"),t.showDendogram("Row",!0),t.updateLabelPosition()}),u.panel.add_button("Cluster columns","#clusterCols",function(t){t.cluster("Col"),t.showDendogram("Col",!0),t.updateLabelPosition()}),u.panel.add_button("Restore original order","#restoreOrder",function(t){var a=t.rowIds().slice(),r=t.colIds().slice();t.reorder("Row",function(t,e){return a.indexOf(t)-a.indexOf(e)}),t.reorder("Col",function(t,e){return r.indexOf(t)-r.indexOf(e)}),t.dendogramRow&&t.dendogramRow.remove(),t.dendogramCol&&t.dendogramCol.remove(),t.updateStarted=!0,t.updateLabels().updateLabelPosition().updateLabelText().updateCellColour(),t.updateStarted=!1}))},function(){return"default"==u.mode()?2500a.indexOf(r[i])&&(l=a.indexOf(r[i]));for(i=l-1;i>=d3.max([0,l-t]);i--)r.unshift(a[i])}else{l=-1;for(i=0;i=e[0]&&t[1]+u.cellSize.height>=e[1]}).data();else for(var r=u.svg.select(".col").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[0]&&t<=a[0]+u.cellSize.width}).data(),n=u.svg.select(".row").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[1]&&t<=a[1]+u.cellSize.height}).data(),o=0;ot[1]&&(t[1]=e[1]),++ar(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),e.enter().append("text").attr("class","label plainText").style("text-anchor","end").attr("dx",-2).merge(e).attr("id",function(t){return t.toString().replace(/[ .]/g,"_")}).on("mouseover",(t,e)=>r(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),u.updateCells(),u},u.updateLabelText=function(){var t;return 0u.get_value(r,e[o-1])&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&ou.get_value(e[o-1],r)&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&os(e,t)).on("mouseout",d).on("click",function(t,e){u.get_on_click.apply(this,[e[0],e[1],t])}),u.get_showValue()&&u.updateTexts()}else{for(var a=u.dispRowIds(),r=u.dispColIds(),n=0;nu.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}):u.g.selectAll(".tval").attr("fill",t=>u.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}),u},u.updateCanvas=function(){var t,e,n=u.canvas.node().getContext("2d"),a=(n.clearRect(0,0,u.plotWidth(),u.plotHeight()),u.dispRowIds()),r=u.dispColIds(),o=r.length,l=a.length,i=document.createElement("canvas"),s=(i.width=o,i.height=l,new ImageData(o,l));if(0==u.marked.length)for(var d=0;dt,x("array_fun","label")).add_property("nelements",1,x("number_nonneg","nelements")).add_property("elementIds",[0],x("array","elementIds")).add_property("value",function(){},x("array_fun","value")).add_property("min",0,x("array_fun","min")).add_property("max",100,x("array_fun","max")).add_property("step",1,x("array_fun","step")).add_property("fontSize",17,x("number_nonneg","fontSize")).add_property("ncols",1,x("number_nonneg","ncols")).add_property("nrows",function(){return a.nelements()},x("number_nonneg","nrows")).add_property("on_change",function(){}),e=(a.wrapSetter("nelements",function(t){return function(){return a.get_elementIds=function(){return d3.range(t())},t.apply(a,arguments)}}),a.wrapSetter("elementIds",function(t){return function(){return a.get_nelements=function(){return t().length},t.apply(a,arguments)}}),a.wrapSetter("nrows",function(t){return function(){return a.get_ncols=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.wrapSetter("ncols",function(t){return function(){return a.get_nrows=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.value(t=>{switch(a.type()){case"text":return"";case"button":return t;case"range":case"radio":return;case"checkbox":return!1}}),a.name="n"+Math.random().toString(36).substring(5),a.width(200),a.put_static_content);return a.put_static_content=function(t){return e(t),a.container.style("display","grid").style("grid-template-columns","repeat(auto-fit, fit-content(500px) 1fr fit-content(20px))").style("column-gap","9px").style("align-items","center").append("p").style("grid-row",1).style("grid-column","1/"+(3*a.ncols()+1)).style("text-align","center").style("font-weight","bold").attr("id","title"),a},a.updateTitle=function(){return a.container.select("#title").text(a.title()),a},a.updateElements=function(){var t=a.container.selectAll("input").data(a.elementIds()),e=a.container.selectAll("label").data(a.elementIds());return t.enter().append("input").attr("type",a.type()).attr("name",a.name).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?2:1)).attr("id",t=>a.name+"_in_"+t).property("value",t=>"radio"==a.type()?t:void 0).style("width","text"==a.type()||"range"==a.type()?"100%":void 0).on("button"==a.type()?"click":"change",function(){var t,e;a.get_on_change((t=this,"button"==a.type()||"radio"==a.type()?t.value:"checkbox"==a.type()?d3.select(t.parentNode).selectAll("input").nodes().map(t=>t.checked):(e={},"range"!=a.type()&&"text"!=a.type()||d3.select(t.parentNode).selectAll("input").nodes().forEach(function(t){e[t.id.substring(a.name.length+1)]=+t.value?+t.value:t.value}),e)))}),t.exit().remove(),"button"!=a.type()?(e.exit().remove(),e.enter().append("label").attr("for",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?1:2)).merge(e).text(t=>a.get_label(t)).style("font-size",a.fontSize())):a.container.selectAll("input").style("font-size",a.fontSize()).property("value",t=>a.get_label(t)),"range"==a.type()?((t=a.container.selectAll(".currentValue").data(a.elementIds())).enter().append("p").attr("class","currentValue").attr("id",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+3).style("margin-top",0).style("margin-bottom",0),t.exit().remove(),a.container.selectAll("input").on("input",function(t,e){a.container.select(".currentValue#"+this.id).text(this.value)})):a.container.selectAll(".currentValue").remove(),a},a.updateState=function(){return"radio"==a.type()&&a.container.selectAll("input").filter(function(){return this.id==a.name+"_in_"+a.value()}).attr("checked",!0),"checkbox"==a.type()&&a.container.selectAll("input").property("checked",t=>!!a.get_value(t)),"text"==a.type()&&a.container.selectAll("input").property("value",t=>a.get_value(t)),"range"==a.type()&&(a.container.selectAll("input").attr("max",t=>a.get_max(t)).attr("min",t=>a.get_min(t)).attr("step",t=>a.get_step(t)).nodes().forEach((t,e)=>{t.value=a.get_value(a.elementIds()[e])}),a.container.selectAll(".currentValue").text(t=>a.get_value(t))),a},a.update=function(){return a.inherited_update(),a.updateElements(),a.updateState(),a},a},t.isNaN=a,t.layerBase=s,t.layerChart=r,t.parametricCurve=A,t.pearsonCorr=function(t,e){for(var a=0,r=0,n=0;n"+t+""+e.get_record()[t]+""}),e.table.selectAll("td").style("border-bottom","1px solid #ddd"),e},e},t.xLine=k,t.yLine=S}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).lc={})}(this,function(t){"use strict";function h(){var n={propList:[],add_property:function(t,e,a){n.propList.push(t);var r="get_"+t;return n[t]=function(t){return void 0===t?n[r]():("function"==typeof a&&(t=a(t)),n[r]="function"==typeof t?t:function(){return t},!n.layers&&n.chart||n)},n[r]="function"==typeof e?e:function(){return e},n},wrapSetter:function(t,e){if("function"!=typeof e)throw"Error in 'wrapSetter': wrapper is not a function.";if(-1==n.propList.indexOf(t))throw"Error in 'wrapSetter': this object doesn't have "+t+" property";var a=n[t];return n[t]=function(){return 0==arguments.length?n["get_"+t]():e(a).apply(n,arguments)},n}};return n}function f(t){var e={};return function(){if("clear"!==arguments[0])return arguments in Object.keys(e)||0==arguments.length&&0!=Object.keys(e).length||(e[arguments]=t.apply(void 0,arguments)),e[arguments];e={}}}function m(t,e){if(t.length!=e.length)throw"Error in getEuclideanDistance: length of theinput vectors is not the same";for(var a=0,r=0;r=r?(t.call(this,e),n.prev_time=d3.now()):n.timer=d3.timeout(t,1.5*r)}};return n}function x(t,r){return"number_nonneg"==t?function(t){if("function"==typeof t)return t;if("number"!=typeof(t=a(+t)?t:+t))throw"Error in 'typeCheck' for property '"+r+"': numeric value is required.";if(0<=t)return t;throw"Error in 'typeCheck' for property '"+r+"': negative values are not allowed."}:"array"==t?function(t){if("function"==typeof t)return t;if(Array.isArray(t))return t;if("object"==typeof t){var e=[];for(el in t){if("string"!=typeof t[el]&&"number"!=typeof t[el])throw"Error in 'typeCheck' for property '"+r+"': the value is not an array.";e.push(t[el])}return e}if("number"==typeof t||"string"==typeof t)return[t];throw"Error in 'typeCheck' for property '"+r+"': the value is not an array."}:"array_fun"==t?function(e){return e&&"object"==typeof e?function(t){return e[t]}:e}:(t="matrix_fun",function(a){if("function"==typeof a)return a;var t;if(a&&"object"==typeof a)return t=Object.keys(a),"object"==typeof a[t[0]]?function(t,e){return a[t][e]}:function(t){return a[t]};throw"Error in 'typeCheck' for property '"+r+"': the value is not an array or an object."})}function a(t){return null==t||"NA"==t||"NaN"==t||"NAN"==t||"na"==t||"Infinity"==t||"Inf"==t}function s(t){function l(){return"default"==c.mode()?2500ID: "+c.get_label(t)},x("array_fun","opacity"));c.propList=c.propList.concat(["updateElementStyle","updateElements","updateElementPosition"]),c.id=t,c.marked=[],c.wrapSetter("nelements",function(t){return function(){return c.get_elementIds=function(){return d3.range(t())},t.apply(c,arguments)}}),c.wrapSetter("elementIds",function(t){return function(){return c.get_nelements=function(){return t().length},t.apply(c,arguments)}}),c.wrapSetter("colour",function(t){return function(){return c.addColourScaleToLegend(!1),t.apply(c,arguments)}}),c.colourDomain(function(){var t=c.elementIds().map(t=>c.get_colourValue(t));if(0!=t.length){if(1==t.length)return void 0===t[0]?[]:t;var e=-1;if("number"==typeof t[1]&&"number"==typeof t[2])for(a=t[1]>t[0]?[t[0],t[1]]:[t[1],t[0]],e=2;et[e]&&(a[0]=t[e]),a[1]!lc.isNaN(t));for(var o=0;o/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t)).length!=t.length&&(t=[d3.min(t),d3.max(t)]),1==l.length&&l.push(l[0]),l.length>t.length){for(var i=[],o=0;o_[t].type).indexOf("colour"))){var n={};if(n.scale="function"==typeof t?t:function(){return t},void 0!==r&&(n.layer=r),-1==["colour","size","symbol","dash"].indexOf(e))throw"Error in 'legend.add_block': "+e+" is not a suitable type of legend block. Please, use one of these: 'colour', 'size', 'symbol', 'dash'";n.type=e,_[a]=n,h.container()&&o()}return h.chart},h.updateScale=function(t,e){if(void 0===_[e])throw"Error in 'legend.updateScale': A block with ID "+e+" is not defined";return _[e].scale=t,h.updateBlock(e),h.chart},h.removeBlock=function(t){if(void 0===_[t])throw"Error in 'legend.remove': block with ID "+t+" doesn't exist";return void 0!==_[t].layer&&_[t].layer.legendBlocks.splice(_[t].layer.legendBlocks.indexOf(t),1),delete _[t],h.legendTable.select("#"+t).remove(),o(),h.chart},h.renameBlock=function(t,e){return _[e]=_[t],delete _[t],void 0!==_[e].layer&&_[e].layer.legendBlocks.splice(_[e].layer.legendBlocks.indexOf(t),1,e),h.legendTable&&(h.legendTable.select("#"+t).attr("id",e),h.updateBlock(e)),h.chart},function(){var a,t=Object.keys(_).length;if(void 0===h.ncol()){for(var e,r=1+t,n=1,o=2;o<=Math.ceil(Math.sqrt(t));o++)o+(e=Math.ceil(t/o))<=r&&(r=o+e,n=o);a=Math.ceil(t/n)}else a=h.ncol(),n=Math.ceil(t/a);for(o in h.legendTable&&h.legendTable.remove(),h.legendTable=h.container().append("table").attr("class","legendTable linked-charts"),h.legendTable.selectAll("tr").data(d3.range(n)).enter().append("tr"),h.legendTable.selectAll("tr").selectAll("td").data(function(e){return d3.range(a).map(function(t){return[e,t]})}).enter().append("td").attr("id",function(t){try{return Object.keys(_)[t[0]*a+t[1]].replace(/[ .]/g,"_")}catch(t){}}),_)h.updateBlock(o)});return h.updateBlock=function(a){if(void 0===_[a])throw"Error in 'legend.updateBlock': block with ID "+a+" is not defined";for(var t,e,r=function(t){var e,a;if("function"!=typeof(e=void 0===(e="function"==typeof _[t].scale?_[t].scale():e)||"function"!=typeof e&&void 0===e.splice?_[t].scale:e)){var r=!1,n=!1;if(1==e.length)throw"Error in 'legend.convertScale': range of the scale is not defined.";2==e[0].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(r=!0),"colour"==_[t].type&&e[0].length!=e[1].length&&(n=!0),2==e[1].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(n=!0),r&&n&&(a=d3.scaleLinear().domain(e[0]).range(e[1]),e.steps?a.steps=e.steps:a.steps=9),r&&!n&&((a=d3.scaleQuantize().domain(e[0]).range(e[1])).steps=e[1].length),!r&&n&&((a=d3.scalePoint().domain(e[0]).range(e[1])).steps=e[0].length),r||n||(e[0].length>e[1].length&&e[0].splice(e[1].length),e[1].length>e[0].length&&e[1].splice(e[0].length),(a=d3.scaleOrdinal().domain(e[0]).range(e[1])).steps=e[0].length),_[t].domain=e[0],void 0===a.domain&&(a.domain=_[t].domain)}else{var o="function"==typeof e.domain?e.domain():e.domain;if(void 0===o)throw"Error in 'legend.convertScale': the domain of the scale is not defined.";for(var l=0;lt),f=[0];n.each(function(){f[0]"+n.innerHTML+"",s.container().selectAll("tr").each(function(t,e){g=0,u=[],d3.select(this).selectAll("td").each(function(t,e){c=d3.select(this).selectAll("svg"),p+=""+c.node().innerHTML+"",u.push(c.attr("height")),g+=+c.attr("width")}),d+=+d3.max(u)}),""+p+""):(new XMLSerializer).serializeToString(n),(n=new Image).onload=function(){l.drawImage(this,0,0),a.canvas&&a.canvas.classed("active")&&l.drawImage(a.canvas.node(),a.paddings().left,a.paddings().top),i()},n.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(p)}function c(t){for(var e,a,r,n,o,l,i=t.svg.node().cloneNode(!0),s=0;s"+i.innerHTML+"",t.legend.container().selectAll("tr").each(function(){e=0,n=[],d3.select(this).selectAll("td").each(function(){r=d3.select(this).selectAll("svg"),o+=""+r.node().innerHTML+"",n.push(r.attr("height")),e+=+r.attr("width")}),a+=+d3.max(n)}),""+o+""):t.svg.attr("xmlns","http://www.w3.org/2000/svg").node().parentNode.innerHTML,l=new Blob([o],{type:"image/svg+xml"}),saveAs(l,"export_"+Date.now()+".svg")):(t.container.append("div").attr("class","hint").attr("id","errMessage").style("left",t.width()/3+"px").style("top",t.height()/3+"px").style("width",t.width()/3+"px").text("Chart in canvas mode cannot be saved as SVG."),setTimeout(function(){t.container.select("#errMessage").remove()},2e3))}function u(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.selectMode(!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.selectMode(!0),(e=t.panel.g.selectAll("#b_pan")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function p(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.pan("mode",!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.pan("mode",!0),(e=t.panel.g.selectAll("#b_selection")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function g(a){var t=a.get_marked(),e=(0==(t=a.layers?Object.keys(a.layers).map(e=>t[e].map(t=>[e,t])).flat():t).length&&(t=a.layers?Object.keys(a.layers).map(e=>a.get_layer(e).elementIds().map(t=>[e,t])).flat():a.elementIds()),{x:[],y:[]}),r=(t.map(function(t){t=a.get_position(t);t&&(e.x.push(t[0]),e.y.push(t[1]))}),d3.extent(e.x)),n=d3.extent(e.y);a.zoom([r[0],n[0]],[r[1],n[1]])}function n(){function t(r){return function(){var e;if(u["get_singleScale"+r]()){var t=!0;for(a in u.layers)t=t&&u.get_layer(a)["get_contScale"+r]();if(t)for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(void 0===e?e=u.get_layer(a)["get_layerDomain"+r]():(e[0]=d3.min([e[0],u.get_layer(a)["get_layerDomain"+r]()[0]]),e[1]=d3.max([e[1],u.get_layer(a)["get_layerDomain"+r]()[1]])));else for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(e=void 0===e?u.get_layer(a)["get_layerDomain"+r]():e.concat(u.get_layer(a)["get_layerDomain"+r]().filter(function(t){return e.indexOf(t)<0})))}return void 0===e&&(e=[0,1]),t&&(u["logScale"+r]()?(e[1]=2*e[1],e[0]=e[0]/2):(e[1]=e[1]+.03*(e[1]-e[0]),e[0]=e[0]-.03*(e[1]-e[0]))),e}}var u=r(),e=(u.add_property("singleScaleX",!0).add_property("singleScaleY",!0).add_property("domainX",void 0,x("array","domainX")).add_property("domainY",void 0,x("array","domainY")).add_property("aspectRatio",void 0,x("number_nonneg","aspectRatio")).add_property("axisTitleX","").add_property("axisTitleY","").add_property("axisTitlePos",{x:{across:"up",along:"end"},y:{across:"up",along:"end"}},function(t){var e={x:{across:"up",along:"end"},y:{across:"up",along:"end"}};if(t.x){if(!t.x.split)throw"Error in 'typeCheck' for property 'axisTitlePos': 'x' must be a string.";var a=t.x.split(" ").map(t=>t.toLowerCase());-1t.toLowerCase());-1=t[0]&&a.push(r[n]),n++;0=t[1];)u.axes.scale_y(l[n])<=e[1]&&o.push(l[n]),n++;0=d3.max([0,o-r]);i--)e.unshift(n[i]);for(i=l+1;i=d3.max([0,o-r]);i--)a.unshift(s[i]);for(i=l+1;i":i+=">",i+=a[o][r]+"";l.push(i)}else l=a[1];e.tickFormat=function(t){return l[e.tickValues.indexOf(t)]}}return e}function g(t){var e=u["get_domain"+t]();void 0===u.axes["scale_"+t.toLowerCase()]&&(u.axes["scale_"+t.toLowerCase()]={},u.axes["shiftScale"+t]=d3.scaleLinear().domain([0,1])),2==e.length&&"number"==typeof(e[0]+e[1])?((e=u["logScale"+t]())&&0r.get_on_click(e,t)).on("mouseover",(t,e)=>r.get_on_mouseover(e,t)).on("mouseout",(t,e)=>r.get_on_mouseout(e,t))},r.dresser(function(t){t.attr("stroke",function(t){return r.get_colour(t)}).attr("stroke-width",function(t){return r.get_lineWidth(t)}).attr("stroke-dasharray",function(t){return r.get_dasharray(t)}).attr("opacity",function(t){return r.get_opacity(t)}).attr("fill",function(t){return r.get_fill(t)})}),r.findElements=function(s,d){var t=d3.max([10,2*r.lineWidth()]);return s[0]-d[0]"+i.get_label(t)+";
x = "+e+";
y = "+a}),i.nelements(function(){for(var t,e=0;e<1e5;e++){try{t=i.get_x(e)}catch(t){return 0<=e?e:0}if(void 0===t)return 0<=e?e:0}throw"There seem to be very many data points. Please supply a number via 'nelements'."}),i.get_scaledShiftX=function(){return 0},i.get_scaledShiftY=function(){return 0},i.findElements=function(a,r){return i.elementIds().filter(function(t){var e=[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)];return e[0]-i.get_size(t)-1<=r[0]&&e[1]-i.get_size(t)-1<=r[1]&&e[0]+i.get_size(t)+1>=a[0]&&e[1]+i.get_size(t)+1>=a[1]})},i.get_position=function(t){return[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)]},i.layerDomainX(function(){var t=i.elementIds().map(function(t){return i.get_x(t)}).filter(function(t){return!lc.isNaN(t)}),e=!0,a=0;if(i.chart.logScaleX())return d3.extent(t.filter(function(t){return 0a[1]||i.get_x(t)r[1]||i.get_y(t)r[1]||i.get_y(t)a[1]||i.get_x(t)i.get_on_click(e,t)).on("mouseover",(t,e)=>i.get_on_mouseover(e,t)).on("mouseout",(t,e)=>i.get_on_mouseout(e,t))):i.updateStarted||i.updateCanvas()),l},i.updateCanvas=function(){var t,e,a,r=i.elementIds(),n=i.canvas.node().getContext("2d");n.clearRect(0,0,l.plotWidth(),l.plotHeight());for(var o=0;oi.chart.plotWidth()?(e=i.chart.plotWidth(),t+="-15 "):t+="0 ",a<0?(a=0,t+="15"):a>i.chart.plotHeight()?(a=i.chart.plotHeight(),t+="-15"):t+="0"),n.translate(e,a),t=new Path2D(t),n.stroke(t),n.fill(t),n.translate(-e,-a)},l}function L(t,e){void 0===e&&(e=n()),C(t=void 0===t?"layer"+e.get_nlayers():t,e);var a=e.get_layer(t),r=(a.add_property("valueAxis","y",function(t){if("x"!=t&&"y"!=t&&"function"!=typeof t)throw"Error in 'typeCheck' for 'valueAxis': axis nameshould be 'x' or 'y'";return t}),e.syncProperties(a),a.type="beeswarm",a.updateElementPosition);return a.updateElementPosition=function(){a.valueAxis();var e=d3.beeswarm().data(a.elementIds().filter(function(t){var e="x"==a.valueAxis()?"y":"x";return void 0!==a.chart.axes["scale_"+e](a["get_"+e](t))}).sort(function(t,e){return a["get_"+a.valueAxis()](t)-a["get_"+a.valueAxis()](e)})).distributeOn(function(t){return a.chart.axes["scale_"+a.valueAxis()](a["get_"+a.valueAxis()](t))}).axis(function(t){return"x"==a.valueAxis()?a.chart.axes.scale_y(a.get_y(t)):a.chart.axes.scale_x(a.get_x(t))}).radius(a.size()).arrange();e.res={};for(var t=0;tt,x("array_fun","stackLabel")).add_property("groupLabel",t=>t,x("array_fun","groupLabel")).add_property("barLabel",t=>t,x("array_fun","barLabel")).add_property("value",void 0,function(r){if("function"==typeof r)return r;var n;if("object"==typeof r){r.__inds__&&(n=r.__inds__,r.__inds__=null);var t=Object.keys(r);if("object"==typeof r[t[0]]){var e,a=Object.keys(r[t[0]]);if("object"==typeof r[t[0]][a[0]])return e=Object.keys(r[t[0]][a[0]]),"object"==typeof r[t[0]][a[0]][e[0]]?function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a][0]}:function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a]}}}throw"Error in 'typeCheck' for property 'value': the value is not an array or an object."}).add_property("groupWidth",.6).add_property("stroke","#444").add_property("strokeWidth",0);return s.chart.syncProperties(s),s.type="barchart",s.chart.informText(function(t,e,a){var r=s.get_groupLabel(t),n=s.get_barLabel(e),o=s.get_stackLabel(a);return 1"+r+";
value = "+s.get_value(t,e,a).toFixed(2)}),["group","bar","stack"].forEach(function(e){s.wrapSetter("n"+e+"s",function(t){return function(){return s["get_"+e+"Ids"]=function(){return d3.range(t())},t.apply(s,arguments)}}),s.wrapSetter(e+"Ids",function(t){return function(){return s["get_n"+e+"s"]=function(){return t().length},t.apply(s,arguments)}})}),s.nbars(1),s.nstacks(1),s.contScaleX(!1),s.elementIds(function(){if(void 0===s.groupIds()||0==s.groupIds().length)return[];if(1==s.nbars()&&(0==s.barIds()[0]||1==s.barIds()[0]))return s.stackIds();for(var t=[],e=s.barIds(),a=s.stackIds(),r=0;rs.get_groupLabel(t));return s.contScaleX()?[d3.min(t),d3.max(t)]:t}),s.layerDomainY(function(){for(var t=s.barIds(),e=s.groupIds(),a=s.stackIds(),r=0,n=0;nt&&n[1]<=e+r&&o[1]>e}).data()},s.get_position=function(t){return[s.g.select("#p"+t.join("_")).attr("x"),s.g.select("#p"+t.join("_")).attr("y")]},s.updateElementPosition=function(){var t,e,a,r,n,o;return void 0!==s.groupIds()&&(t=s.groupIds().map(t=>s.get_groupLabel(t)),e=(t=s.contScaleX()?Math.abs(s.chart.axes.scale_x(t[1])-s.chart.axes.scale_x(t[0]))*s.groupWidth():s.chart.axes.scale_x.step()*s.groupWidth())/s.nbars(),a=Math.abs(s.chart.axes.scale_y(1)-s.chart.axes.scale_y(0)),r=d3.scaleLinear().domain([0,s.nbars()-1]).range([-t/2,t/2-e]),n=s.barIds(),o=s.stackIds(),0e&&g.midpoint(e),g.midpoint()-td3.interpolateRdYlBu(1-t),function(e){if("string"==typeof e){if(d3[e])return d3[e];throw"Error in 'typeCheck' for 'palette': invalid palette name, must be one of d3 interpolators (e.g. 'interpolateOrRd')."}if(Array.isArray(e))return e=e.map(t=>/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t),d3.scaleLinear().domain(d3.range(e.length).map(function(t){return t/e.length})).range(e);if("function"==typeof e)return e;throw"Error in 'typeCheck' for 'palette': invalid type. Palette must be a name of a d3 interpolator, an array of colours or a function."}).add_property("colourDomain",function(){return u.dataRange()},x("array","colourDomain")).add_property("clusterRowMetric",m).add_property("clusterColMetric",m).add_property("on_click",function(){}).add_property("rowTitle","").add_property("showValue",!1).add_property("valueTextColour",(t,e)=>{t=d3.hsl(u.get_colour(u.get_value(t,e)));return t.h=(t.h+180)%360,t.s=Math.sqrt(t.s),t.l=1-t.l,t},function(t){if("function"==typeof t)return t;if("string"==typeof t)return t;throw"Error in 'typeCheck' for 'valueTextColour': invalid type. valueTextColour must be a colour name or a function."}).add_property("showInform",!0).add_property("colTitle","").add_property("on_mouseover").add_property("on_mouseout").add_property("on_labelClickRow").add_property("on_labelClickCol").add_property("clusterRows",!1).add_property("clusterCols",!1).add_property("legendTitle","").add_property("informText",function(t,e){var a=u.get_value(t,e);return"number"==typeof a&&(a=a.toFixed(2)),"Row: "+u.get_rowLabel(t)+";
Col: "+u.get_colLabel(e)+";
value = "+a},x("matrix_fun","value"))).paddings({top:100,left:100,right:10,bottom:40}),u.legend.width(75),["col","row"].forEach(function(a){u.wrapSetter("n"+a+"s",function(t){return function(){return u["get_"+a+"Ids"]=function(){return d3.range(t())},t.apply(u,arguments)}}),u.wrapSetter(a+"Ids",function(e){return function(){u["get_n"+a+"s"]=function(){return e().length};var t=a[0].toUpperCase()+a.slice(1);return e.apply(u,arguments),u["get_disp"+t+"Ids"]=u["get_"+a+"Ids"],u}})}),u.wrapSetter("colour",function(a){return function(){var t=a.apply(u,arguments),e=u.get_colour;return u.get_colour=function(){return 1==arguments.length&&void 0===arguments[0]?"#eee":e.apply(u,arguments)},t}}),["col","row"].forEach(function(t){var a="col"==t?"bottom":"right";u.wrapSetter(t+"Title",function(e){return function(){var t={};return t[a]=d3.max([u.paddings()[a],20]),u.set_paddings(t),e.apply(u,arguments)}})}),u.colour(function(t){return u.colourScale(t)}),u.axes={},u.marked=[],a={Row:u.showDendogramRow(),Col:u.showDendogramCol()},u.showDendogram=function(t,e){return void 0===e?a[t]:(a[t]=e&&u["showDendogram"+t](),u)},u.showDendogram("Row",!1).showDendogram("Col",!1);var a,e=u.put_static_content,i=(u.put_static_content=function(t){e(t),_(u),u.svg.append("g").attr("class","row label_panel"),u.svg.append("g").attr("class","col label_panel"),u.canvas=u.container.append("canvas").style("position","absolute").style("z-index",-5).attr("id","hCanvas"),u.g=u.svg.select(".plotArea").append("g").attr("class","chart_g"),u.text=u.g.append("g").attr("class","text_g"),u.axes.x_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end"),u.axes.y_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end").attr("transform","rotate(-90)"),("svg"==i()?u.g:u.canvas).classed("active",!0),u.svg.select(".clickPanel").on("mouseover",function(){u.container.select(".inform").classed("hidden",!1)}).on("mouseout",function(){u.container.select(".inform").classed("hidden",!0)}),u.showPanel()&&(u.panel.add_button("Zoom in","#zoomIn",function(t){var e=-Math.ceil(.1*t.dispRowIds().length),a=-Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Zoom out","#zoomOut",function(t){var e=Math.ceil(.1*t.dispRowIds().length),a=Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateCellColour(),t.updateLabelText(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Cluster rows","#clusterRows",function(t){t.cluster("Row"),t.showDendogram("Row",!0),t.updateLabelPosition()}),u.panel.add_button("Cluster columns","#clusterCols",function(t){t.cluster("Col"),t.showDendogram("Col",!0),t.updateLabelPosition()}),u.panel.add_button("Restore original order","#restoreOrder",function(t){var a=t.rowIds().slice(),r=t.colIds().slice();t.reorder("Row",function(t,e){return a.indexOf(t)-a.indexOf(e)}),t.reorder("Col",function(t,e){return r.indexOf(t)-r.indexOf(e)}),t.dendogramRow&&t.dendogramRow.remove(),t.dendogramCol&&t.dendogramCol.remove(),t.updateStarted=!0,t.updateLabels().updateLabelPosition().updateLabelText().updateCellColour(),t.updateStarted=!1}))},function(){return"default"==u.mode()?2500a.indexOf(r[i])&&(l=a.indexOf(r[i]));for(i=l-1;i>=d3.max([0,l-t]);i--)r.unshift(a[i])}else{l=-1;for(i=0;i=e[0]&&t[1]+u.cellSize.height>=e[1]}).data();else for(var r=u.svg.select(".col").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[0]&&t<=a[0]+u.cellSize.width}).data(),n=u.svg.select(".row").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[1]&&t<=a[1]+u.cellSize.height}).data(),o=0;ot[1]&&(t[1]=e[1]),++ar(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),e.enter().append("text").attr("class","label plainText").style("text-anchor","end").attr("dx",-2).merge(e).attr("id",function(t){return t.toString().replace(/[ .]/g,"_")}).on("mouseover",(t,e)=>r(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),u.updateCells(),u},u.updateLabelText=function(){var t;return 0u.get_value(r,e[o-1])&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&ou.get_value(e[o-1],r)&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&os(e,t)).on("mouseout",d).on("click",function(t,e){u.get_on_click.apply(this,[e[0],e[1],t])}),u.get_showValue()&&u.updateTexts()}else{for(var a=u.dispRowIds(),r=u.dispColIds(),n=0;nu.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}):u.g.selectAll(".tval").attr("fill",t=>u.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}),u},u.updateCanvas=function(){var t,e,n=u.canvas.node().getContext("2d"),a=(n.clearRect(0,0,u.plotWidth(),u.plotHeight()),u.dispRowIds()),r=u.dispColIds(),o=r.length,l=a.length,i=document.createElement("canvas"),s=(i.width=o,i.height=l,new ImageData(o,l));if(0==u.marked.length)for(var d=0;dt,x("array_fun","label")).add_property("nelements",1,x("number_nonneg","nelements")).add_property("elementIds",[0],x("array","elementIds")).add_property("value",function(){},x("array_fun","value")).add_property("min",0,x("array_fun","min")).add_property("max",100,x("array_fun","max")).add_property("step",1,x("array_fun","step")).add_property("fontSize",17,x("number_nonneg","fontSize")).add_property("ncols",1,x("number_nonneg","ncols")).add_property("nrows",function(){return a.nelements()},x("number_nonneg","nrows")).add_property("on_change",function(){}),e=(a.wrapSetter("nelements",function(t){return function(){return a.get_elementIds=function(){return d3.range(t())},t.apply(a,arguments)}}),a.wrapSetter("elementIds",function(t){return function(){return a.get_nelements=function(){return t().length},t.apply(a,arguments)}}),a.wrapSetter("nrows",function(t){return function(){return a.get_ncols=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.wrapSetter("ncols",function(t){return function(){return a.get_nrows=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.value(t=>{switch(a.type()){case"text":return"";case"button":return t;case"range":case"radio":return;case"checkbox":return!1}}),a.name="n"+Math.random().toString(36).substring(5),a.width(200),a.put_static_content);return a.put_static_content=function(t){return e(t),a.container.style("display","grid").style("grid-template-columns","repeat(auto-fit, fit-content(500px) 1fr fit-content(20px))").style("column-gap","9px").style("align-items","center").append("p").style("grid-row",1).style("grid-column","1/"+(3*a.ncols()+1)).style("text-align","center").style("font-weight","bold").attr("id","title"),a},a.updateTitle=function(){return a.container.select("#title").text(a.title()),a},a.updateElements=function(){var t=a.container.selectAll("input").data(a.elementIds()),e=a.container.selectAll("label").data(a.elementIds());return t.enter().append("input").attr("type",a.type()).attr("name",a.name).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?2:1)).attr("id",t=>a.name+"_in_"+t).property("value",t=>"radio"==a.type()?t:void 0).style("width","text"==a.type()||"range"==a.type()?"100%":void 0).on("button"==a.type()?"click":"change",function(){var t,e;a.get_on_change((t=this,"button"==a.type()||"radio"==a.type()?t.value:"checkbox"==a.type()?d3.select(t.parentNode).selectAll("input").nodes().map(t=>t.checked):(e={},"range"!=a.type()&&"text"!=a.type()||d3.select(t.parentNode).selectAll("input").nodes().forEach(function(t){e[t.id.substring(a.name.length+1)]=+t.value?+t.value:t.value}),e)))}),t.exit().remove(),"button"!=a.type()?(e.exit().remove(),e.enter().append("label").attr("for",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?1:2)).merge(e).text(t=>a.get_label(t)).style("font-size",a.fontSize())):a.container.selectAll("input").style("font-size",a.fontSize()).property("value",t=>a.get_label(t)),"range"==a.type()?((t=a.container.selectAll(".currentValue").data(a.elementIds())).enter().append("p").attr("class","currentValue").attr("id",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+3).style("margin-top",0).style("margin-bottom",0),t.exit().remove(),a.container.selectAll("input").on("input",function(t,e){a.container.select(".currentValue#"+this.id).text(this.value)})):a.container.selectAll(".currentValue").remove(),a},a.updateState=function(){return"radio"==a.type()&&a.container.selectAll("input").filter(function(){return this.id==a.name+"_in_"+a.value()}).attr("checked",!0),"checkbox"==a.type()&&a.container.selectAll("input").property("checked",t=>!!a.get_value(t)),"text"==a.type()&&a.container.selectAll("input").property("value",t=>a.get_value(t)),"range"==a.type()&&(a.container.selectAll("input").attr("max",t=>a.get_max(t)).attr("min",t=>a.get_min(t)).attr("step",t=>a.get_step(t)).nodes().forEach((t,e)=>{t.value=a.get_value(a.elementIds()[e])}),a.container.selectAll(".currentValue").text(t=>a.get_value(t))),a},a.update=function(){return a.inherited_update(),a.updateElements(),a.updateState(),a},a},t.isNaN=a,t.layerBase=s,t.layerChart=r,t.parametricCurve=A,t.pearsonCorr=function(t,e){for(var a=0,r=0,n=0;n"+t+""+e.get_record()[t]+""}),e.table.selectAll("td").style("border-bottom","1px solid #ddd"),e},e},t.xLine=k,t.yLine=S}); \ No newline at end of file diff --git a/example/hetamap.html b/example/hetamap.html index a379b79..eb939c6 100644 --- a/example/hetamap.html +++ b/example/hetamap.html @@ -16,5 +16,6 @@ .ncols(30) .mode("canvas") .value((row, col) => Math.random()) + .legendTitle("BBB!") .place("#container"); \ No newline at end of file diff --git a/lib/linked-charts.min.js b/lib/linked-charts.min.js index 993063b..8f3a6c1 100644 --- a/lib/linked-charts.min.js +++ b/lib/linked-charts.min.js @@ -7,4 +7,4 @@ /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ var saveAs=saveAs||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),c=e.webkitRequestFileSystem,d=e.requestFileSystem||c||e.mozRequestFileSystem,u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",f=0,l=4e4,v=function(e){var t=function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()};setTimeout(t,l)},p=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(i){u(i)}}},w=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e},y=function(t,u,l){l||(t=w(t));var y,m,S,h=this,R=t.type,O=!1,g=function(){p(h,"writestart progress write writeend".split(" "))},b=function(){if(m&&a&&"undefined"!=typeof FileReader){var o=new FileReader;return o.onloadend=function(){var e=o.result;m.location.href="data:attachment/file"+e.slice(e.search(/[,;]/)),h.readyState=h.DONE,g()},o.readAsDataURL(t),void(h.readyState=h.INIT)}if((O||!y)&&(y=n().createObjectURL(t)),m)m.location.href=y;else{var r=e.open(y,"_blank");void 0===r&&a&&(e.location.href=y)}h.readyState=h.DONE,g(),v(y)},E=function(e){return function(){return h.readyState!==h.DONE?e.apply(this,arguments):void 0}},N={create:!0,exclusive:!1};return h.readyState=h.INIT,u||(u="download"),r?(y=n().createObjectURL(t),void setTimeout(function(){o.href=y,o.download=u,i(o),g(),v(y),h.readyState=h.DONE})):(e.chrome&&R&&R!==s&&(S=t.slice||t.webkitSlice,t=S.call(t,0,t.size,s),O=!0),c&&"download"!==u&&(u+=".download"),(R===s||c)&&(m=e),d?(f+=t.size,void d(e.TEMPORARY,f,E(function(e){e.root.getDirectory("saved",N,E(function(e){var n=function(){e.getFile(u,N,E(function(e){e.createWriter(E(function(n){n.onwriteend=function(t){m.location.href=e.toURL(),h.readyState=h.DONE,p(h,"writeend",t),v(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&b()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=h["on"+e]}),n.write(t),h.abort=function(){n.abort(),h.readyState=h.DONE},h.readyState=h.WRITING}),b)}),b)};e.getFile(u,{create:!1},E(function(e){e.remove(),n()}),E(function(e){e.code===e.NOT_FOUND_ERR?n():b()}))}),b)}),b)):void b())},m=y.prototype,S=function(e,t,n){return new y(e,t,n)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return n||(e=w(e)),navigator.msSaveOrOpenBlob(e,t||"download")}:(m.abort=function(){var e=this;e.readyState=e.DONE,p(e,"abort")},m.readyState=m.INIT=0,m.WRITING=1,m.DONE=2,m.error=m.onwritestart=m.onprogress=m.onwrite=m.onabort=m.onerror=m.onwriteend=null,S)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define([],function(){return saveAs}); -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).lc={})}(this,function(t){"use strict";function h(){var n={propList:[],add_property:function(t,e,a){n.propList.push(t);var r="get_"+t;return n[t]=function(t){return void 0===t?n[r]():("function"==typeof a&&(t=a(t)),n[r]="function"==typeof t?t:function(){return t},!n.layers&&n.chart||n)},n[r]="function"==typeof e?e:function(){return e},n},wrapSetter:function(t,e){if("function"!=typeof e)throw"Error in 'wrapSetter': wrapper is not a function.";if(-1==n.propList.indexOf(t))throw"Error in 'wrapSetter': this object doesn't have "+t+" property";var a=n[t];return n[t]=function(){return 0==arguments.length?n["get_"+t]():e(a).apply(n,arguments)},n}};return n}function f(t){var e={};return function(){if("clear"!==arguments[0])return arguments in Object.keys(e)||0==arguments.length&&0!=Object.keys(e).length||(e[arguments]=t.apply(void 0,arguments)),e[arguments];e={}}}function m(t,e){if(t.length!=e.length)throw"Error in getEuclideanDistance: length of theinput vectors is not the same";for(var a=0,r=0;r=r?(t.call(this,e),n.prev_time=d3.now()):n.timer=d3.timeout(t,1.5*r)}};return n}function x(t,r){return"number_nonneg"==t?function(t){if("function"==typeof t)return t;if("number"!=typeof(t=a(+t)?t:+t))throw"Error in 'typeCheck' for property '"+r+"': numeric value is required.";if(0<=t)return t;throw"Error in 'typeCheck' for property '"+r+"': negative values are not allowed."}:"array"==t?function(t){if("function"==typeof t)return t;if(Array.isArray(t))return t;if("object"==typeof t){var e=[];for(el in t){if("string"!=typeof t[el]&&"number"!=typeof t[el])throw"Error in 'typeCheck' for property '"+r+"': the value is not an array.";e.push(t[el])}return e}if("number"==typeof t||"string"==typeof t)return[t];throw"Error in 'typeCheck' for property '"+r+"': the value is not an array."}:"array_fun"==t?function(e){return e&&"object"==typeof e?function(t){return e[t]}:e}:(t="matrix_fun",function(a){if("function"==typeof a)return a;var t;if(a&&"object"==typeof a)return t=Object.keys(a),"object"==typeof a[t[0]]?function(t,e){return a[t][e]}:function(t){return a[t]};throw"Error in 'typeCheck' for property '"+r+"': the value is not an array or an object."})}function a(t){return null==t||"NA"==t||"NaN"==t||"NAN"==t||"na"==t||"Infinity"==t||"Inf"==t}function s(t){function l(){return"default"==c.mode()?2500ID: "+c.get_label(t)},x("array_fun","opacity"));c.propList=c.propList.concat(["updateElementStyle","updateElements","updateElementPosition"]),c.id=t,c.marked=[],c.wrapSetter("nelements",function(t){return function(){return c.get_elementIds=function(){return d3.range(t())},t.apply(c,arguments)}}),c.wrapSetter("elementIds",function(t){return function(){return c.get_nelements=function(){return t().length},t.apply(c,arguments)}}),c.wrapSetter("colour",function(t){return function(){return c.addColourScaleToLegend(!1),t.apply(c,arguments)}}),c.colourDomain(function(){var t=c.elementIds().map(t=>c.get_colourValue(t));if(0!=t.length){if(1==t.length)return void 0===t[0]?[]:t;var e=-1;if("number"==typeof t[1]&&"number"==typeof t[2])for(a=t[1]>t[0]?[t[0],t[1]]:[t[1],t[0]],e=2;et[e]&&(a[0]=t[e]),a[1]!lc.isNaN(t));for(var o=0;o/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t)).length!=t.length&&(t=[d3.min(t),d3.max(t)]),1==l.length&&l.push(l[0]),l.length>t.length){for(var i=[],o=0;o_[t].type).indexOf("colour"))){var n={};if(n.scale="function"==typeof t?t:function(){return t},void 0!==r&&(n.layer=r),-1==["colour","size","symbol","dash"].indexOf(e))throw"Error in 'legend.add_block': "+e+" is not a suitable type of legend block. Please, use one of these: 'colour', 'size', 'symbol', 'dash'";n.type=e,_[a]=n,h.container()&&o()}return h.chart},h.updateScale=function(t,e){if(void 0===_[e])throw"Error in 'legend.updateScale': A block with ID "+e+" is not defined";return _[e].scale=t,h.updateBlock(e),h.chart},h.removeBlock=function(t){if(void 0===_[t])throw"Error in 'legend.remove': block with ID "+t+" doesn't exist";return void 0!==_[t].layer&&_[t].layer.legendBlocks.splice(_[t].layer.legendBlocks.indexOf(t),1),delete _[t],h.legendTable.select("#"+t).remove(),o(),h.chart},h.renameBlock=function(t,e){return _[e]=_[t],delete _[t],void 0!==_[e].layer&&_[e].layer.legendBlocks.splice(_[e].layer.legendBlocks.indexOf(t),1,e),h.legendTable&&(h.legendTable.select("#"+t).attr("id",e),h.updateBlock(e)),h.chart},function(){var a,t=Object.keys(_).length;if(void 0===h.ncol()){for(var e,r=1+t,n=1,o=2;o<=Math.ceil(Math.sqrt(t));o++)o+(e=Math.ceil(t/o))<=r&&(r=o+e,n=o);a=Math.ceil(t/n)}else a=h.ncol(),n=Math.ceil(t/a);for(o in h.legendTable&&h.legendTable.remove(),h.legendTable=h.container().append("table").attr("class","legendTable linked-charts"),h.legendTable.selectAll("tr").data(d3.range(n)).enter().append("tr"),h.legendTable.selectAll("tr").selectAll("td").data(function(e){return d3.range(a).map(function(t){return[e,t]})}).enter().append("td").attr("id",function(t){try{return Object.keys(_)[t[0]*a+t[1]].replace(/[ .]/g,"_")}catch(t){}}),_)h.updateBlock(o)});return h.updateBlock=function(a){if(void 0===_[a])throw"Error in 'legend.updateBlock': block with ID "+a+" is not defined";for(var t,e,r=function(t){var e,a;if("function"!=typeof(e=void 0===(e="function"==typeof _[t].scale?_[t].scale():e)||"function"!=typeof e&&void 0===e.splice?_[t].scale:e)){var r=!1,n=!1;if(1==e.length)throw"Error in 'legend.convertScale': range of the scale is not defined.";2==e[0].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(r=!0),"colour"==_[t].type&&e[0].length!=e[1].length&&(n=!0),2==e[1].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(n=!0),r&&n&&(a=d3.scaleLinear().domain(e[0]).range(e[1]),e.steps?a.steps=e.steps:a.steps=9),r&&!n&&((a=d3.scaleQuantize().domain(e[0]).range(e[1])).steps=e[1].length),!r&&n&&((a=d3.scalePoint().domain(e[0]).range(e[1])).steps=e[0].length),r||n||(e[0].length>e[1].length&&e[0].splice(e[1].length),e[1].length>e[0].length&&e[1].splice(e[0].length),(a=d3.scaleOrdinal().domain(e[0]).range(e[1])).steps=e[0].length),_[t].domain=e[0],void 0===a.domain&&(a.domain=_[t].domain)}else{var o="function"==typeof e.domain?e.domain():e.domain;if(void 0===o)throw"Error in 'legend.convertScale': the domain of the scale is not defined.";for(var l=0;lt),f=[0];n.each(function(){f[0]"+n.innerHTML+"",s.container().selectAll("tr").each(function(t,e){g=0,u=[],d3.select(this).selectAll("td").each(function(t,e){c=d3.select(this).selectAll("svg"),p+=""+c.node().innerHTML+"",u.push(c.attr("height")),g+=+c.attr("width")}),d+=+d3.max(u)}),""+p+""):(new XMLSerializer).serializeToString(n),(n=new Image).onload=function(){l.drawImage(this,0,0),a.canvas&&a.canvas.classed("active")&&l.drawImage(a.canvas.node(),a.paddings().left,a.paddings().top),i()},n.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(p)}function c(t){for(var e,a,r,n,o,l,i=t.svg.node().cloneNode(!0),s=0;s"+i.innerHTML+"",t.legend.container().selectAll("tr").each(function(){e=0,n=[],d3.select(this).selectAll("td").each(function(){r=d3.select(this).selectAll("svg"),o+=""+r.node().innerHTML+"",n.push(r.attr("height")),e+=+r.attr("width")}),a+=+d3.max(n)}),""+o+""):t.svg.attr("xmlns","http://www.w3.org/2000/svg").node().parentNode.innerHTML,l=new Blob([o],{type:"image/svg+xml"}),saveAs(l,"export_"+Date.now()+".svg")):(t.container.append("div").attr("class","hint").attr("id","errMessage").style("left",t.width()/3+"px").style("top",t.height()/3+"px").style("width",t.width()/3+"px").text("Chart in canvas mode cannot be saved as SVG."),setTimeout(function(){t.container.select("#errMessage").remove()},2e3))}function u(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.selectMode(!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.selectMode(!0),(e=t.panel.g.selectAll("#b_pan")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function p(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.pan("mode",!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.pan("mode",!0),(e=t.panel.g.selectAll("#b_selection")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function g(a){var t=a.get_marked(),e=(0==(t=a.layers?Object.keys(a.layers).map(e=>t[e].map(t=>[e,t])).flat():t).length&&(t=a.layers?Object.keys(a.layers).map(e=>a.get_layer(e).elementIds().map(t=>[e,t])).flat():a.elementIds()),{x:[],y:[]}),r=(t.map(function(t){t=a.get_position(t);t&&(e.x.push(t[0]),e.y.push(t[1]))}),d3.extent(e.x)),n=d3.extent(e.y);a.zoom([r[0],n[0]],[r[1],n[1]])}function n(){function t(r){return function(){var e;if(u["get_singleScale"+r]()){var t=!0;for(a in u.layers)t=t&&u.get_layer(a)["get_contScale"+r]();if(t)for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(void 0===e?e=u.get_layer(a)["get_layerDomain"+r]():(e[0]=d3.min([e[0],u.get_layer(a)["get_layerDomain"+r]()[0]]),e[1]=d3.max([e[1],u.get_layer(a)["get_layerDomain"+r]()[1]])));else for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(e=void 0===e?u.get_layer(a)["get_layerDomain"+r]():e.concat(u.get_layer(a)["get_layerDomain"+r]().filter(function(t){return e.indexOf(t)<0})))}return void 0===e&&(e=[0,1]),t&&(u["logScale"+r]()?(e[1]=2*e[1],e[0]=e[0]/2):(e[1]=e[1]+.03*(e[1]-e[0]),e[0]=e[0]-.03*(e[1]-e[0]))),e}}var u=r(),e=(u.add_property("singleScaleX",!0).add_property("singleScaleY",!0).add_property("domainX",void 0,x("array","domainX")).add_property("domainY",void 0,x("array","domainY")).add_property("aspectRatio",void 0,x("number_nonneg","aspectRatio")).add_property("axisTitleX","").add_property("axisTitleY","").add_property("axisTitlePos",{x:{across:"up",along:"end"},y:{across:"up",along:"end"}},function(t){var e={x:{across:"up",along:"end"},y:{across:"up",along:"end"}};if(t.x){if(!t.x.split)throw"Error in 'typeCheck' for property 'axisTitlePos': 'x' must be a string.";var a=t.x.split(" ").map(t=>t.toLowerCase());-1t.toLowerCase());-1=t[0]&&a.push(r[n]),n++;0=t[1];)u.axes.scale_y(l[n])<=e[1]&&o.push(l[n]),n++;0=d3.max([0,o-r]);i--)e.unshift(n[i]);for(i=l+1;i=d3.max([0,o-r]);i--)a.unshift(s[i]);for(i=l+1;i":i+=">",i+=a[o][r]+"";l.push(i)}else l=a[1];e.tickFormat=function(t){return l[e.tickValues.indexOf(t)]}}return e}function g(t){var e=u["get_domain"+t]();void 0===u.axes["scale_"+t.toLowerCase()]&&(u.axes["scale_"+t.toLowerCase()]={},u.axes["shiftScale"+t]=d3.scaleLinear().domain([0,1])),2==e.length&&"number"==typeof(e[0]+e[1])?((e=u["logScale"+t]())&&0r.get_on_click(e,t)).on("mouseover",(t,e)=>r.get_on_mouseover(e,t)).on("mouseout",(t,e)=>r.get_on_mouseout(e,t))},r.dresser(function(t){t.attr("stroke",function(t){return r.get_colour(t)}).attr("stroke-width",function(t){return r.get_lineWidth(t)}).attr("stroke-dasharray",function(t){return r.get_dasharray(t)}).attr("opacity",function(t){return r.get_opacity(t)}).attr("fill",function(t){return r.get_fill(t)})}),r.findElements=function(s,d){var t=d3.max([10,2*r.lineWidth()]);return s[0]-d[0]"+i.get_label(t)+";
x = "+e+";
y = "+a}),i.nelements(function(){for(var t,e=0;e<1e5;e++){try{t=i.get_x(e)}catch(t){return 0<=e?e:0}if(void 0===t)return 0<=e?e:0}throw"There seem to be very many data points. Please supply a number via 'nelements'."}),i.get_scaledShiftX=function(){return 0},i.get_scaledShiftY=function(){return 0},i.findElements=function(a,r){return i.elementIds().filter(function(t){var e=[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)];return e[0]-i.get_size(t)-1<=r[0]&&e[1]-i.get_size(t)-1<=r[1]&&e[0]+i.get_size(t)+1>=a[0]&&e[1]+i.get_size(t)+1>=a[1]})},i.get_position=function(t){return[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)]},i.layerDomainX(function(){var t=i.elementIds().map(function(t){return i.get_x(t)}).filter(function(t){return!lc.isNaN(t)}),e=!0,a=0;if(i.chart.logScaleX())return d3.extent(t.filter(function(t){return 0a[1]||i.get_x(t)r[1]||i.get_y(t)r[1]||i.get_y(t)a[1]||i.get_x(t)i.get_on_click(e,t)).on("mouseover",(t,e)=>i.get_on_mouseover(e,t)).on("mouseout",(t,e)=>i.get_on_mouseout(e,t))):i.updateStarted||i.updateCanvas()),l},i.updateCanvas=function(){var t,e,a,r=i.elementIds(),n=i.canvas.node().getContext("2d");n.clearRect(0,0,l.plotWidth(),l.plotHeight());for(var o=0;oi.chart.plotWidth()?(e=i.chart.plotWidth(),t+="-15 "):t+="0 ",a<0?(a=0,t+="15"):a>i.chart.plotHeight()?(a=i.chart.plotHeight(),t+="-15"):t+="0"),n.translate(e,a),t=new Path2D(t),n.stroke(t),n.fill(t),n.translate(-e,-a)},l}function L(t,e){void 0===e&&(e=n()),C(t=void 0===t?"layer"+e.get_nlayers():t,e);var a=e.get_layer(t),r=(a.add_property("valueAxis","y",function(t){if("x"!=t&&"y"!=t&&"function"!=typeof t)throw"Error in 'typeCheck' for 'valueAxis': axis nameshould be 'x' or 'y'";return t}),e.syncProperties(a),a.type="beeswarm",a.updateElementPosition);return a.updateElementPosition=function(){a.valueAxis();var e=d3.beeswarm().data(a.elementIds().filter(function(t){var e="x"==a.valueAxis()?"y":"x";return void 0!==a.chart.axes["scale_"+e](a["get_"+e](t))}).sort(function(t,e){return a["get_"+a.valueAxis()](t)-a["get_"+a.valueAxis()](e)})).distributeOn(function(t){return a.chart.axes["scale_"+a.valueAxis()](a["get_"+a.valueAxis()](t))}).axis(function(t){return"x"==a.valueAxis()?a.chart.axes.scale_y(a.get_y(t)):a.chart.axes.scale_x(a.get_x(t))}).radius(a.size()).arrange();e.res={};for(var t=0;tt,x("array_fun","stackLabel")).add_property("groupLabel",t=>t,x("array_fun","groupLabel")).add_property("barLabel",t=>t,x("array_fun","barLabel")).add_property("value",void 0,function(r){if("function"==typeof r)return r;var n;if("object"==typeof r){r.__inds__&&(n=r.__inds__,r.__inds__=null);var t=Object.keys(r);if("object"==typeof r[t[0]]){var e,a=Object.keys(r[t[0]]);if("object"==typeof r[t[0]][a[0]])return e=Object.keys(r[t[0]][a[0]]),"object"==typeof r[t[0]][a[0]][e[0]]?function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a][0]}:function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a]}}}throw"Error in 'typeCheck' for property 'value': the value is not an array or an object."}).add_property("groupWidth",.6).add_property("stroke","#444").add_property("strokeWidth",0);return s.chart.syncProperties(s),s.type="barchart",s.chart.informText(function(t,e,a){var r=s.get_groupLabel(t),n=s.get_barLabel(e),o=s.get_stackLabel(a);return 1"+r+";
value = "+s.get_value(t,e,a).toFixed(2)}),["group","bar","stack"].forEach(function(e){s.wrapSetter("n"+e+"s",function(t){return function(){return s["get_"+e+"Ids"]=function(){return d3.range(t())},t.apply(s,arguments)}}),s.wrapSetter(e+"Ids",function(t){return function(){return s["get_n"+e+"s"]=function(){return t().length},t.apply(s,arguments)}})}),s.nbars(1),s.nstacks(1),s.contScaleX(!1),s.elementIds(function(){if(void 0===s.groupIds()||0==s.groupIds().length)return[];if(1==s.nbars()&&(0==s.barIds()[0]||1==s.barIds()[0]))return s.stackIds();for(var t=[],e=s.barIds(),a=s.stackIds(),r=0;rs.get_groupLabel(t));return s.contScaleX()?[d3.min(t),d3.max(t)]:t}),s.layerDomainY(function(){for(var t=s.barIds(),e=s.groupIds(),a=s.stackIds(),r=0,n=0;nt&&n[1]<=e+r&&o[1]>e}).data()},s.get_position=function(t){return[s.g.select("#p"+t.join("_")).attr("x"),s.g.select("#p"+t.join("_")).attr("y")]},s.updateElementPosition=function(){var t,e,a,r,n,o;return void 0!==s.groupIds()&&(t=s.groupIds().map(t=>s.get_groupLabel(t)),e=(t=s.contScaleX()?Math.abs(s.chart.axes.scale_x(t[1])-s.chart.axes.scale_x(t[0]))*s.groupWidth():s.chart.axes.scale_x.step()*s.groupWidth())/s.nbars(),a=Math.abs(s.chart.axes.scale_y(1)-s.chart.axes.scale_y(0)),r=d3.scaleLinear().domain([0,s.nbars()-1]).range([-t/2,t/2-e]),n=s.barIds(),o=s.stackIds(),0e&&g.midpoint(e),g.midpoint()-td3.interpolateRdYlBu(1-t),function(e){if("string"==typeof e){if(d3[e])return d3[e];throw"Error in 'typeCheck' for 'palette': invalid palette name, must be one of d3 interpolators (e.g. 'interpolateOrRd')."}if(Array.isArray(e))return e=e.map(t=>/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t),d3.scaleLinear().domain(d3.range(e.length).map(function(t){return t/e.length})).range(e);if("function"==typeof e)return e;throw"Error in 'typeCheck' for 'palette': invalid type. Palette must be a name of a d3 interpolator, an array of colours or a function."}).add_property("colourDomain",function(){return u.dataRange()},x("array","colourDomain")).add_property("clusterRowMetric",m).add_property("clusterColMetric",m).add_property("on_click",function(){}).add_property("rowTitle","").add_property("showValue",!1).add_property("valueTextColour",(t,e)=>{t=d3.hsl(u.get_colour(u.get_value(t,e)));return t.h=(t.h+180)%360,t.s=Math.sqrt(t.s),t.l=1-t.l,t},function(t){if("function"==typeof t)return t;if("string"==typeof t)return t;throw"Error in 'typeCheck' for 'valueTextColour': invalid type. valueTextColour must be a colour name or a function."}).add_property("showInform",!0).add_property("colTitle","").add_property("on_mouseover").add_property("on_mouseout").add_property("on_labelClickRow").add_property("on_labelClickCol").add_property("clusterRows",!1).add_property("clusterCols",!1).add_property("informText",function(t,e){var a=u.get_value(t,e);return"number"==typeof a&&(a=a.toFixed(2)),"Row: "+u.get_rowLabel(t)+";
Col: "+u.get_colLabel(e)+";
value = "+a},x("matrix_fun","value"))).paddings({top:100,left:100,right:10,bottom:40}),u.legend.width(75),["col","row"].forEach(function(a){u.wrapSetter("n"+a+"s",function(t){return function(){return u["get_"+a+"Ids"]=function(){return d3.range(t())},t.apply(u,arguments)}}),u.wrapSetter(a+"Ids",function(e){return function(){u["get_n"+a+"s"]=function(){return e().length};var t=a[0].toUpperCase()+a.slice(1);return e.apply(u,arguments),u["get_disp"+t+"Ids"]=u["get_"+a+"Ids"],u}})}),u.wrapSetter("colour",function(a){return function(){var t=a.apply(u,arguments),e=u.get_colour;return u.get_colour=function(){return 1==arguments.length&&void 0===arguments[0]?"#eee":e.apply(u,arguments)},t}}),["col","row"].forEach(function(t){var a="col"==t?"bottom":"right";u.wrapSetter(t+"Title",function(e){return function(){var t={};return t[a]=d3.max([u.paddings()[a],20]),u.set_paddings(t),e.apply(u,arguments)}})}),u.colour(function(t){return u.colourScale(t)}),u.axes={},u.marked=[],a={Row:u.showDendogramRow(),Col:u.showDendogramCol()},u.showDendogram=function(t,e){return void 0===e?a[t]:(a[t]=e&&u["showDendogram"+t](),u)},u.showDendogram("Row",!1).showDendogram("Col",!1);var a,e=u.put_static_content,i=(u.put_static_content=function(t){e(t),_(u),u.svg.append("g").attr("class","row label_panel"),u.svg.append("g").attr("class","col label_panel"),u.canvas=u.container.append("canvas").style("position","absolute").style("z-index",-5).attr("id","hCanvas"),u.g=u.svg.select(".plotArea").append("g").attr("class","chart_g"),u.text=u.g.append("g").attr("class","text_g"),u.axes.x_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end"),u.axes.y_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end").attr("transform","rotate(-90)"),("svg"==i()?u.g:u.canvas).classed("active",!0),u.svg.select(".clickPanel").on("mouseover",function(){u.container.select(".inform").classed("hidden",!1)}).on("mouseout",function(){u.container.select(".inform").classed("hidden",!0)}),u.showPanel()&&(u.panel.add_button("Zoom in","#zoomIn",function(t){var e=-Math.ceil(.1*t.dispRowIds().length),a=-Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Zoom out","#zoomOut",function(t){var e=Math.ceil(.1*t.dispRowIds().length),a=Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateCellColour(),t.updateLabelText(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Cluster rows","#clusterRows",function(t){t.cluster("Row"),t.showDendogram("Row",!0),t.updateLabelPosition()}),u.panel.add_button("Cluster columns","#clusterCols",function(t){t.cluster("Col"),t.showDendogram("Col",!0),t.updateLabelPosition()}),u.panel.add_button("Restore original order","#restoreOrder",function(t){var a=t.rowIds().slice(),r=t.colIds().slice();t.reorder("Row",function(t,e){return a.indexOf(t)-a.indexOf(e)}),t.reorder("Col",function(t,e){return r.indexOf(t)-r.indexOf(e)}),t.dendogramRow&&t.dendogramRow.remove(),t.dendogramCol&&t.dendogramCol.remove(),t.updateStarted=!0,t.updateLabels().updateLabelPosition().updateLabelText().updateCellColour(),t.updateStarted=!1}))},function(){return"default"==u.mode()?2500a.indexOf(r[i])&&(l=a.indexOf(r[i]));for(i=l-1;i>=d3.max([0,l-t]);i--)r.unshift(a[i])}else{l=-1;for(i=0;i=e[0]&&t[1]+u.cellSize.height>=e[1]}).data();else for(var r=u.svg.select(".col").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[0]&&t<=a[0]+u.cellSize.width}).data(),n=u.svg.select(".row").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[1]&&t<=a[1]+u.cellSize.height}).data(),o=0;ot[1]&&(t[1]=e[1]),++ar(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),e.enter().append("text").attr("class","label plainText").style("text-anchor","end").attr("dx",-2).merge(e).attr("id",function(t){return t.toString().replace(/[ .]/g,"_")}).on("mouseover",(t,e)=>r(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),u.updateCells(),u},u.updateLabelText=function(){var t;return 0u.get_value(r,e[o-1])&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&ou.get_value(e[o-1],r)&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&os(e,t)).on("mouseout",d).on("click",function(t,e){u.get_on_click.apply(this,[e[0],e[1],t])}),u.get_showValue()&&u.updateTexts()}else{for(var a=u.dispRowIds(),r=u.dispColIds(),n=0;nu.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}):u.g.selectAll(".tval").attr("fill",t=>u.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}),u},u.updateCanvas=function(){var t,e,n=u.canvas.node().getContext("2d"),a=(n.clearRect(0,0,u.plotWidth(),u.plotHeight()),u.dispRowIds()),r=u.dispColIds(),o=r.length,l=a.length,i=document.createElement("canvas"),s=(i.width=o,i.height=l,new ImageData(o,l));if(0==u.marked.length)for(var d=0;dt,x("array_fun","label")).add_property("nelements",1,x("number_nonneg","nelements")).add_property("elementIds",[0],x("array","elementIds")).add_property("value",function(){},x("array_fun","value")).add_property("min",0,x("array_fun","min")).add_property("max",100,x("array_fun","max")).add_property("step",1,x("array_fun","step")).add_property("fontSize",17,x("number_nonneg","fontSize")).add_property("ncols",1,x("number_nonneg","ncols")).add_property("nrows",function(){return a.nelements()},x("number_nonneg","nrows")).add_property("on_change",function(){}),e=(a.wrapSetter("nelements",function(t){return function(){return a.get_elementIds=function(){return d3.range(t())},t.apply(a,arguments)}}),a.wrapSetter("elementIds",function(t){return function(){return a.get_nelements=function(){return t().length},t.apply(a,arguments)}}),a.wrapSetter("nrows",function(t){return function(){return a.get_ncols=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.wrapSetter("ncols",function(t){return function(){return a.get_nrows=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.value(t=>{switch(a.type()){case"text":return"";case"button":return t;case"range":case"radio":return;case"checkbox":return!1}}),a.name="n"+Math.random().toString(36).substring(5),a.width(200),a.put_static_content);return a.put_static_content=function(t){return e(t),a.container.style("display","grid").style("grid-template-columns","repeat(auto-fit, fit-content(500px) 1fr fit-content(20px))").style("column-gap","9px").style("align-items","center").append("p").style("grid-row",1).style("grid-column","1/"+(3*a.ncols()+1)).style("text-align","center").style("font-weight","bold").attr("id","title"),a},a.updateTitle=function(){return a.container.select("#title").text(a.title()),a},a.updateElements=function(){var t=a.container.selectAll("input").data(a.elementIds()),e=a.container.selectAll("label").data(a.elementIds());return t.enter().append("input").attr("type",a.type()).attr("name",a.name).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?2:1)).attr("id",t=>a.name+"_in_"+t).property("value",t=>"radio"==a.type()?t:void 0).style("width","text"==a.type()||"range"==a.type()?"100%":void 0).on("button"==a.type()?"click":"change",function(){var t,e;a.get_on_change((t=this,"button"==a.type()||"radio"==a.type()?t.value:"checkbox"==a.type()?d3.select(t.parentNode).selectAll("input").nodes().map(t=>t.checked):(e={},"range"!=a.type()&&"text"!=a.type()||d3.select(t.parentNode).selectAll("input").nodes().forEach(function(t){e[t.id.substring(a.name.length+1)]=+t.value?+t.value:t.value}),e)))}),t.exit().remove(),"button"!=a.type()?(e.exit().remove(),e.enter().append("label").attr("for",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?1:2)).merge(e).text(t=>a.get_label(t)).style("font-size",a.fontSize())):a.container.selectAll("input").style("font-size",a.fontSize()).property("value",t=>a.get_label(t)),"range"==a.type()?((t=a.container.selectAll(".currentValue").data(a.elementIds())).enter().append("p").attr("class","currentValue").attr("id",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+3).style("margin-top",0).style("margin-bottom",0),t.exit().remove(),a.container.selectAll("input").on("input",function(t,e){a.container.select(".currentValue#"+this.id).text(this.value)})):a.container.selectAll(".currentValue").remove(),a},a.updateState=function(){return"radio"==a.type()&&a.container.selectAll("input").filter(function(){return this.id==a.name+"_in_"+a.value()}).attr("checked",!0),"checkbox"==a.type()&&a.container.selectAll("input").property("checked",t=>!!a.get_value(t)),"text"==a.type()&&a.container.selectAll("input").property("value",t=>a.get_value(t)),"range"==a.type()&&(a.container.selectAll("input").attr("max",t=>a.get_max(t)).attr("min",t=>a.get_min(t)).attr("step",t=>a.get_step(t)).nodes().forEach((t,e)=>{t.value=a.get_value(a.elementIds()[e])}),a.container.selectAll(".currentValue").text(t=>a.get_value(t))),a},a.update=function(){return a.inherited_update(),a.updateElements(),a.updateState(),a},a},t.isNaN=a,t.layerBase=s,t.layerChart=r,t.parametricCurve=A,t.pearsonCorr=function(t,e){for(var a=0,r=0,n=0;n"+t+""+e.get_record()[t]+""}),e.table.selectAll("td").style("border-bottom","1px solid #ddd"),e},e},t.xLine=k,t.yLine=S}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).lc={})}(this,function(t){"use strict";function h(){var n={propList:[],add_property:function(t,e,a){n.propList.push(t);var r="get_"+t;return n[t]=function(t){return void 0===t?n[r]():("function"==typeof a&&(t=a(t)),n[r]="function"==typeof t?t:function(){return t},!n.layers&&n.chart||n)},n[r]="function"==typeof e?e:function(){return e},n},wrapSetter:function(t,e){if("function"!=typeof e)throw"Error in 'wrapSetter': wrapper is not a function.";if(-1==n.propList.indexOf(t))throw"Error in 'wrapSetter': this object doesn't have "+t+" property";var a=n[t];return n[t]=function(){return 0==arguments.length?n["get_"+t]():e(a).apply(n,arguments)},n}};return n}function f(t){var e={};return function(){if("clear"!==arguments[0])return arguments in Object.keys(e)||0==arguments.length&&0!=Object.keys(e).length||(e[arguments]=t.apply(void 0,arguments)),e[arguments];e={}}}function m(t,e){if(t.length!=e.length)throw"Error in getEuclideanDistance: length of theinput vectors is not the same";for(var a=0,r=0;r=r?(t.call(this,e),n.prev_time=d3.now()):n.timer=d3.timeout(t,1.5*r)}};return n}function x(t,r){return"number_nonneg"==t?function(t){if("function"==typeof t)return t;if("number"!=typeof(t=a(+t)?t:+t))throw"Error in 'typeCheck' for property '"+r+"': numeric value is required.";if(0<=t)return t;throw"Error in 'typeCheck' for property '"+r+"': negative values are not allowed."}:"array"==t?function(t){if("function"==typeof t)return t;if(Array.isArray(t))return t;if("object"==typeof t){var e=[];for(el in t){if("string"!=typeof t[el]&&"number"!=typeof t[el])throw"Error in 'typeCheck' for property '"+r+"': the value is not an array.";e.push(t[el])}return e}if("number"==typeof t||"string"==typeof t)return[t];throw"Error in 'typeCheck' for property '"+r+"': the value is not an array."}:"array_fun"==t?function(e){return e&&"object"==typeof e?function(t){return e[t]}:e}:(t="matrix_fun",function(a){if("function"==typeof a)return a;var t;if(a&&"object"==typeof a)return t=Object.keys(a),"object"==typeof a[t[0]]?function(t,e){return a[t][e]}:function(t){return a[t]};throw"Error in 'typeCheck' for property '"+r+"': the value is not an array or an object."})}function a(t){return null==t||"NA"==t||"NaN"==t||"NAN"==t||"na"==t||"Infinity"==t||"Inf"==t}function s(t){function l(){return"default"==c.mode()?2500ID: "+c.get_label(t)},x("array_fun","opacity"));c.propList=c.propList.concat(["updateElementStyle","updateElements","updateElementPosition"]),c.id=t,c.marked=[],c.wrapSetter("nelements",function(t){return function(){return c.get_elementIds=function(){return d3.range(t())},t.apply(c,arguments)}}),c.wrapSetter("elementIds",function(t){return function(){return c.get_nelements=function(){return t().length},t.apply(c,arguments)}}),c.wrapSetter("colour",function(t){return function(){return c.addColourScaleToLegend(!1),t.apply(c,arguments)}}),c.colourDomain(function(){var t=c.elementIds().map(t=>c.get_colourValue(t));if(0!=t.length){if(1==t.length)return void 0===t[0]?[]:t;var e=-1;if("number"==typeof t[1]&&"number"==typeof t[2])for(a=t[1]>t[0]?[t[0],t[1]]:[t[1],t[0]],e=2;et[e]&&(a[0]=t[e]),a[1]!lc.isNaN(t));for(var o=0;o/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t)).length!=t.length&&(t=[d3.min(t),d3.max(t)]),1==l.length&&l.push(l[0]),l.length>t.length){for(var i=[],o=0;o_[t].type).indexOf("colour"))){var n={};if(n.scale="function"==typeof t?t:function(){return t},void 0!==r&&(n.layer=r),-1==["colour","size","symbol","dash"].indexOf(e))throw"Error in 'legend.add_block': "+e+" is not a suitable type of legend block. Please, use one of these: 'colour', 'size', 'symbol', 'dash'";n.type=e,_[a]=n,h.container()&&o()}return h.chart},h.updateScale=function(t,e){if(void 0===_[e])throw"Error in 'legend.updateScale': A block with ID "+e+" is not defined";return _[e].scale=t,h.updateBlock(e),h.chart},h.removeBlock=function(t){if(void 0===_[t])throw"Error in 'legend.remove': block with ID "+t+" doesn't exist";return void 0!==_[t].layer&&_[t].layer.legendBlocks.splice(_[t].layer.legendBlocks.indexOf(t),1),delete _[t],h.legendTable.select("#"+t).remove(),o(),h.chart},h.renameBlock=function(t,e){return _[e]=_[t],delete _[t],void 0!==_[e].layer&&_[e].layer.legendBlocks.splice(_[e].layer.legendBlocks.indexOf(t),1,e),h.legendTable&&(h.legendTable.select("#"+t).attr("id",e),h.updateBlock(e)),h.chart},function(){var a,t=Object.keys(_).length;if(void 0===h.ncol()){for(var e,r=1+t,n=1,o=2;o<=Math.ceil(Math.sqrt(t));o++)o+(e=Math.ceil(t/o))<=r&&(r=o+e,n=o);a=Math.ceil(t/n)}else a=h.ncol(),n=Math.ceil(t/a);for(o in h.legendTable&&h.legendTable.remove(),h.legendTable=h.container().append("table").attr("class","legendTable linked-charts"),h.legendTable.selectAll("tr").data(d3.range(n)).enter().append("tr"),h.legendTable.selectAll("tr").selectAll("td").data(function(e){return d3.range(a).map(function(t){return[e,t]})}).enter().append("td").attr("id",function(t){try{return Object.keys(_)[t[0]*a+t[1]].replace(/[ .]/g,"_")}catch(t){}}),_)h.updateBlock(o)});return h.updateBlock=function(a){if(void 0===_[a])throw"Error in 'legend.updateBlock': block with ID "+a+" is not defined";for(var t,e,r=function(t){var e,a;if("function"!=typeof(e=void 0===(e="function"==typeof _[t].scale?_[t].scale():e)||"function"!=typeof e&&void 0===e.splice?_[t].scale:e)){var r=!1,n=!1;if(1==e.length)throw"Error in 'legend.convertScale': range of the scale is not defined.";2==e[0].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(r=!0),"colour"==_[t].type&&e[0].length!=e[1].length&&(n=!0),2==e[1].length&&"number"==typeof e[0][0]&&"number"==typeof e[0][1]&&(n=!0),r&&n&&(a=d3.scaleLinear().domain(e[0]).range(e[1]),e.steps?a.steps=e.steps:a.steps=9),r&&!n&&((a=d3.scaleQuantize().domain(e[0]).range(e[1])).steps=e[1].length),!r&&n&&((a=d3.scalePoint().domain(e[0]).range(e[1])).steps=e[0].length),r||n||(e[0].length>e[1].length&&e[0].splice(e[1].length),e[1].length>e[0].length&&e[1].splice(e[0].length),(a=d3.scaleOrdinal().domain(e[0]).range(e[1])).steps=e[0].length),_[t].domain=e[0],void 0===a.domain&&(a.domain=_[t].domain)}else{var o="function"==typeof e.domain?e.domain():e.domain;if(void 0===o)throw"Error in 'legend.convertScale': the domain of the scale is not defined.";for(var l=0;lt),f=[0];n.each(function(){f[0]"+n.innerHTML+"",s.container().selectAll("tr").each(function(t,e){g=0,u=[],d3.select(this).selectAll("td").each(function(t,e){c=d3.select(this).selectAll("svg"),p+=""+c.node().innerHTML+"",u.push(c.attr("height")),g+=+c.attr("width")}),d+=+d3.max(u)}),""+p+""):(new XMLSerializer).serializeToString(n),(n=new Image).onload=function(){l.drawImage(this,0,0),a.canvas&&a.canvas.classed("active")&&l.drawImage(a.canvas.node(),a.paddings().left,a.paddings().top),i()},n.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(p)}function c(t){for(var e,a,r,n,o,l,i=t.svg.node().cloneNode(!0),s=0;s"+i.innerHTML+"",t.legend.container().selectAll("tr").each(function(){e=0,n=[],d3.select(this).selectAll("td").each(function(){r=d3.select(this).selectAll("svg"),o+=""+r.node().innerHTML+"",n.push(r.attr("height")),e+=+r.attr("width")}),a+=+d3.max(n)}),""+o+""):t.svg.attr("xmlns","http://www.w3.org/2000/svg").node().parentNode.innerHTML,l=new Blob([o],{type:"image/svg+xml"}),saveAs(l,"export_"+Date.now()+".svg")):(t.container.append("div").attr("class","hint").attr("id","errMessage").style("left",t.width()/3+"px").style("top",t.height()/3+"px").style("width",t.width()/3+"px").text("Chart in canvas mode cannot be saved as SVG."),setTimeout(function(){t.container.select("#errMessage").remove()},2e3))}function u(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.selectMode(!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.selectMode(!0),(e=t.panel.g.selectAll("#b_pan")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function p(t,e){e.classed("clicked")?(e.classed("clicked",!1).attr("opacity",.6).on("mouseout",function(){d3.select(this).attr("opacity",.6)}),t.pan("mode",!1)):(e.classed("clicked",!0).attr("opacity",1).on("mouseout",function(){}),t.pan("mode",!0),(e=t.panel.g.selectAll("#b_selection")).classed("clicked")&&e.on("click").call(e.node(),e.datum()))}function g(a){var t=a.get_marked(),e=(0==(t=a.layers?Object.keys(a.layers).map(e=>t[e].map(t=>[e,t])).flat():t).length&&(t=a.layers?Object.keys(a.layers).map(e=>a.get_layer(e).elementIds().map(t=>[e,t])).flat():a.elementIds()),{x:[],y:[]}),r=(t.map(function(t){t=a.get_position(t);t&&(e.x.push(t[0]),e.y.push(t[1]))}),d3.extent(e.x)),n=d3.extent(e.y);a.zoom([r[0],n[0]],[r[1],n[1]])}function n(){function t(r){return function(){var e;if(u["get_singleScale"+r]()){var t=!0;for(a in u.layers)t=t&&u.get_layer(a)["get_contScale"+r]();if(t)for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(void 0===e?e=u.get_layer(a)["get_layerDomain"+r]():(e[0]=d3.min([e[0],u.get_layer(a)["get_layerDomain"+r]()[0]]),e[1]=d3.max([e[1],u.get_layer(a)["get_layerDomain"+r]()[1]])));else for(var a in u.layers)void 0!==u.get_layer(a)["get_layerDomain"+r]()&&(e=void 0===e?u.get_layer(a)["get_layerDomain"+r]():e.concat(u.get_layer(a)["get_layerDomain"+r]().filter(function(t){return e.indexOf(t)<0})))}return void 0===e&&(e=[0,1]),t&&(u["logScale"+r]()?(e[1]=2*e[1],e[0]=e[0]/2):(e[1]=e[1]+.03*(e[1]-e[0]),e[0]=e[0]-.03*(e[1]-e[0]))),e}}var u=r(),e=(u.add_property("singleScaleX",!0).add_property("singleScaleY",!0).add_property("domainX",void 0,x("array","domainX")).add_property("domainY",void 0,x("array","domainY")).add_property("aspectRatio",void 0,x("number_nonneg","aspectRatio")).add_property("axisTitleX","").add_property("axisTitleY","").add_property("axisTitlePos",{x:{across:"up",along:"end"},y:{across:"up",along:"end"}},function(t){var e={x:{across:"up",along:"end"},y:{across:"up",along:"end"}};if(t.x){if(!t.x.split)throw"Error in 'typeCheck' for property 'axisTitlePos': 'x' must be a string.";var a=t.x.split(" ").map(t=>t.toLowerCase());-1t.toLowerCase());-1=t[0]&&a.push(r[n]),n++;0=t[1];)u.axes.scale_y(l[n])<=e[1]&&o.push(l[n]),n++;0=d3.max([0,o-r]);i--)e.unshift(n[i]);for(i=l+1;i=d3.max([0,o-r]);i--)a.unshift(s[i]);for(i=l+1;i":i+=">",i+=a[o][r]+"";l.push(i)}else l=a[1];e.tickFormat=function(t){return l[e.tickValues.indexOf(t)]}}return e}function g(t){var e=u["get_domain"+t]();void 0===u.axes["scale_"+t.toLowerCase()]&&(u.axes["scale_"+t.toLowerCase()]={},u.axes["shiftScale"+t]=d3.scaleLinear().domain([0,1])),2==e.length&&"number"==typeof(e[0]+e[1])?((e=u["logScale"+t]())&&0r.get_on_click(e,t)).on("mouseover",(t,e)=>r.get_on_mouseover(e,t)).on("mouseout",(t,e)=>r.get_on_mouseout(e,t))},r.dresser(function(t){t.attr("stroke",function(t){return r.get_colour(t)}).attr("stroke-width",function(t){return r.get_lineWidth(t)}).attr("stroke-dasharray",function(t){return r.get_dasharray(t)}).attr("opacity",function(t){return r.get_opacity(t)}).attr("fill",function(t){return r.get_fill(t)})}),r.findElements=function(s,d){var t=d3.max([10,2*r.lineWidth()]);return s[0]-d[0]"+i.get_label(t)+";
x = "+e+";
y = "+a}),i.nelements(function(){for(var t,e=0;e<1e5;e++){try{t=i.get_x(e)}catch(t){return 0<=e?e:0}if(void 0===t)return 0<=e?e:0}throw"There seem to be very many data points. Please supply a number via 'nelements'."}),i.get_scaledShiftX=function(){return 0},i.get_scaledShiftY=function(){return 0},i.findElements=function(a,r){return i.elementIds().filter(function(t){var e=[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)];return e[0]-i.get_size(t)-1<=r[0]&&e[1]-i.get_size(t)-1<=r[1]&&e[0]+i.get_size(t)+1>=a[0]&&e[1]+i.get_size(t)+1>=a[1]})},i.get_position=function(t){return[i.chart.axes.scale_x(i.get_x(t))+i.get_scaledShiftX(t),i.chart.axes.scale_y(i.get_y(t))+i.get_scaledShiftY(t)]},i.layerDomainX(function(){var t=i.elementIds().map(function(t){return i.get_x(t)}).filter(function(t){return!lc.isNaN(t)}),e=!0,a=0;if(i.chart.logScaleX())return d3.extent(t.filter(function(t){return 0a[1]||i.get_x(t)r[1]||i.get_y(t)r[1]||i.get_y(t)a[1]||i.get_x(t)i.get_on_click(e,t)).on("mouseover",(t,e)=>i.get_on_mouseover(e,t)).on("mouseout",(t,e)=>i.get_on_mouseout(e,t))):i.updateStarted||i.updateCanvas()),l},i.updateCanvas=function(){var t,e,a,r=i.elementIds(),n=i.canvas.node().getContext("2d");n.clearRect(0,0,l.plotWidth(),l.plotHeight());for(var o=0;oi.chart.plotWidth()?(e=i.chart.plotWidth(),t+="-15 "):t+="0 ",a<0?(a=0,t+="15"):a>i.chart.plotHeight()?(a=i.chart.plotHeight(),t+="-15"):t+="0"),n.translate(e,a),t=new Path2D(t),n.stroke(t),n.fill(t),n.translate(-e,-a)},l}function L(t,e){void 0===e&&(e=n()),C(t=void 0===t?"layer"+e.get_nlayers():t,e);var a=e.get_layer(t),r=(a.add_property("valueAxis","y",function(t){if("x"!=t&&"y"!=t&&"function"!=typeof t)throw"Error in 'typeCheck' for 'valueAxis': axis nameshould be 'x' or 'y'";return t}),e.syncProperties(a),a.type="beeswarm",a.updateElementPosition);return a.updateElementPosition=function(){a.valueAxis();var e=d3.beeswarm().data(a.elementIds().filter(function(t){var e="x"==a.valueAxis()?"y":"x";return void 0!==a.chart.axes["scale_"+e](a["get_"+e](t))}).sort(function(t,e){return a["get_"+a.valueAxis()](t)-a["get_"+a.valueAxis()](e)})).distributeOn(function(t){return a.chart.axes["scale_"+a.valueAxis()](a["get_"+a.valueAxis()](t))}).axis(function(t){return"x"==a.valueAxis()?a.chart.axes.scale_y(a.get_y(t)):a.chart.axes.scale_x(a.get_x(t))}).radius(a.size()).arrange();e.res={};for(var t=0;tt,x("array_fun","stackLabel")).add_property("groupLabel",t=>t,x("array_fun","groupLabel")).add_property("barLabel",t=>t,x("array_fun","barLabel")).add_property("value",void 0,function(r){if("function"==typeof r)return r;var n;if("object"==typeof r){r.__inds__&&(n=r.__inds__,r.__inds__=null);var t=Object.keys(r);if("object"==typeof r[t[0]]){var e,a=Object.keys(r[t[0]]);if("object"==typeof r[t[0]][a[0]])return e=Object.keys(r[t[0]][a[0]]),"object"==typeof r[t[0]][a[0]][e[0]]?function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a][0]}:function(t,e,a){return n&&(t=n.indexOf(t)+1),r[t][e][a]}}}throw"Error in 'typeCheck' for property 'value': the value is not an array or an object."}).add_property("groupWidth",.6).add_property("stroke","#444").add_property("strokeWidth",0);return s.chart.syncProperties(s),s.type="barchart",s.chart.informText(function(t,e,a){var r=s.get_groupLabel(t),n=s.get_barLabel(e),o=s.get_stackLabel(a);return 1"+r+";
value = "+s.get_value(t,e,a).toFixed(2)}),["group","bar","stack"].forEach(function(e){s.wrapSetter("n"+e+"s",function(t){return function(){return s["get_"+e+"Ids"]=function(){return d3.range(t())},t.apply(s,arguments)}}),s.wrapSetter(e+"Ids",function(t){return function(){return s["get_n"+e+"s"]=function(){return t().length},t.apply(s,arguments)}})}),s.nbars(1),s.nstacks(1),s.contScaleX(!1),s.elementIds(function(){if(void 0===s.groupIds()||0==s.groupIds().length)return[];if(1==s.nbars()&&(0==s.barIds()[0]||1==s.barIds()[0]))return s.stackIds();for(var t=[],e=s.barIds(),a=s.stackIds(),r=0;rs.get_groupLabel(t));return s.contScaleX()?[d3.min(t),d3.max(t)]:t}),s.layerDomainY(function(){for(var t=s.barIds(),e=s.groupIds(),a=s.stackIds(),r=0,n=0;nt&&n[1]<=e+r&&o[1]>e}).data()},s.get_position=function(t){return[s.g.select("#p"+t.join("_")).attr("x"),s.g.select("#p"+t.join("_")).attr("y")]},s.updateElementPosition=function(){var t,e,a,r,n,o;return void 0!==s.groupIds()&&(t=s.groupIds().map(t=>s.get_groupLabel(t)),e=(t=s.contScaleX()?Math.abs(s.chart.axes.scale_x(t[1])-s.chart.axes.scale_x(t[0]))*s.groupWidth():s.chart.axes.scale_x.step()*s.groupWidth())/s.nbars(),a=Math.abs(s.chart.axes.scale_y(1)-s.chart.axes.scale_y(0)),r=d3.scaleLinear().domain([0,s.nbars()-1]).range([-t/2,t/2-e]),n=s.barIds(),o=s.stackIds(),0e&&g.midpoint(e),g.midpoint()-td3.interpolateRdYlBu(1-t),function(e){if("string"==typeof e){if(d3[e])return d3[e];throw"Error in 'typeCheck' for 'palette': invalid palette name, must be one of d3 interpolators (e.g. 'interpolateOrRd')."}if(Array.isArray(e))return e=e.map(t=>/^#[0-9a-fA-F]{8,8}$/.test(t)?t.substring(0,7):t),d3.scaleLinear().domain(d3.range(e.length).map(function(t){return t/e.length})).range(e);if("function"==typeof e)return e;throw"Error in 'typeCheck' for 'palette': invalid type. Palette must be a name of a d3 interpolator, an array of colours or a function."}).add_property("colourDomain",function(){return u.dataRange()},x("array","colourDomain")).add_property("clusterRowMetric",m).add_property("clusterColMetric",m).add_property("on_click",function(){}).add_property("rowTitle","").add_property("showValue",!1).add_property("valueTextColour",(t,e)=>{t=d3.hsl(u.get_colour(u.get_value(t,e)));return t.h=(t.h+180)%360,t.s=Math.sqrt(t.s),t.l=1-t.l,t},function(t){if("function"==typeof t)return t;if("string"==typeof t)return t;throw"Error in 'typeCheck' for 'valueTextColour': invalid type. valueTextColour must be a colour name or a function."}).add_property("showInform",!0).add_property("colTitle","").add_property("on_mouseover").add_property("on_mouseout").add_property("on_labelClickRow").add_property("on_labelClickCol").add_property("clusterRows",!1).add_property("clusterCols",!1).add_property("legendTitle","").add_property("informText",function(t,e){var a=u.get_value(t,e);return"number"==typeof a&&(a=a.toFixed(2)),"Row: "+u.get_rowLabel(t)+";
Col: "+u.get_colLabel(e)+";
value = "+a},x("matrix_fun","value"))).paddings({top:100,left:100,right:10,bottom:40}),u.legend.width(75),["col","row"].forEach(function(a){u.wrapSetter("n"+a+"s",function(t){return function(){return u["get_"+a+"Ids"]=function(){return d3.range(t())},t.apply(u,arguments)}}),u.wrapSetter(a+"Ids",function(e){return function(){u["get_n"+a+"s"]=function(){return e().length};var t=a[0].toUpperCase()+a.slice(1);return e.apply(u,arguments),u["get_disp"+t+"Ids"]=u["get_"+a+"Ids"],u}})}),u.wrapSetter("colour",function(a){return function(){var t=a.apply(u,arguments),e=u.get_colour;return u.get_colour=function(){return 1==arguments.length&&void 0===arguments[0]?"#eee":e.apply(u,arguments)},t}}),["col","row"].forEach(function(t){var a="col"==t?"bottom":"right";u.wrapSetter(t+"Title",function(e){return function(){var t={};return t[a]=d3.max([u.paddings()[a],20]),u.set_paddings(t),e.apply(u,arguments)}})}),u.colour(function(t){return u.colourScale(t)}),u.axes={},u.marked=[],a={Row:u.showDendogramRow(),Col:u.showDendogramCol()},u.showDendogram=function(t,e){return void 0===e?a[t]:(a[t]=e&&u["showDendogram"+t](),u)},u.showDendogram("Row",!1).showDendogram("Col",!1);var a,e=u.put_static_content,i=(u.put_static_content=function(t){e(t),_(u),u.svg.append("g").attr("class","row label_panel"),u.svg.append("g").attr("class","col label_panel"),u.canvas=u.container.append("canvas").style("position","absolute").style("z-index",-5).attr("id","hCanvas"),u.g=u.svg.select(".plotArea").append("g").attr("class","chart_g"),u.text=u.g.append("g").attr("class","text_g"),u.axes.x_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end"),u.axes.y_label=u.svg.append("text").attr("class","axisLabel").attr("text-anchor","end").attr("transform","rotate(-90)"),("svg"==i()?u.g:u.canvas).classed("active",!0),u.svg.select(".clickPanel").on("mouseover",function(){u.container.select(".inform").classed("hidden",!1)}).on("mouseout",function(){u.container.select(".inform").classed("hidden",!0)}),u.showPanel()&&(u.panel.add_button("Zoom in","#zoomIn",function(t){var e=-Math.ceil(.1*t.dispRowIds().length),a=-Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Zoom out","#zoomOut",function(t){var e=Math.ceil(.1*t.dispRowIds().length),a=Math.ceil(.1*t.dispColIds().length);t.dispRowIds(o(e,"top")),t.dispRowIds(o(e,"bottom")),t.dispColIds(o(a,"left")),t.dispColIds(o(a,"right")),t.updateStarted=!0,t.updateLabels(),t.updateLabelPosition(),t.updateCellColour(),t.updateLabelText(),t.updateStarted=!1},"Double click to return to original scales"),u.panel.add_button("Cluster rows","#clusterRows",function(t){t.cluster("Row"),t.showDendogram("Row",!0),t.updateLabelPosition()}),u.panel.add_button("Cluster columns","#clusterCols",function(t){t.cluster("Col"),t.showDendogram("Col",!0),t.updateLabelPosition()}),u.panel.add_button("Restore original order","#restoreOrder",function(t){var a=t.rowIds().slice(),r=t.colIds().slice();t.reorder("Row",function(t,e){return a.indexOf(t)-a.indexOf(e)}),t.reorder("Col",function(t,e){return r.indexOf(t)-r.indexOf(e)}),t.dendogramRow&&t.dendogramRow.remove(),t.dendogramCol&&t.dendogramCol.remove(),t.updateStarted=!0,t.updateLabels().updateLabelPosition().updateLabelText().updateCellColour(),t.updateStarted=!1}))},function(){return"default"==u.mode()?2500a.indexOf(r[i])&&(l=a.indexOf(r[i]));for(i=l-1;i>=d3.max([0,l-t]);i--)r.unshift(a[i])}else{l=-1;for(i=0;i=e[0]&&t[1]+u.cellSize.height>=e[1]}).data();else for(var r=u.svg.select(".col").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[0]&&t<=a[0]+u.cellSize.width}).data(),n=u.svg.select(".row").selectAll(".label").filter(function(){var t=this.y.baseVal[0].value;return t>=e[1]&&t<=a[1]+u.cellSize.height}).data(),o=0;ot[1]&&(t[1]=e[1]),++ar(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),e.enter().append("text").attr("class","label plainText").style("text-anchor","end").attr("dx",-2).merge(e).attr("id",function(t){return t.toString().replace(/[ .]/g,"_")}).on("mouseover",(t,e)=>r(0,t)).on("mouseout",(t,e)=>n(0,t)).on("click",(t,e)=>c(e,t)),u.updateCells(),u},u.updateLabelText=function(){var t;return 0u.get_value(r,e[o-1])&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&ou.get_value(e[o-1],r)&&(n=!1),o++;if(!n)for(o=1,n=!0;n&&os(e,t)).on("mouseout",d).on("click",function(t,e){u.get_on_click.apply(this,[e[0],e[1],t])}),u.get_showValue()&&u.updateTexts()}else{for(var a=u.dispRowIds(),r=u.dispColIds(),n=0;nu.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}):u.g.selectAll(".tval").attr("fill",t=>u.get_valueTextColour(t[0],t[1])).text(function(t){t=u.get_value(t[0],t[1]);return t.toFixed?t.toFixed(1):"NA"}),u},u.updateCanvas=function(){var t,e,n=u.canvas.node().getContext("2d"),a=(n.clearRect(0,0,u.plotWidth(),u.plotHeight()),u.dispRowIds()),r=u.dispColIds(),o=r.length,l=a.length,i=document.createElement("canvas"),s=(i.width=o,i.height=l,new ImageData(o,l));if(0==u.marked.length)for(var d=0;dt,x("array_fun","label")).add_property("nelements",1,x("number_nonneg","nelements")).add_property("elementIds",[0],x("array","elementIds")).add_property("value",function(){},x("array_fun","value")).add_property("min",0,x("array_fun","min")).add_property("max",100,x("array_fun","max")).add_property("step",1,x("array_fun","step")).add_property("fontSize",17,x("number_nonneg","fontSize")).add_property("ncols",1,x("number_nonneg","ncols")).add_property("nrows",function(){return a.nelements()},x("number_nonneg","nrows")).add_property("on_change",function(){}),e=(a.wrapSetter("nelements",function(t){return function(){return a.get_elementIds=function(){return d3.range(t())},t.apply(a,arguments)}}),a.wrapSetter("elementIds",function(t){return function(){return a.get_nelements=function(){return t().length},t.apply(a,arguments)}}),a.wrapSetter("nrows",function(t){return function(){return a.get_ncols=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.wrapSetter("ncols",function(t){return function(){return a.get_nrows=function(){return Math.ceil(a.nelements()/t())},t.apply(a,arguments)}}),a.value(t=>{switch(a.type()){case"text":return"";case"button":return t;case"range":case"radio":return;case"checkbox":return!1}}),a.name="n"+Math.random().toString(36).substring(5),a.width(200),a.put_static_content);return a.put_static_content=function(t){return e(t),a.container.style("display","grid").style("grid-template-columns","repeat(auto-fit, fit-content(500px) 1fr fit-content(20px))").style("column-gap","9px").style("align-items","center").append("p").style("grid-row",1).style("grid-column","1/"+(3*a.ncols()+1)).style("text-align","center").style("font-weight","bold").attr("id","title"),a},a.updateTitle=function(){return a.container.select("#title").text(a.title()),a},a.updateElements=function(){var t=a.container.selectAll("input").data(a.elementIds()),e=a.container.selectAll("label").data(a.elementIds());return t.enter().append("input").attr("type",a.type()).attr("name",a.name).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?2:1)).attr("id",t=>a.name+"_in_"+t).property("value",t=>"radio"==a.type()?t:void 0).style("width","text"==a.type()||"range"==a.type()?"100%":void 0).on("button"==a.type()?"click":"change",function(){var t,e;a.get_on_change((t=this,"button"==a.type()||"radio"==a.type()?t.value:"checkbox"==a.type()?d3.select(t.parentNode).selectAll("input").nodes().map(t=>t.checked):(e={},"range"!=a.type()&&"text"!=a.type()||d3.select(t.parentNode).selectAll("input").nodes().forEach(function(t){e[t.id.substring(a.name.length+1)]=+t.value?+t.value:t.value}),e)))}),t.exit().remove(),"button"!=a.type()?(e.exit().remove(),e.enter().append("label").attr("for",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+("text"==a.type()||"range"==a.type()?1:2)).merge(e).text(t=>a.get_label(t)).style("font-size",a.fontSize())):a.container.selectAll("input").style("font-size",a.fontSize()).property("value",t=>a.get_label(t)),"range"==a.type()?((t=a.container.selectAll(".currentValue").data(a.elementIds())).enter().append("p").attr("class","currentValue").attr("id",t=>a.name+"_in_"+t).style("grid-row",(t,e)=>e%a.nrows()+2).style("grid-column",(t,e)=>3*Math.floor(e/a.nrows())+3).style("margin-top",0).style("margin-bottom",0),t.exit().remove(),a.container.selectAll("input").on("input",function(t,e){a.container.select(".currentValue#"+this.id).text(this.value)})):a.container.selectAll(".currentValue").remove(),a},a.updateState=function(){return"radio"==a.type()&&a.container.selectAll("input").filter(function(){return this.id==a.name+"_in_"+a.value()}).attr("checked",!0),"checkbox"==a.type()&&a.container.selectAll("input").property("checked",t=>!!a.get_value(t)),"text"==a.type()&&a.container.selectAll("input").property("value",t=>a.get_value(t)),"range"==a.type()&&(a.container.selectAll("input").attr("max",t=>a.get_max(t)).attr("min",t=>a.get_min(t)).attr("step",t=>a.get_step(t)).nodes().forEach((t,e)=>{t.value=a.get_value(a.elementIds()[e])}),a.container.selectAll(".currentValue").text(t=>a.get_value(t))),a},a.update=function(){return a.inherited_update(),a.updateElements(),a.updateState(),a},a},t.isNaN=a,t.layerBase=s,t.layerChart=r,t.parametricCurve=A,t.pearsonCorr=function(t,e){for(var a=0,r=0,n=0;n"+t+""+e.get_record()[t]+""}),e.table.selectAll("td").style("border-bottom","1px solid #ddd"),e},e},t.xLine=k,t.yLine=S}); \ No newline at end of file diff --git a/src/heatmap.js b/src/heatmap.js index 0086b7f..71a3a4f 100644 --- a/src/heatmap.js +++ b/src/heatmap.js @@ -68,6 +68,7 @@ export function heatmap(id, chart){ .add_property("on_labelClickCol") .add_property("clusterRows", false) .add_property("clusterCols", false) + .add_property("legendTitle", "") .add_property("informText", function(rowId, colId) { var value = chart.get_value(rowId, colId); if(typeof value == "number") @@ -649,7 +650,7 @@ export function heatmap(id, chart){ } if(chart.showLegend() && chart.legend) - updateLegend(); + updateLegend(); } //some default onmouseover and onmouseout behaviour for cells and labels @@ -1055,7 +1056,7 @@ export function heatmap(id, chart){ function updateLegend() { chart.legend - .set_title({"heatmap": ""}) + .set_title({"heatmap": chart.legendTitle()}) .add_block(chart.colourScale, "colour", "heatmap"); return chart;