There is a more recent run of this report. Click here to view it.

Report not found

There was a problem finding this report.
Making a Funnel
May 28, 2015 · Refreshed 2 months ago
Description
Making a funnel with Mode.

Collaborators

Run History
SELECT event_name, COUNT(*) * RANDOM() AS number FROM tutorial.playbook_events WHERE event_name IN ('create_user','enter_email','enter_info','complete_signup') GROUP BY 1 ORDER BY 2 DESC
SELECT event_name, COUNT(*) * RANDOM() AS number FROM tutorial.playbook_events WHERE event_name IN ('create_user','enter_email','enter_info','complete_signup') GROUP BY 1 ORDER BY 2 DESC
SELECT event_name, COUNT(*) FROM tutorial.playbook_events WHERE event_name IN ('create_user','enter_email','enter_info','complete_signup') GROUP BY 1 ORDER BY 2 DESC
SELECT event_name, COUNT(*) FROM tutorial.playbook_events WHERE event_name IN ('create_user','enter_email','enter_info','complete_signup') GROUP BY 1 ORDER BY 2 DESC
<style> .mode-bar-chart-funnel-background { fill: rgba(0, 0, 0, 0.7); border-radius: 2px; } .mode-bar-chart-funnel-label { fill: #fff; } </style> <div class="mode-header embed-hidden"> <h1>{{ title }}</h1> <p>{{ description }}</p> </div> <div class="container mode-grid"> <div class="row"> <div class="col-md-12"> <mode-chart id="chart_44b22113859d" dataset="dataset" options="chart_options"></mode-chart> </div> </div> <div class="row"> <div class="col-md-12"> <mode-chart id="chart_d63b4795c7b6" dataset="dataset" options="chart_options"></mode-chart> </div> </div> </div> <script> barChartFunnel({ "chart_id": "#chart_44b22113859d", "include_overall_rate": true }) barChartFunnel({ "chart_id": "#chart_d63b4795c7b6", "include_overall_rate": true }) function barChartFunnel(o) { var p = d3.format(".3p"); var includeOverall = o["include_overall_rate"], chartId = o["chart_id"], jqChart = $(chartId); function drawFunnel() { d3.selectAll(chartId + " .r").remove(); var svgTrans = getTrans(jqChart.find("g.nvd3.nv-wrap g").attr("transform")); var bars = jqChart.find(".nv-barsWrap .nv-groups .nv-bar"); var funnelObj = []; bars.each(function(i) { var bar = $(this).find("rect"); var value = +$(this).find("text").text().replace(/,/g, ''); var barTrans = getTrans($(this).attr("transform")); barWidth = bar.attr("width"), barHeight = bar.attr("height"); bar.attr("width",barWidth/2); bar.attr("transform","translate(" + barWidth/4 + ",0)"); obj = { step: i, value: value, x: barTrans[0], y: barTrans[1], h: barHeight} funnelObj.push(obj) }) var svg = d3.select(chartId + " .nvd3svg"); funnelObj.forEach(function(d,i) { if (i != 0) { var h = 30, x = d.x + svgTrans[0] + barWidth/8, y = Math.min(svgTrans[1] + d.y + d.h/2 - h/2, svgTrans[1] + d.y + d.h/1 - h), w = barWidth/2; var value = p(d.value/funnelObj[i-1]["value"]); var pts = (x-w) + "," + y + " " + (x-.2*w) + "," + y + " " + x + "," + (y+h/2) + " " + (x-.2*w) + "," + (y+h) + " " + (x-w) + "," + (y+h) svg.append("polygon") .attr("points",pts) .attr("class","mode-bar-chart-funnel-background r"); svg.append("text") .attr("x",(x - w*.6)) .attr("y",y + h/2) .attr("dy",".37em") .attr("text-anchor","middle") .attr("class","mode-bar-chart-funnel-label r") .style("font-size","12px") .text(value) } }) if (includeOverall) { var legendX = funnelObj[funnelObj.length-1]["x"]+svgTrans[0], overallVal = funnelObj[funnelObj.length-1]["value"]/funnelObj[0]["value"]; svg.append("rect") .attr("x",funnelObj[funnelObj.length-1]["x"]+svgTrans[0]) .attr("y",0) .attr("width",100) .attr("height",50) .attr("class","mode-bar-chart-funnel-background r") svg.append("text") .attr("x",funnelObj[funnelObj.length-1]["x"]+svgTrans[0] + 10) .attr("y",15) .attr("class","mode-bar-chart-funnel-label r") .style("font-size","12px") .text("Overall Rate"); svg.append("text") .attr("x",funnelObj[funnelObj.length-1]["x"]+svgTrans[0] + 10) .attr("y",40) .attr("class","mode-bar-chart-funnel-label r") .style("font-size","18px") .text(p(overallVal)); } } function getTrans(translation) { var openPos = translation.indexOf("("), closePos = translation.indexOf(")"), commaPos = translation.indexOf(","); var xTrans = +translation.slice(openPos+1,commaPos), yTrans = +translation.slice(commaPos+1,closePos); return [xTrans,yTrans]; } setTimeout(function(){ drawFunnel() }, 750); $(window).resize(function () { waitForFinalEvent(function(){ drawFunnel() }, 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); }; })(); } </script>
{{ dataSourceName(params.queryId) }}

The dataset is too large to view in browser

Export

Looks like something went wrong with your query.

{{ DS.queryRuns[params.queryId].errorMessage }}
This query was cancelled