{"size": 12431, "ext": "js", "max_stars_repo_path": "basiclive/core/lims/static/lims/js/mxlive-reports.min.js", "max_stars_repo_name": "znarthur/basic-live", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "basiclive/core/lims/static/lims/js/mxlive-reports.min.js", "max_issues_repo_name": "znarthur/basic-live", "max_issues_repo_issues_event_min_datetime": "2020-12-03T15:27:09.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-03T15:27:09.000Z", "max_forks_repo_path": "basiclive/core/lims/static/lims/js/mxlive-reports.min.js", "max_forks_repo_name": "znarthur/basic-live", "max_forks_repo_forks_event_min_datetime": "2021-09-28T21:06:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-28T21:06:09.000Z"}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 12431.0, "max_line_length": 12431, "alphanum_fraction": 0.6329337945}
'use strict';function getPrecision(a,b){b=b||8;let c=(a[a.length-1]-a[0])/b;return Math.abs(Math.floor(Math.log10(c.toPrecision(1))||2))}function renderMarkdown(a){let b=new showdown.Converter;return b.makeHtml(a)}const figureTypes=["histogram","lineplot","barchart","scatterplot","pie","gauge","timeline","columnchart"];let ColorSchemes={Live4:["#8f9f9a","#c56052","#9f6dbf","#a0b552"],Live8:["#073B4C","#06D6A0","#FFD166","#EF476F","#118AB2","#7F7EFF","#afc765","#78C5E7"],Live16:["#67aec1","#c45a81","#cdc339","#ae8e6b","#6dc758","#a084b6","#667ccd","#cd4f55","#805cd6","#cf622d","#a69e4c","#9b9795","#6db586","#c255b6","#073B4C","#FFD166"],Dark2:d3.schemeDark2,Set1:d3.schemeSet1,Set2:d3.schemeSet2,Set3:d3.scheme,Tableau10:d3.schemeTableau10},styleTemplate=_.template("<%= selector %> { <%= rules %> }"),contentTemplate=_.template("<div id=\"entry-<%= id %>\" <% let style = entry.style || \"\"; %> class=\"section-entry <%= style %>\" >   <% if ((entry.title) &! (entry.kind))  { %>       <h4><%= entry.title %></h4>   <% } %>   <% if (entry.description) { %>       <div class=\"description\"><%= renderMarkdown(entry.description) %></div>   <% } %>   <% if ((entry.kind === \"table\") && (entry.data)) { %>       <%= tableTemplate({id: id, entry: entry}) %>   <% } else if (figureTypes.includes(entry.kind)) { %>       <figure id=\"figure-<%= entry.id || id %>\" data-type=\"<%= entry.kind %>\" data-chart='<%= JSON.stringify(entry) %>' >       </figure>   <% }%>   <% if (entry.notes) { %>       <div class=\"notes\"><%= renderMarkdown(entry.notes) %></div>   <% } %></div>"),sectionTemplate=_.template("<section id=\"section-<%= id %>\" <% let style = section.style || \"col-12\"; %>       class=\"<%= style %>\">       <%  if (section.title)  {%>       <h3 class=\"section-title col-12\"><%= section.title %></h3>       <% } %>       <%  if (section.description)  {%>       <div class=\"description\"><%= renderMarkdown(section.description) %></div>       <% } %>     <% _.each(section.content, function(entry, j){ %><%= contentTemplate({id: id+\"-\"+j, entry: entry}) %><% }); %></section>"),tableTemplate=_.template("<table id=\"table-<%= id %>\" class=\"table table-sm table-hover\"><% if (entry.title) { %>   <caption class=\"text-center\"><%= entry.title %></caption><% } %><% if (entry.header.includes(\"row\")) { %>   <thead><tr>       <% _.each(entry.data[0], function(cell, i){ %>       <th><%= cell %></th>       <% }); %>   </tr></thead><% } %><tbody><% _.each(entry.data, function(row, j){ %>   <% if ((!entry.header.includes(\"row\")) || (j>0)) { %>       <tr>       <% _.each(row, function(cell, i){ %>           <% if (entry.header.includes(\"column\") && (i==0)) { %>               <th><%= cell %></th>           <% } else { %>               <td><%= cell %></td>           <% } %>       <% }); %>       </tr>   <% } %><% }); %></tbody></table>"),NUM_TICKS=10;function drawXYChart(a,b,c,d="spline"){let e=[],f=[],g={},h=d,i={interpolation:{}},j={x:{},y:{},y2:{}},k=[],l=b.data.x[1],m=b.data.x[b.data.x.length-1],n=d3.scaleLinear().domain([l,m]),o=n.ticks(NUM_TICKS),p=function(a){return a},q=function(a){return a},r=2;switch(b.data["x-scale"]){case"time":p=function(a){return Date.parse(a)},j.x=$.extend(j.x,{type:"timeseries",tick:{format:b.data["time-format"],culling:{max:13}}});break;case"pow":case"inv-square":let a="pow"===b.data["x-scale"]?1:-1;p=d3.scalePow().exponent(2*a).domain([l,m]),q=p.invert,n.domain([p(l),p(m)]),o=n.ticks(NUM_TICKS),r=getPrecision(o),j.x=$.extend(j.x,{tick:{values:o,multiline:!1,format:a=>q(a).toFixed(r)}});break;case"log":p=d3.scaleLog().domain([l,m]),q=p.invert,n.domain([p(l),p(m)]),o=n.ticks(NUM_TICKS),r=getPrecision(o),j.x=$.extend(j.x,{tick:{values:o,multiline:!1,format:a=>q(a).toFixed(r)}});break;case"identity":j.x=$.extend(j.x,{type:"index",tick:{multiline:!1}});break;default:j.x=$.extend(j.x,{tick:{values:o,fit:!0,multiline:!1,format:a=>q(a).toFixed(r)}});}b.data["x-limits"]&&(j.x=$.extend(j.x,{min:p(b.data["x-limits"][0]),max:p(b.data["x-limits"][1]),padding:0})),b.data["y1-limits"]&&(j.y=$.extend(j.y,{min:b.data["y1-limits"][0],max:b.data["y1-limits"][1],padding:0})),b.data["y2-limits"]&&(j.y2=$.extend(j.y2,{min:b.data["y2-limits"][0],max:b.data["y2-limits"][1],padding:0})),["cardinal","basis","step","step-before","step-after"].includes(b.data.interpolation)&&(h="spline",i.interpolation.type=b.data.interpolation),$.each(b.data.x,function(a,b){0===a?k.push(b):k.push(p(b))}),j.x.label=b.data["x-label"]||b.data.x[0],f.push(k),a.removeData("chart").removeAttr("data-chart"),$.each(b.data.y1,function(a,c){f.push(c),g[c[0]]="y",e.push(c[0]),0===a&&(j.y.label=b.data["y1-label"]||c[0])}),$.each(b.data.y2,function(a,c){f.push(c),g[c[0]]="y2",e.push(c[0]),j.y2.show=!0,0===a&&(j.y2.label=b.data["y2-label"]||c[0])});let s=d3.scaleOrdinal().domain(e).range(c.scheme);$.each(e,function(a,b){b in c.colors||(c.colors[b]=s(b))});let t=c3.generate({bindto:`#${a.attr("id")}`,size:{width:c.width,height:c.height},data:{type:h,columns:f,colors:c.colors,axes:g,x:b.data.x[0]},spline:i,point:{show:15>b.data.x.length},axis:j,grid:{y:{show:!0}},onresize:function(){this.api.resize({width:a.width(),height:a.width()*c.height/c.width})}});b.data.annotations&&t.xgrids(b.data.annotations),a.data("c3-chart",t)}function drawBarChart(a,b,c){let d=[],e=[],f=[],g="object"==typeof b.data.colors?b.data.colors:{},h=function(a){return a};a.removeData("chart"),a.removeAttr("data-chart");if($.each(b.data.data[0],function(a){a===b.data["color-by"]?f.push(a):a===b.data["x-label"]||d.push(a)}),b.data["color-by"]){let a=b.data["color-by"];$.each(b.data.data,function(b,c){e.includes(c[a])||e.push(c[a])}),h=function(e,f){if("object"==typeof f){let d=b.data.data[f.index][a];return c.colors[d]}return e}}let j=d3.scaleOrdinal().domain(e.concat(d)).range(c.scheme);$.each(d,function(a,b){b in c.colors||(c.colors[b]=j(b))});let k={},l={},m={show:b.data.line&&!0||!1,label:b.data.line};b.data.line&&(l[b.data.line]="line",k[b.data.line]="y2",b.data["line-limits"]&&(m=$.extend(m,{min:b.data["line-limits"][0],max:b.data["line-limits"][1],padding:0})));let n=c3.generate({bindto:`#${a.attr("id")}`,size:{width:c.width,height:c.height},data:{type:"bar",json:b.data.data,hide:f,color:h,colors:c.colors,keys:{x:b.data["x-label"],value:d},axes:b.data.line&&k||{},types:b.data.line&&l||{},groups:b.data.stack||[],order:null},grid:{y:{show:!0}},axis:{x:{type:"category",label:b.data["x-label"]},y2:m,rotated:c.horizontal||!1},legend:{hide:1===d.length},bar:{width:{ratio:.6}},padding:{bottom:20},onresize:function(){this.api.resize({width:a.width(),height:a.width()*c.height/c.width})}});b.data.annotations&&(c.horizontal?n.ygrids(b.data.annotations):n.xgrids(b.data.annotations)),a.data("c3-chart",n)}function drawHistogram(a,b,c){let d=b["y-scale"],e=b.data.data;a.removeData("chart"),a.removeAttr("data-chart");let f=c3.generate({bindto:`#${a.attr("id")}`,size:{width:c.width,height:c.height},data:{type:"bar",json:e,colors:{y:c.scheme[a.parent().index()]},keys:{x:"x",value:["y"]}},axis:{x:{tick:{fit:!1,count:10,format:a=>a.toFixed(1)}},y:{type:d}},legend:{hide:!0},grid:{y:{show:!0}},bar:{width:{ratio:.5}},onresize:function(){this.api.resize({width:a.width(),height:a.width()*c.height/c.width})}});a.data("c3-chart",f)}function drawPieChart(a,b,c){let d={},e=[],f={};a.removeData("chart"),a.removeAttr("data-chart"),$.each(b.data.data,function(a,b){d[b.label]=b.value,e.push(b.label),f[b.label]=b.color||c.scheme[a]});let g=c3.generate({bindto:`#${a.attr("id")}`,size:{width:c.width,height:c.height},data:{type:"pie",json:[d],colors:f,keys:{value:e}},onresize:function(){this.api.resize({width:a.width(),height:a.width()*c.height/c.width})}});a.data("c3-chart",g)}function drawScatterChart(a,b,c){drawXYChart(a,b,c,"scatter")}function drawLineChart(a,b,c){drawXYChart(a,b,c,"line")}function callout(a,b){if(!b)return a.style("display","none");a.attr("data-label")&&(b=`${b} - ${a.attr("data-label")}`),a.attr("data-label"),a.style("display",null).style("pointer-events","none").style("font","10px sans-serif");const c=a.selectAll("path").data([null]).join("path").attr("fill","var(--warning)").attr("stroke","black"),d=a.selectAll("text").data([null]).join("text").call(a=>a.selectAll("tspan").data((b+"").split(/\n/)).join("tspan").attr("x",0).attr("y",(a,b)=>`${1.1*b}rem`).style("font-weight",(a,b)=>b?null:"bold").text(a=>a)),{x:e,y:f,width:g,height:i}=d.node().getBBox();d.attr("transform",`translate(${-g/2},${10-f})`),c.attr("d",`M${-g/2-10},5H-5l5,-5l5,5H${g/2+10}v${i+10}h-${g+20}z`)}function drawTimeline(a,b,c){let d=[],e={top:10,right:10,bottom:10,left:10},f=c.width-e.left-e.right,g=240;$.each(b.data,function(a,b){d.includes(b.type)||d.push(b.type)}),d.sort();let h=d3.scaleOrdinal().domain(d).range(c.scheme),i=d3.timeline().size([f,150]).extent([b.start,b.end]).bandStart(a=>a.start).bandEnd(a=>a.end).padding(2),j=i(b.data),k=d3.scaleLinear().domain([b.start,b.end]).range([0,f]),l=d3.axisBottom().scale(k).tickFormat(d3.timeFormat("%H:%M")),m=d3.select(`#${a.attr("id")}`).append("svg").attr("viewBox",`-${e.left} -${e.top} ${c.width} ${g}`).attr("class","w-100");m.selectAll("rect.event").data(j).enter().append("rect").attr("class","event").attr("x",function(a){return a.start}).attr("x",function(a){return a.start}).attr("y",function(a){return a.y}).attr("height",function(a){return a.dy}).attr("width",function(a){return a.end-a.start}).attr("data-label",a=>`${a.label}`).attr("data-type",a=>a.type).attr("shape-rendering","geometricPrecision").style("fill",a=>h(a.type)).style("stroke",a=>h(a.type)).attr("pointer-events","all").on("mouseover",function(){t.attr("data-label",$(this).data("label"))}).on("mouseout",function(){t.attr("data-label",null)}),m.append("g").call(l).attr("transform","translate(0, 160)");let n=0,o=80,p=m.append("g"),q=p.selectAll(".legend").data(d).enter().append("g").attr("class","legend").attr("data-type",function(a){return a}).attr("transform",function(a,b){if(0===b)return n=a.length+o,"translate(0,0)";else{let b=n;return n+=a.length+o,`translate(${b}, 0)`}}).on("mouseover",function(){let a=$(this).data("type");m.selectAll(`rect.event:not([data-type="${a}"])`).style("opacity",.1)}).on("mouseout",function(){m.selectAll("rect").style("opacity",1)});q.append("rect").attr("x",0).attr("y",0).attr("width",10).attr("height",10).style("fill",a=>h(a)),q.append("text").attr("x",20).attr("y",10).text(function(a){return a}).style("text-anchor","start").style("font-size","10");let r=f/2-n/2,s=g-e.bottom-30;p.attr("transform",`translate(${r}, ${s})`);const t=m.append("g"),u=m.append("g").attr("class","mouse-cursor").append("path").attr("class","mouse-line").style("stroke","var(--warning)").style("stroke-width","1px").style("opacity","0").attr("pointer-events","none");m.on("mouseleave",function(){d3.select(".mouse-line").style("opacity",0),t.call(callout,null)}).on("touchmove mousemove",function(){const a=d3.mouse(this),b=d3.timeFormat("%H:%M %b %d, %Y")(k.invert(a[0]));165>a[1]?(d3.select(".mouse-line").style("opacity",1).attr("d",function(){return`M ${a[0]}, 160, ${a[0]} 0`}),t.attr("transform",`translate(${a[0]}, 164)`).call(callout,b)):(d3.select(".mouse-line").style("opacity",0),t.call(callout,null))}),a.removeData("chart").removeAttr("data-chart"),window.onresize=function(){let b=f/a.width();m.selectAll("text").attr("transform",`scale(${b} ${b})`),m.selectAll("line").attr("stroke-width",`${b}px`)}}(function(a){a.fn.liveReport=function(b){let c=a(this),d=a.extend({data:{}},b);c.addClass("report-viewer"),a.each(d.data.details,function(a,b){c.append(sectionTemplate({id:a,section:b}))}),c.find("figure").each(function(){let b=a(this),c=b.data("chart"),d={width:b.width(),height:b.width()/(c.data["aspect-ratio"]||16/9),colors:{}};switch(Array.isArray(c.data.colors)?d.scheme=c.data.colors:"object"==typeof c.data.colors?(d.scheme=ColorSchemes.Live16,d.colors=c.data.colors):d.scheme=ColorSchemes[c.data.colors]||ColorSchemes.Live16,b.data("type")){case"barchart":d.horizontal=!0,drawBarChart(b,c,d);break;case"columnchart":drawBarChart(b,c,d);break;case"lineplot":drawLineChart(b,c,d);break;case"histogram":drawHistogram(b,c,d);break;case"pie":drawPieChart(b,c,d);break;case"scatterplot":drawScatterChart(b,c,d);break;case"timeline":drawTimeline(b,c,d);}c.title?b.after(`<figcaption class="text-center">${c.title}</figcaption>`):b.after(`<figcaption class="text-center"></figcaption>`)})}})(jQuery);