diff --git a/alamode.js b/alamode.js
index 9058552..9032a5f 100644
--- a/alamode.js
+++ b/alamode.js
@@ -115,12 +115,14 @@ var alamode = {
cName = url.substring(start+2,start+end+2),
full = url.substring(start,start+end+4),
col = colIndex[cName],
- content = data[rowKey][cName];
+ content = data[rowKey][cName],
+ escaped = encodeURIComponent(content);
- url = url.replace(full,content);
+ url = url.replace(full, escaped);
}
- cells.eq(columnToShow).html("" + cellContent + "")
+ var newCellContent = $("", {href: url}).text(cellContent);
+ cells.eq(columnToShow).empty().append(newCellContent);
})
}
})
diff --git a/alamode.min.js b/alamode.min.js
index 6633708..df9b576 100644
--- a/alamode.min.js
+++ b/alamode.min.js
@@ -1,3 +1,2 @@
-var version="0.20";var alamode={reportError:function(msg){$("").text(msg).prependTo(document.body)},getColumnsFromQuery:function(queryName){var columns=datasets.filter(function(d){if(d){return d.queryName==queryName}})[0];if(!columns){alamode.reportError("No such query: '"+queryName+"'");return[]}return columns.columns},getDataFromQuery:function(queryName){var data=datasets.filter(function(d){if(d){return d.queryName==queryName}})[0];if(!data){alamode.reportError("No such query: '"+queryName+"'");return[]}return data.content},makeId:function(chars){var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",text="";for(var i=0;i
"})},forceDirectedGraph:function(o){var id=alamode.makeId(10);var nodeQuery=o["node_query"],edgeQuery=o["edge_query"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,width=o["chart_width"]||"800",height=o["chart_height"]||"800",colors=o["group_colors"]||"",visibleLinks=o["links_to_show"]||100;var nodes=alamode.getDataFromQuery(nodeQuery),initialLinks=alamode.getDataFromQuery(edgeQuery);var links=[];initialLinks.forEach(function(l){var match1=links.filter(function(d){return d.target==l.source}),match2=match1.filter(function(d){return d.source==l.target});if(match2.length!=0){match2["edge_size"]+=l.edge_size}else{links.push(l)}});links=links.sort(function(a,b){return b.edge_size-a.edge_size});links=links.slice(0,visibleLinks);nameMap={};nodes.forEach(function(d,i){d["id"]=i;nameMap[d.node]=i});links.forEach(function(d){d["source_id"]=nameMap[d.source];d["target_id"]=nameMap[d.target]});var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-force-directed-graph").style("width",width).attr("id",id);var tip=d3.tip().attr("class","mode-force-directed-graph-tooltip").offset([-10,0]).html(function(d){return d.node});var force=d3.layout.force().linkDistance(40).linkStrength(1).size([width,height]);var svg=d3.select("#"+id).append("svg").attr("width",width).attr("height",height);svg.call(tip);var graph={nodes:nodes,links:links};var nodeSizeScale=d3.scale.linear().domain(d3.extent(nodes,function(d){return d.node_size})).range([2,20]);var edgeSizeScale=d3.scale.linear().domain(d3.extent(links,function(d){return d.edge_size})).range([1,10]);var edgeOpacityScale=d3.scale.linear().domain(d3.extent(links,function(d){return d.edge_size})).range([.1,.9]);var nodes=graph.nodes.slice(),links=[],bilinks=[];graph.links.forEach(function(link){var s=nodes[link.source_id],t=nodes[link.target_id],i={};i["connections"]=link["edge_size"];nodes.push(i);links.push({source:s,target:i},{source:i,target:t});bilinks.push([s,i,t])});force.nodes(nodes).links(links).start();var link=svg.selectAll(".mode-force-directed-graph-link ").data(bilinks).enter().append("path").attr("class","mode-force-directed-graph-link").style("stroke-width",function(d){return edgeSizeScale(d[1]["connections"])}).style("opacity",function(d){return edgeOpacityScale(d[1]["connections"])});var node=svg.selectAll(".mode-force-directed-graph-node").data(graph.nodes).enter().append("g").attr("class","mode-force-directed-graph-node").call(force.drag);node.append("circle").attr("r",function(d){return nodeSizeScale(d.node_size)}).style("fill",function(d){if(colors){return colors[d.node_group]}else{return"#0E819A"}}).on("mouseover",tip.show).on("mouseout",tip.hide);force.on("tick",function(){link.attr("d",function(d){return"M"+d[0].x+","+d[0].y+"S"+d[1].x+","+d[1].y+" "+d[2].x+","+d[2].y});node.attr("transform",function(d){return"translate("+d.x+","+d.y+")"})})},networkMatrix:function(o){var id=alamode.makeId(10);var nodeQuery=o["node_query"],edgeQuery=o["edge_query"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,padding=o["padding_for_names"]||"200",width=o["chart_width"]||"800",height=o["chart_height"]||"800",colors=o["group_colors"]||"",leftLabel=o["left_label"]||"",topLabel=o["top_label"]||"";var margin={top:padding,right:10,bottom:10,left:padding};var nodes=alamode.getDataFromQuery(nodeQuery),links=alamode.getDataFromQuery(edgeQuery);nameMap={};nodes.forEach(function(d,i){d["id"]=i;nameMap[d.node]=i});links.forEach(function(d){d["source_id"]=nameMap[d.source];d["target_id"]=nameMap[d.target]});var x=d3.scale.ordinal().rangeBands([0,width]);var z=d3.scale.linear().domain(d3.extent(links,function(d){return d.edge_size})).clamp(true);var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-network-matrix-order-picker").html(' "}setTimeout(function(){if(tableId=="#"){table=$(".main-table");container=$(".js-table-content-container")}else{table=$(tableId+" .main-table");container=$(tableId+" .js-table-content-container")}var lastRow=table.find("tr:last");var totalRow=makeRow(totals);var tableHeight=container.css("height");var tableHeightInt=+tableHeight.match(/\d+/)[0];lastRow.after(totalRow);container.css("height",tableHeightInt+26)},1e3)},addImagesToTables:function(o){var tableId="#"+o["table"],imageColumn=o["column"],imgHeight=o["image_height"]||100;setTimeout(function(){drawImages()},1e3);$(tableId).keyup(function(){setTimeout(function(){drawImages()},500)});$(tableId).mousemove(function(){drawImages()});function drawImages(){var tableDiv=$(tableId+" table"),tableHeader=$(tableId+" .js-header-table"),headers=!tableHeader?$(tableHeader).find("th"):$(tableId+" .js-col-header"),rows=tableDiv.find("tr"),columnIndex=0;headers.each(function(){text=$(this).find(".axel-table-header-label").text();if(text==imageColumn){columnIndex=+$(this).attr("data-axel-column")}});rows.each(function(){var cells=$(this).find("td");cells.each(function(i){if(i==columnIndex-1){var content=$(this).text();if($(this).find("img").length==0){$(this).css("text-align","center");$(this).html("")}}})})}},resizeChartHeight:function(o){var chart=o["chart"],height=o["height"];if(chart.slice(0,6)=="python"){$("#"+chart+" .mode-python").css("height",height);$("#"+chart+" .mode-python").css("max-height",height);$("#"+chart+" img").css("max-height",height)}else{$("#"+chart+" .chart").css("height",height);$("#"+chart+" .chart-svg").css("height",height)}window.dispatchEvent(new Event("resize"))},retentionHeatmap:function(o){var queryName=o["query_name"],cohortColumn=o["cohort_column"],pivotColumn=o["pivot_column"],valueColumn=o["value_column"],colors=o["color_gradient"]||["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"],totalColumn=o["total_column"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,pivotLabel=o["pivot_label"]||"",isPercent=o["value_is_percent"],precision=o["precision"]||0;var data=alamode.getDataFromQuery(queryName),columns=alamode.getColumnsFromQuery(queryName),cohorts=_.uniq(_.map(data,cohortColumn)),pivots=_.uniq(_.map(data,pivotColumn));var uniqContainerClass=alamode.addContainerElement(htmlElement);var color=d3.scale.quantize().domain(d3.extent(data,function(d){return d[valueColumn]})).range(colors);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-retention-heatmap-label").text(pivotLabel);if(totalColumn){headers=[cohortColumn,totalColumn].concat(pivots)}else{headers=[cohortColumn].concat(pivots)}var table=d3.select(uniqContainerClass).append("table").attr("class","mode-retention-heatmap-table");table.selectAll(".mode-retention-heatmap-table-header").data([0]).enter().append("tr").attr("class","mode-retention-heatmap-table-header").selectAll("mode-retention-heatmap-table-header-cell").data(headers).enter().append("td").attr("class",function(d){if(isNaN(d)){return"mode-retention-heatmap-table-header-cell heatmap-string"}else{return"mode-retention-heatmap-table-header-cell heatmap-number"}}).text(function(d){return d});table.selectAll(".mode-retention-heatmap-table-row").data(cohorts).enter().append("tr").attr("class","mode-retention-heatmap-table-row").selectAll(".mode-retention-heatmap-table-cell").data(function(d){return makeRow(data,d)}).enter().append("td").style("background",function(d){if(checkShade(d)){return color(d.value)}}).attr("class",function(d){return cellClass(d)}).text(function(d){return fmt(d,o)});function checkShade(entry){if(entry.value==""){return false}else if(entry.column==pivotColumn||entry.column==totalColumn){return false}else if(entry.column==valueColumn){return true}else{return false}}function cellClass(entry){var type=getDataType(entry.column);if(type=="float"||type=="integer"||type=="number"){return"heatmap-number"}else{return"heatmap-string"}}function getDataType(column){return columns.filter(function(d){return d.name==column})[0].type}function makeRow(data,cohort){var row=[{column:cohortColumn,value:cohort}];if(totalColumn){var total=_.filter(data,function(d){return d[cohortColumn]==cohort})[0],totalObject={column:totalColumn,value:total[totalColumn]};row=row.concat(totalObject)}pivots.forEach(function(p){var matches=_.filter(data,function(d){return d[cohortColumn]==cohort&&d[pivotColumn]==p});if(matches.length>0){entry=d3.mean(_.map(matches,valueColumn))}else{entry=""}row=row.concat({column:valueColumn,value:entry})});return row}function fmt(entry){var type=getDataType(entry.column);var c=d3.format(","),p=d3.format("."+precision+"%"),t=d3.time.format("%b %d, %Y");if(entry.value==""){return entry.value}else if(type=="datetime"||type=="timestamp"||type=="date"){if(typeof moment=="function"){return moment(entry.value).utc().format("ll")}else{return t(new Date(entry.value))}}else if(entry.column==totalColumn){return c(entry.value)}else if(entry.column==valueColumn&&isPercent){return p(entry.value)}else if(entry.column==valueColumn){return c(entry.value)}else{return entry.value}}},googleMap:function(o){var id=alamode.makeId(10);var latColumn=o["lat_column"],lngColumn=o["lng_column"],queryName=o["query_name"],apiKey=o["google_maps_api_key"],title=o["title"]||queryName,labelColumn=o["label_column"],htmlElement=o["html_element"]||"body",centerLat=o["center_lat"]||39.5,centerLng=o["center_lng"]||-98.35,zoom=o["starting_zoom"]||4,mapType=o["map_type"]||"terrain",mapHeight=o["height"]||600;var data=alamode.getDataFromQuery(queryName);var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-google-map").attr("id",id).style("height",mapHeight+"px");jQuery.getScript("https://maps.googleapis.com/maps/api/js?key="+apiKey,function(){initMap();function initMap(){var myOptions={zoom:zoom,center:new google.maps.LatLng(centerLat,centerLng),mapTypeId:mapType};var map=new google.maps.Map(document.getElementById(id),myOptions);data.forEach(function(d){var lat=d[latColumn],lng=d[lngColumn];if(labelColumn){label=d[labelColumn]}else{label=""}var marker=new google.maps.Marker({position:{lat:lat,lng:lng},map:map,title:label});var infowindow=new google.maps.InfoWindow({content:label});marker.addListener("click",function(){infowindow.open(map,marker)})})}})},leafletMap:function(o){var id=alamode.makeId(10);var latColumn=o["lat_column"],lngColumn=o["lng_column"],queryName=o["query_name"],title=o["title"]||queryName,height=o["height"]||400,htmlElement=o["html_element"]||"body",centerLat=o["center_lat"]||39.5,centerLng=o["center_lng"]||-98.35,zoom=o["starting_zoom"]||4,dotRadius=o["dot_size"]||.4,dotOpacity=o["dot_opacity"]||.8,applyFilter=o["apply_filter"]||false;var data=alamode.getDataFromQuery(queryName),validData=[];data.forEach(function(d){if(typeof d[latColumn]==="number"&&typeof d[lngColumn]==="number"){validData.push(d)}});var uniqContainerClass=alamode.addContainerElement(htmlElement,applyFilter);d3.select(uniqContainerClass).style("height",height+"px").append("div").attr("class","mode-graphic-title").text(title);var mapHeight=height-$(uniqContainerClass+".mode-graphic-title").height(),mapWidth=$(uniqContainerClass).width();d3.select(uniqContainerClass).append("div").attr("class","mode-leaflet-map").attr("id",id).style("height",mapHeight+"px").style("width",mapWidth+"px");var baseLayer=L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:18});var d={max:8,data:validData};var cfg={radius:dotRadius,maxOpacity:dotOpacity,scaleRadius:true,useLocalExtrema:true,latField:latColumn,lngField:lngColumn};var C={lat:centerLat,lng:centerLng,zoom:zoom};var heatmapLayer=new HeatmapOverlay(cfg);var map=new L.Map(id,{center:new L.LatLng(C.lat,C.lng),zoom:Math.floor(C.zoom),layers:[baseLayer,heatmapLayer]});heatmapLayer.setData(d)},wordCloud:function(o){var queryName=o["query_name"],words=o["word_column"],wordCount=o["word_count_column"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,height=o["height"]||"400",width=o["width"]||"800",colors=o["colors"]||["black"];var data=alamode.getDataFromQuery(queryName);var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);var textScale=d3.scale.linear().domain(d3.extent(data,function(d){return d[wordCount]})).range([12,60]);var layout=d3.layout.cloud().size([width,height]).words(data.map(function(d){return{text:d[words],size:textScale(d[wordCount])}})).padding(2).rotate(function(){return(~~(Math.random()*6)-3)*360}).font("Impact").fontSize(function(d){return d.size}).on("end",draw);layout.start();function draw(words){d3.select(uniqContainerClass).append("div").attr("class","mode-wordcloud").append("svg").attr("width",layout.size()[0]).attr("height",layout.size()[1]).append("g").attr("transform","translate("+layout.size()[0]/2+","+layout.size()[1]/2+")").selectAll("text").data(words).enter().append("text").style("font-size",function(d){return d.size+"px"}).style("font-family","Impact").style("fill",function(d,i){return colors[i%colors.length]}).attr("text-anchor","middle").attr("transform",function(d){return"translate("+[d.x,d.y]+")rotate("+d.rotate+")"}).text(function(d){return d.text})}},funnel:function(o){var id=alamode.makeId(10);var queryName=o["query_name"],stageColumn=o["stage_column"],valueColumn=o["value_column"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,height=o["height"]||"300",width=o["width"]||"500";var data=alamode.getDataFromQuery(queryName);var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-funnel").attr("id",id).style("width",width+"px").style("height",height-20+"px");var funnelData=[];data.forEach(function(d){funnelData.push([d[stageColumn],d[valueColumn]])});var options={label:{format:"{l}: {f}"},block:{dynamicHeight:true},chart:{bottomPinch:1},animation:100};var chart=new D3Funnel("#"+id);chart.draw(funnelData,options);d3.select("#"+id).style("height",height+"px")},horizontalBarChart:function(o){var queryName=o["query_name"],barColumn=o["bar_column"],seriesColumns=o["series_columns"],colors=o["colors"]||["#EE8D24","#43A5DA","#6AB328","#BB60F8","#E14459","#EAD022","#06D0AD","#DB38B7"];stacked=o["stacked"]||false,leftpad=o["left_pad"]||175,htmlElement=o["html_element"]||"body",title=o["title"]||queryName,height=o["chart_height"]||395,width=o["width"]||"500";var data=alamode.getDataFromQuery(queryName);var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-horizontal-bar-chart").style("height",height-50+"px").append("svg");var nvData=[];seriesColumns.forEach(function(s,i){var seriesObj={key:s,color:colors[i%colors.length]};var seriesData=[];data.forEach(function(d){seriesData.push({label:d[o["bar_column"]],value:d[s]})});seriesObj["values"]=seriesData;nvData.push(seriesObj)});nv.addGraph(function(){var chart=nv.models.multiBarHorizontalChart().x(function(d){return d.label}).y(function(d){return d.value}).margin({top:30,right:20,bottom:50,left:leftpad}).showValues(true).showControls(false).stacked(stacked);chart.yAxis.tickFormat(d3.format(",.2f"));d3.select(uniqContainerClass+" svg").datum(nvData).call(chart);nv.utils.windowResize(chart.update);return chart})},chartAnnotations:function(o){var chart="#"+o["chart_id"],xAxis=o["x_axis_column"],queryName=o["query_name"],orientations=o["orientations"],values=o["comment_values"],groupBy=o["group_by"],comments=o["comments"];var data=alamode.getDataFromQuery(queryName);var pointNumbers=[];var dataGroups={};if(groupBy){dataGroups=_.groupBy(data,function(d){return d[groupBy]})}comments.forEach(function(c,i){var match=_.filter(data,function(d){return d[xAxis]==values[i]});if(match.length!=0){if(groupBy){pointNumber=dataGroups[match[0][groupBy]].indexOf(match[0])}else{pointNumber=data.indexOf(match[0])}}else{pointNumber=-1}pointNumbers.push(pointNumber)});function drawComments(){comments.forEach(function(c,i){var pointNumber=pointNumbers[i],orientation=orientations[i],value=values[i];var tip=d3.tip().attr("class","d3-tip").style("z-index",100).offset([-10,0]).html(function(d){return d});var translate=$(chart).find("g.nvd3.nv-wrap").attr("transform"),openPos=translate.indexOf("("),closePos=translate.indexOf(")"),commaPos=translate.indexOf(",");var xTrans=+translate.slice(openPos+1,commaPos),yTrans=+translate.slice(commaPos+1,closePos);if(pointNumber!=-1&&orientation=="v"){var pointTranlate=$(chart).find(".nv-point.nv-point-"+pointNumber).attr("transform"),pointOpenPos=pointTranlate.indexOf("("),pointClosePos=pointTranlate.indexOf(")"),pointCommaPos=pointTranlate.indexOf(",");var xPoint=+pointTranlate.slice(pointOpenPos+1,pointCommaPos),yPoint=+pointTranlate.slice(pointCommaPos+1,pointClosePos);var height=$(chart).find("g.nvd3.nv-wrap").first().find("rect").first().attr("height"),width=$(chart).find("g.nvd3.nv-wrap").first().find("rect").first().attr("width");var svg=d3.select(chart+" .nvd3svg");svg.call(tip);svg.append("rect").attr("x",xPoint+xTrans).attr("y",yTrans-5).attr("width",1).attr("class","flag").attr("height",yPoint+5).attr("fill","#ff8f53");svg.append("circle").data([c]).attr("cx",xPoint+xTrans).attr("cy",yTrans-5).attr("class","flag").attr("r",5).attr("fill","#ff8f53").on("mouseover",tip.show).on("mouseout",tip.hide)}else if(orientation=="h"||orientation=="h-left"||orientation=="h-right"){if(orientation=="h"){y=""}else if("h-left"){y="1"}else{y="2"}var ticks=$(chart).find("g.nv-y"+y+".nv-axis").find(".tick");ticks.each(function(t){if(orientation=="h-right"){lineLength=+$(chart).find("g.nv-y1.nv-axis").find(".tick").first().find("line").attr("x2")}else{lineLength=+$(this).find("line").attr("x2")}tickTrans=$(this).attr("transform");tickClosePos=tickTrans.indexOf(")"),tickCommaPos=tickTrans.indexOf(",");if(t==0){yTrans1=+tickTrans.slice(tickCommaPos+1,tickClosePos);yVal1=+$(this).find("text").text().replace(",","")}else if(t==1){yTrans2=+tickTrans.slice(tickCommaPos+1,tickClosePos);yVal2=+$(this).find("text").text().replace(",","")}});var scalar=(yTrans2-yTrans1)/(yVal2-yVal1),intercept=yTrans2-yVal2*scalar;var lineLocation=intercept+value*scalar;var svg=d3.select(chart+" .nvd3svg");svg.call(tip);svg.append("rect").attr("x",xTrans).attr("y",lineLocation+yTrans).attr("width",lineLength+10).attr("height",1).attr("class","flag").attr("fill","#ff8f53");svg.append("circle").data([c]).attr("cx",lineLength+xTrans+10).attr("cy",lineLocation+yTrans).attr("class","flag").attr("r",5).attr("fill","#ff8f53").on("mouseover",tip.show).on("mouseout",tip.hide)}})}setTimeout(function(){d3.select(chart).selectAll(".flag").remove();drawComments()},1e3);$(window).resize(function(){d3.select(chart).selectAll(".flag").remove();waitForFinalEvent(function(){drawComments()},500,"")});var waitForFinalEvent=function(){var timers={};return function(callback,ms,uniqueId){if(!uniqueId){uniqueId="Don't call this twice without a uniqueId"}if(timers[uniqueId]){clearTimeout(timers[uniqueId])}timers[uniqueId]=setTimeout(callback,ms)}}()},bulletChart:function(o){var id=alamode.makeId(10);var queryName=o["query_name"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,width=o["chart_width"]||"800",barLabel=o["bar_column"]||"",markerLabel=o["marker_column"]||"",leftpad=o["left_pad"]||150,color=o["color"];var data=alamode.getDataFromQuery(queryName);var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-bullet-chart").style("width",width).attr("id",id);data.forEach(function(d){var title=d[o["title_column"]]||"",subtitle=d[o["subtitle_column"]]||"",marker=d[o["marker_column"]]||"",bar=d[o["bar_column"]]||"";if(o["scale_columns"]){scale=[d[o["scale_columns"][0]],d[o["scale_columns"][1]],d[o["scale_columns"][2]]]}else{scale=o["scale_columns"]}var bulletData={title:title,subtitle:subtitle,ranges:scale,measures:[bar],measureLabels:[barLabel],markers:[marker],markerLabels:[markerLabel],color:color};nv.addGraph(function(){var chart=nv.models.bulletChart().height(50).width(width).margin({left:leftpad,right:15,top:10,bottom:10});var svg=d3.select("#"+id).append("svg").style("width",width+"px").style("height",70+"px").style("display","inline").datum(bulletData).transition().duration(500).call(chart);return chart})})},sunburstChart:function(o){var id=alamode.makeId(10);var queryName=o["query_name"],eventColumns=o["event_columns"],valueColumn=o["event_counts"],title=o["title"]||queryName,colorRange=o["color_range"]||["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],htmlElement=o["html_element"]||"body";var data=alamode.getDataFromQuery(queryName);var height=600,width=850,radius=Math.min(width,height)/2,breadcrumbWidth=(width-30)/eventColumns.length,b={w:breadcrumbWidth,h:20,s:3,t:10};var fullEventList=[];eventColumns.forEach(function(e){fullEventList=fullEventList.concat(_.uniq(_.map(data,e)))});var events=_.uniq(fullEventList);var colors={};events.forEach(function(e,i){if(e!=null){colors[e]=colorRange[i%colorRange.length]}});colors["end"]="#666";var totalSize=0;var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-sunburst-sequence").attr("id","sequence-"+id);d3.select(uniqContainerClass).append("div").attr("class","mode-sunburst").attr("id",id);d3.select(uniqContainerClass).append("div").attr("class","mode-sunburst-legend-container").attr("id","legend-container-"+id);vis=d3.select("#"+id).append("svg:svg").attr("width",width).attr("height",height).append("svg:g").attr("transform","translate("+width/2+","+height/2+")");vis.append("text").attr("x",0).attr("y",-30).attr("text-anchor","middle").attr("class","mode-sunburst-explanation mode-sunburst-percentage").attr("id","percentage-"+id).style("visibility","hidden").text("");vis.append("text").attr("x",0).attr("y",-10).attr("text-anchor","middle").attr("class","mode-sunburst-explanation").style("visibility","hidden").text("of total sequences.");vis.append("text").attr("x",0).attr("y",20).attr("text-anchor","middle").attr("class","mode-sunburst-explanation mode-sunburst-cond-percentage").attr("id","cond-percentage-"+id).style("visibility","hidden").text("");vis.append("text").attr("x",0).attr("y",40).attr("text-anchor","middle").attr("class","mode-sunburst-explanation").style("visibility","hidden").text("from previous location.");var partition=d3.layout.partition().size([2*Math.PI,radius*radius]).value(function(d){return d.size});var arc=d3.svg.arc().startAngle(function(d){return d.x}).endAngle(function(d){return d.x+d.dx}).innerRadius(function(d){return Math.sqrt(d.y)}).outerRadius(function(d){return Math.sqrt(d.y+d.dy)});var formattedData=[];data.forEach(function(d){var sequence="";for(i=0;iTTL ";totals.forEach(function(t){if(t.total!=""){rowString=rowString+""+fmt(t.total)+" "}else{rowString=rowString+""}});return rowString+"
Order: ');d3.select(uniqContainerClass).append("div").attr("class","mode-network-matrix").style("width",width).attr("id",id);var tip=d3.tip().attr("class","mode-network-matrix-tooltip").offset([-10,0]).html(function(d){return d.z});var svg=d3.select("#"+id).append("svg").attr("width",width+margin.left+margin.right).attr("height",height+margin.top+margin.bottom);svg.call(tip);var g=svg.append("g").attr("transform","translate("+margin.left+","+margin.top+")");graph={nodes:nodes,links:links};var matrix=[],nodes=graph.nodes,n=nodes.length;nodes.forEach(function(node,i){node.index=i;node.count=0;matrix[i]=d3.range(n).map(function(j){return{x:j,y:i,z:0}})});graph.links.forEach(function(link){if(typeof matrix[link.source_id][link.target_id]!=="undefined"){matrix[link.source_id][link.target_id].z+=link.edge_size;nodes[link.source_id].count+=link.edge_size;nodes[link.target_id].count+=link.edge_size}else{matrix[link.source_id][link.target_id]={};matrix[link.source_id][link.target_id]["z"]=0}});var orders={name:d3.range(n).sort(function(a,b){return d3.ascending(nodes[a].node,nodes[b].node)}),count:d3.range(n).sort(function(a,b){return nodes[b].count-nodes[a].count}),group:d3.range(n).sort(function(a,b){return d3.ascending(nodes[a].node_group,nodes[b].node_group)})};x.domain(orders.name);svg.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(width+margin.left+margin.right)/2).attr("y",25).attr("text-anchor","middle").text(topLabel);svg.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(height+margin.top+margin.bottom)/-2).attr("y",25).attr("transform","rotate(-90)").attr("text-anchor","middle").text(leftLabel);g.append("rect").attr("class","mode-network-matrix-background").attr("width",width).attr("height",height);var row=g.selectAll(".mode-network-matrix-row").data(matrix).enter().append("g").attr("class","mode-network-matrix-row").attr("transform",function(d,i){return"translate(0,"+x(i)+")"}).each(row);row.append("line").attr("class","mode-network-matrix-line").attr("x2",width);row.append("text").attr("class","mode-network-matrix-row-text").attr("x",-6).attr("y",x.rangeBand()/2).attr("dy",".32em").attr("text-anchor","end").text(function(d,i){return nodes[i].node});var column=g.selectAll(".mode-network-matrix-column").data(matrix).enter().append("g").attr("class","mode-network-matrix-column").attr("transform",function(d,i){return"translate("+x(i)+")rotate(-90)"});column.append("line").attr("class","mode-network-matrix-line").attr("x1",-width);column.append("text").attr("class","mode-network-matrix-column-text").attr("x",6).attr("y",x.rangeBand()/2).attr("dy",".32em").attr("text-anchor","start").text(function(d,i){return nodes[i].node});function row(row){var cell=d3.select(this).selectAll(".mode-network-matrix-cell").data(row.filter(function(d){return d.z})).enter().append("rect").attr("class","mode-network-matrix-cell").attr("x",function(d){return x(d.x)}).attr("width",x.rangeBand()).attr("height",x.rangeBand()).style("fill-opacity",function(d){return z(d.z)}).style("fill",function(d){return nodes[d.x].node_group==nodes[d.y].node_group?colors[nodes[d.x].node_group]:"#2B2B2B"}).on("mouseover",function(d){mouseover(d);tip.show(d)}).on("mouseout",function(d){mouseout(d);tip.hide(d)})}function mouseover(p){d3.selectAll(".mode-network-matrix-row-text").classed("active",function(d,i){return i==p.y});d3.selectAll(".mode-network-matrix-column-text").classed("active",function(d,i){return i==p.x})}function mouseout(){d3.selectAll("text").classed("active",false)}d3.select("#mode-network-matrix-order-picker-"+id).on("change",function(){order(this.value)});function order(value){x.domain(orders[value]);var t=g.transition().duration(1e3);t.selectAll(".mode-network-matrix-row").attr("transform",function(d,i){return"translate(0,"+x(i)+")"}).selectAll(".mode-network-matrix-cell").attr("x",function(d){return x(d.x)});t.selectAll(".mode-network-matrix-column").attr("transform",function(d,i){return"translate("+x(i)+")rotate(-90)"})}},hive:function(o){d3.hive={},d3.hive.link=function(){function t(t,s){var u,h=a(r,this,t,s),i=a(n,this,t,s);h.a>i.a&&(u=i,i=h,h=u),i.a-h.a>Math.PI&&(h.a+=2*Math.PI);var e=h.a+(i.a-h.a)/3,c=i.a-(i.a-h.a)/3;return h.r0-h.r1||i.r0-i.r1?"M"+Math.cos(h.a)*h.r0+","+Math.sin(h.a)*h.r0+"L"+Math.cos(h.a)*h.r1+","+Math.sin(h.a)*h.r1+"C"+Math.cos(e)*h.r1+","+Math.sin(e)*h.r1+" "+Math.cos(c)*i.r1+","+Math.sin(c)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1+"L"+Math.cos(i.a)*i.r0+","+Math.sin(i.a)*i.r0+"C"+Math.cos(c)*i.r0+","+Math.sin(c)*i.r0+" "+Math.cos(e)*h.r0+","+Math.sin(e)*h.r0+" "+Math.cos(h.a)*h.r0+","+Math.sin(h.a)*h.r0:"M"+Math.cos(h.a)*h.r0+","+Math.sin(h.a)*h.r0+"C"+Math.cos(e)*h.r1+","+Math.sin(e)*h.r1+" "+Math.cos(c)*i.r1+","+Math.sin(c)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1}function a(t,a,r,n){var e=t.call(a,r,n),c=+("function"==typeof s?s.call(a,e,n):s)+i,o=+("function"==typeof u?u.call(a,e,n):u),M=u===h?o:+("function"==typeof h?h.call(a,e,n):h);return{r0:o,r1:M,a:c}}var r=function(t){return t.source},n=function(t){return t.target},s=function(t){return t.angle},u=function(t){return t.radius},h=u,i=-Math.PI/2;return t.source=function(a){return arguments.length?(r=a,t):r},t.target=function(a){return arguments.length?(n=a,t):n},t.angle=function(a){return arguments.length?(s=a,t):s},t.radius=function(a){return arguments.length?(u=h=a,t):u},t.startRadius=function(a){return arguments.length?(u=a,t):u},t.endRadius=function(a){return arguments.length?(h=a,t):h},t};var id=alamode.makeId(10);var nodeQuery=o["node_query"],edgeQuery=o["edge_query"],isNumeric=o["groups_are_numeric"],htmlElement=o["html_element"]||"body",title=o["title"]||queryName,width=o["chart_width"]||"800",height=o["chart_height"]||"800",colors=o["group_colors"]||"";var outerRadius=Math.min(width,height)/2-30,innerRadius=outerRadius*.2;var nodes=alamode.getDataFromQuery(nodeQuery),links=alamode.getDataFromQuery(edgeQuery);var groups=_.uniq(_.map(nodes,"node_group"));var nameMap={};nodes.forEach(function(d){if(isNumeric){d.x=d.node_group}else{d.x=groups.indexOf(d.node_group)}d.y=d.node_size;nameMap[d.node]=d});links.forEach(function(l){l.source=nameMap[l.source],l.target=nameMap[l.target]});var uniqContainerClass=alamode.addContainerElement(htmlElement);d3.select(uniqContainerClass).append("div").attr("class","mode-graphic-title").text(title);d3.select(uniqContainerClass).append("div").attr("class","mode-network-matrix").style("width",width).attr("id",id);if(isNumeric){angle=d3.scale.linear().domain(d3.extent(nodes,function(d){return d.node_group})).range([0,2*Math.PI])}else{angle=d3.scale.ordinal().domain(d3.range(groups.length+1)).rangePoints([0,2*Math.PI])}var radius=d3.scale.linear().domain(d3.extent(nodes,function(d){return d.node_size})).range([innerRadius,outerRadius]);var tip=d3.tip().attr("class","mode-hive-tooltip").offset([-10,0]).html(function(d){return d.node});var svg=d3.select("#"+id).append("svg").attr("width",width).attr("height",height).append("g").attr("transform","translate("+width/2+","+height/2+")");svg.call(tip);svg.selectAll(".mode-hive-axis").data(d3.range(groups.length)).enter().append("line").attr("class","mode-hive-axis").attr("transform",function(d){return"rotate("+degrees(angle(d))+")"}).attr("x1",radius.range()[0]).attr("x2",radius.range()[1]);svg.selectAll(".mode-hive-link").data(links).enter().append("path").attr("class","mode-hive-link").attr("d",d3.hive.link().angle(function(d){return angle(d.x)}).radius(function(d){return radius(d.y)})).style("stroke",function(d){return colors[d.source.node_group]});svg.selectAll(".mode-hive-node").data(nodes).enter().append("circle").attr("class","mode-hive-node").attr("transform",function(d){return"rotate("+degrees(angle(d.x))+")"}).attr("cx",function(d){return radius(d.y)}).attr("r",5).style("fill",function(d){return colors[d.node_group]}).on("mouseover",function(d){tip.show(d);d3.select(this).attr("class","mode-hive-node mode-hive-node-selected");d3.selectAll(".mode-hive-link").data(links).attr("class",function(l){if(l.source.node==d.node){return"mode-hive-link-selected"}else if(l.target.node==d.node){return"mode-hive-link-selected"}else{return"mode-hive-link"}})}).on("mouseout",function(d){tip.hide(d);d3.select(this).attr("class","mode-hive-node");d3.selectAll(".mode-hive-link-selected").attr("class","mode-hive-link")});function degrees(radians){return radians/Math.PI*180-90}},conditionalFormattingByColumn:function(o){var tableId="#"+o["table_id"],queryName=o["query_name"],columnRules=o["column_rules"];var data=alamode.getDataFromQuery(queryName),columns=alamode.getColumnsFromQuery(queryName);var colIndex={};setTimeout(function(){shade(columnRules)},1e3);$(tableId).mousemove(function(){shade(columnRules)});function shade(columnRules){var tableDiv=$(tableId+" table"),tableHeader=$(tableId+" .js-header-table"),headers=!tableHeader?$(tableHeader).find("th"):$(tableId+" .js-col-header"),rows=tableDiv.find("tr"),columnIndex=0;headers.each(function(){text=$(this).find(".axel-table-header-label").text();columnIndex=$(this).attr("data-axel-column");colIndex[text]=columnIndex});columnRules.forEach(function(c){c.rules.forEach(function(r){var colorText=r.shade_text||false;if(r.type=="gradient"){drawGradient(c.column,r.color,colorText)}else if(r.type=="above"||r.type=="below"||r.type=="equal"){drawThreshold(c.column,r.type,r.value,r.color,colorText)}})})}function drawGradient(column,color,colorText){var range=d3.extent(_.map(data,column));var scale=d3.scale.linear().domain(range).interpolate(d3.interpolateHsl).range(color);var idx=colIndex[column];data.forEach(function(d,i){var selector=tableId+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+idx+"']",selectedColor=scale(d[column]),textColor=getTextColor(selectedColor),cell=$(selector);if(colorText){cell.css("color",selectedColor)}else{cell.css({background:selectedColor,color:textColor})}})}function drawThreshold(column,type,threshold,color,colorText){var idx=colIndex[column];var textColor=getTextColor(color);data.forEach(function(d,i){var selector=tableId+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+idx+"']",cell=$(selector);if(type=="above"&&d[column]>=threshold){if(colorText){cell.css("color",color)}else{cell.css({background:color,color:textColor})}}else if(type=="below"&&d[column]<=threshold){if(colorText){cell.css("color",color)}else{cell.css({background:color,color:textColor})}}else if(type=="equal"&&d[column]==threshold){if(colorText){cell.css("color",color)}else{cell.css({background:color,color:textColor})}}})}function hexToRgb(hex){var result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);return result?{r:parseInt(result[1],16),g:parseInt(result[2],16),b:parseInt(result[3],16)}:null}function getTextColor(hex){var isHex=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);if(isHex){rgb=hexToRgb(hex);o=Math.round((parseInt(rgb.r)*299+parseInt(rgb.g)*587+parseInt(rgb.b)*114)/1e3)}else{o=255}if(o>125){return"#2B2B2B"}else{return"#FCFCFC"}}},conditionalFormattingByTable:function(o){var tableId="#"+o["table_id"],queryName=o["query_name"],includedColumns=o["columns"];rules=o["rules"];var data=alamode.getDataFromQuery(queryName),columns=alamode.getColumnsFromQuery(queryName);var colIndex={};var combinedRange=[];includedColumns.forEach(function(c){var range=d3.extent(_.map(data,c));combinedRange=combinedRange.concat(range)});var fullRange=d3.extent(combinedRange);setTimeout(function(){shade(rules)},1e3);$(tableId).mousemove(function(){shade(rules)});function shade(rules){var tableDiv=$(tableId+" table"),tableHeader=$(tableId+" .js-header-table"),headers=!tableHeader?$(tableHeader).find("th"):$(tableId+" .js-col-header"),rows=tableDiv.find("tr"),columnIndex=0;headers.each(function(){text=$(this).find(".axel-table-header-label").text();columnIndex=$(this).attr("data-axel-column");colIndex[text]=columnIndex});rules.forEach(function(r){var colorText=r.shade_text||false;if(r.type=="gradient"){drawGradient(r.color,colorText)}else if(r.type=="above"||r.type=="below"||r.type=="equal"){drawThreshold(r.type,r.value,r.color,colorText)}})}function drawGradient(color,colorText){var scale=d3.scale.linear().domain(fullRange).interpolate(d3.interpolateHsl).range(color);data.forEach(function(d,i){includedColumns.forEach(function(c){var idx=colIndex[c];var selector=tableId+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+idx+"']",selectedColor=scale(d[c]),textColor=getTextColor(selectedColor),cell=$(selector);if(colorText){cell.css("color",selectedColor)}else{cell.css({background:selectedColor,color:textColor})}})})}function drawThreshold(type,threshold,color,colorText){var textColor=getTextColor(color);data.forEach(function(d,i){includedColumns.forEach(function(c){var idx=colIndex[c];var selector=tableId+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+idx+"']",cell=$(selector);if(type=="above"&&d[c]>=threshold){if(colorText){cell.css("color",color)}else{cell.css({background:color,color:textColor})}}else if(type=="below"&&d[c]<=threshold){if(colorText){cell.css("color",color)}else{cell.css({background:color,color:textColor})}}else if(type=="equal"&&d[c]==threshold){if(colorText){cell.css("color",color)}else{cell.css({background:color,color:textColor})}}})})}function hexToRgb(hex){var result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);return result?{r:parseInt(result[1],16),g:parseInt(result[2],16),b:parseInt(result[3],16)}:null}function getTextColor(hex){var isHex=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);if(isHex){rgb=hexToRgb(hex);o=Math.round((parseInt(rgb.r)*299+parseInt(rgb.g)*587+parseInt(rgb.b)*114)/1e3)}else{o=255}if(o>125){return"#2B2B2B"}else{return"#FCFCFC"}}},addTableOfContents:function(o){if(typeof o==="undefined"){o="default"}var textColor=o["text_color"],backgroundColor=o["background_color"],hoverColor=o["hover_color"];$(".mode-header").addClass("has-nav");var nav=$("");$(".row").each(function(){var cols=$(this).children();cols.each(function(){var title;var chartId=$(this).find("mode-chart").attr("id")||$(this).find("mode-table").attr("id")||$(this).find("mode-python").attr("id");if(!chartId){return true}if(chartId.includes("chart")||chartId.includes("table")){var element=document.getElementById(chartId);if($(element).find("mode-pivot-table").length>0){title=document.getElementById(chartId).getElementsByClassName("in-place-edit-text")[0].innerText}else{title=document.getElementById(chartId).getElementsByClassName("chart-title")[0].innerText}}else if(chartId.includes("python")){title=document.getElementById(chartId).getElementsByClassName("in-place-edit-text")[0].innerText}var newlink=$(""+(title.includes("Click to add title")?"Untitled":title)+"");nav.append(newlink)})});var newdiv=$("
");$(".mode-content").prepend(newdiv);var newrow=$("");newdiv.prepend(newrow);var newcol=$("");newrow.prepend(newcol);newcol.prepend(nav);if(!!textColor){$(".fixed-nav-bar a").css("color",textColor)}if(!!backgroundColor){$(".fixed-nav-bar").css("background-color",backgroundColor)}if(!!hoverColor){$(".fixed-nav-bar a").hover(function(){$(this).css("color",hoverColor)},function(){if(!!textColor){$(this).css("color",textColor)}else{$(this).css("color","")}})}setTimeout(function(){$(".scroll-link").on("click",function(event){event.preventDefault();var sectionID=$(this).attr("href");scrollToID(sectionID,750)});function scrollToID(id,speed){var offSet=50;var targetOffset=$(id).offset().top-offSet;$("html,body").animate({scrollTop:targetOffset},speed)}},100); -}}; +var version="0.20",alamode={reportError:function(e){$("Order: '),d3.select(g).append("div").attr("class","mode-network-matrix").style("width",u).attr("id",t);var y=d3.tip().attr("class","mode-network-matrix-tooltip").offset([-10,0]).html(function(e){return e.z}),b=d3.select("#"+t).append("svg").attr("width",u+h.left+h.right).attr("height",a+h.top+h.bottom);b.call(y);var w=b.append("g").attr("transform","translate("+h.left+","+h.top+")");graph={nodes:p,links:d};var E=[],p=graph.nodes,S=p.length;p.forEach(function(e,t){e.index=t,e.count=0,E[t]=d3.range(S).map(function(e){return{x:e,y:t,z:0}})}),graph.links.forEach(function(e){typeof E[e.source_id][e.target_id]!="undefined"?(E[e.source_id][e.target_id].z+=e.edge_size,p[e.source_id].count+=e.edge_size,p[e.target_id].count+=e.edge_size):(E[e.source_id][e.target_id]={},E[e.source_id][e.target_id].z=0)});var x={name:d3.range(S).sort(function(e,t){return d3.ascending(p[e].node,p[t].node)}),count:d3.range(S).sort(function(e,t){return p[t].count-p[e].count}),group:d3.range(S).sort(function(e,t){return d3.ascending(p[e].node_group,p[t].node_group)})};v.domain(x.name),b.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(u+h.left+h.right)/2).attr("y",25).attr("text-anchor","middle").text(c),b.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(a+h.top+h.bottom)/-2).attr("y",25).attr("transform","rotate(-90)").attr("text-anchor","middle").text(l),w.append("rect").attr("class","mode-network-matrix-background").attr("width",u).attr("height",a);var T=w.selectAll(".mode-network-matrix-row").data(E).enter().append("g").attr("class","mode-network-matrix-row").attr("transform",function(e,t){return"translate(0,"+v(t)+")"}).each(T);T.append("line").attr("class","mode-network-matrix-line").attr("x2",u),T.append("text").attr("class","mode-network-matrix-row-text").attr("x",-6).attr("y",v.rangeBand()/2).attr("dy",".32em").attr("text-anchor","end").text(function(e,t){return p[t].node});var N=w.selectAll(".mode-network-matrix-column").data(E).enter().append("g").attr("class","mode-network-matrix-column").attr("transform",function(e,t){return"translate("+v(t)+")rotate(-90)"});N.append("line").attr("class","mode-network-matrix-line").attr("x1",-u),N.append("text").attr("class","mode-network-matrix-column-text").attr("x",6).attr("y",v.rangeBand()/2).attr("dy",".32em").attr("text-anchor","start").text(function(e,t){return p[t].node}),d3.select("#mode-network-matrix-order-picker-"+t).on("change",function(){L(this.value)})},hive:function(e){function w(e){return e/Math.PI*180-90}d3.hive={},d3.hive.link=function(){function e(e,i){var s,o=t(n,this,e,i),u=t(r,this,e,i);o.a>u.a&&(s=u,u=o,o=s),u.a-o.a>Math.PI&&(o.a+=2*Math.PI);var a=o.a+(u.a-o.a)/3,f=u.a-(u.a-o.a)/3;return o.r0-o.r1||u.r0-u.r1?"M"+Math.cos(o.a)*o.r0+","+Math.sin(o.a)*o.r0+"L"+Math.cos(o.a)*o.r1+","+Math.sin(o.a)*o.r1+"C"+Math.cos(a)*o.r1+","+Math.sin(a)*o.r1+" "+Math.cos(f)*u.r1+","+Math.sin(f)*u.r1+" "+Math.cos(u.a)*u.r1+","+Math.sin(u.a)*u.r1+"L"+Math.cos(u.a)*u.r0+","+Math.sin(u.a)*u.r0+"C"+Math.cos(f)*u.r0+","+Math.sin(f)*u.r0+" "+Math.cos(a)*o.r0+","+Math.sin(a)*o.r0+" "+Math.cos(o.a)*o.r0+","+Math.sin(o.a)*o.r0:"M"+Math.cos(o.a)*o.r0+","+Math.sin(o.a)*o.r0+"C"+Math.cos(a)*o.r1+","+Math.sin(a)*o.r1+" "+Math.cos(f)*u.r1+","+Math.sin(f)*u.r1+" "+Math.cos(u.a)*u.r1+","+Math.sin(u.a)*u.r1}function t(e,t,n,r){var a=e.call(t,n,r),f=+("function"==typeof i?i.call(t,a,r):i)+u,l=+("function"==typeof s?s.call(t,a,r):s),c=s===o?l:+("function"==typeof o?o.call(t,a,r):o);return{r0:l,r1:c,a:f}}var n=function(e){return e.source},r=function(e){return e.target},i=function(e){return e.angle},s=function(e){return e.radius},o=s,u=-Math.PI/2;return e.source=function(t){return arguments.length?(n=t,e):n},e.target=function(t){return arguments.length?(r=t,e):r},e.angle=function(t){return arguments.length?(i=t,e):i},e.radius=function(t){return arguments.length?(s=o=t,e):s},e.startRadius=function(t){return arguments.length?(s=t,e):s},e.endRadius=function(t){return arguments.length?(o=t,e):o},e};var t=alamode.makeId(10),n=e.node_query,r=e.edge_query,i=e.groups_are_numeric,s=e.html_element||"body",o=e.title||queryName,u=e.chart_width||"800",a=e.chart_height||"800",f=e.group_colors||"",l=Math.min(u,a)/2-30,c=l*.2,h=alamode.getDataFromQuery(n),p=alamode.getDataFromQuery(r),d=_.uniq(_.map(h,"node_group")),v={};h.forEach(function(e){i?e.x=e.node_group:e.x=d.indexOf(e.node_group),e.y=e.node_size,v[e.node]=e}),p.forEach(function(e){e.source=v[e.source],e.target=v[e.target]});var m=alamode.addContainerElement(s);d3.select(m).append("div").attr("class","mode-graphic-title").text(o),d3.select(m).append("div").attr("class","mode-network-matrix").style("width",u).attr("id",t),i?angle=d3.scale.linear().domain(d3.extent(h,function(e){return e.node_group})).range([0,2*Math.PI]):angle=d3.scale.ordinal().domain(d3.range(d.length+1)).rangePoints([0,2*Math.PI]);var g=d3.scale.linear().domain(d3.extent(h,function(e){return e.node_size})).range([c,l]),y=d3.tip().attr("class","mode-hive-tooltip").offset([-10,0]).html(function(e){return e.node}),b=d3.select("#"+t).append("svg").attr("width",u).attr("height",a).append("g").attr("transform","translate("+u/2+","+a/2+")");b.call(y),b.selectAll(".mode-hive-axis").data(d3.range(d.length)).enter().append("line").attr("class","mode-hive-axis").attr("transform",function(e){return"rotate("+w(angle(e))+")"}).attr("x1",g.range()[0]).attr("x2",g.range()[1]),b.selectAll(".mode-hive-link").data(p).enter().append("path").attr("class","mode-hive-link").attr("d",d3.hive.link().angle(function(e){return angle(e.x)}).radius(function(e){return g(e.y)})).style("stroke",function(e){return f[e.source.node_group]}),b.selectAll(".mode-hive-node").data(h).enter().append("circle").attr("class","mode-hive-node").attr("transform",function(e){return"rotate("+w(angle(e.x))+")"}).attr("cx",function(e){return g(e.y)}).attr("r",5).style("fill",function(e){return f[e.node_group]}).on("mouseover",function(e){y.show(e),d3.select(this).attr("class","mode-hive-node mode-hive-node-selected"),d3.selectAll(".mode-hive-link").data(p).attr("class",function(t){return t.source.node==e.node?"mode-hive-link-selected":t.target.node==e.node?"mode-hive-link-selected":"mode-hive-link"})}).on("mouseout",function(e){y.hide(e),d3.select(this).attr("class","mode-hive-node"),d3.selectAll(".mode-hive-link-selected").attr("class","mode-hive-link")})},conditionalFormattingByColumn:function(e){function u(e){var n=$(t+" table"),r=$(t+" .js-header-table"),i=r?$(t+" .js-col-header"):$(r).find("th"),s=n.find("tr"),u=0;i.each(function(){text=$(this).find(".axel-table-header-label").text(),u=$(this).attr("data-axel-column"),o[text]=u}),e.forEach(function(e){e.rules.forEach(function(t){var n=t.shade_text||!1;t.type=="gradient"?a(e.column,t.color,n):(t.type=="above"||t.type=="below"||t.type=="equal")&&f(e.column,t.type,t.value,t.color,n)})})}function a(e,n,r){var s=d3.extent(_.map(i,e)),u=d3.scale.linear().domain(s).interpolate(d3.interpolateHsl).range(n),a=o[e];i.forEach(function(n,i){var s=t+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+a+"']",o=u(n[e]),f=c(o),l=$(s);r?l.css("color",o):l.css({background:o,color:f})})}function f(e,n,r,s,u){var a=o[e],f=c(s);i.forEach(function(i,o){var l=t+" table [data-axel-rowkey='"+o+"'][data-axel-column='"+a+"']",c=$(l);n!="above"||i[e]