Last active
January 3, 2016 07:28
-
-
Save rebeccastandig/8429171 to your computer and use it in GitHub Desktop.
How to create a Keen Number that divides the results of two different queries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Keen.onChartsReady(function(){ | |
| //Create a Metric containing our total number of logins. | |
| var myMetric = new Keen.Metric("logins", { | |
| analysisType: "count" | |
| }); | |
| //Create a Metric containing our total number of registers. | |
| var myMetric2 = new Keen.Metric("registers", { | |
| analysisType: "count" | |
| }) | |
| myMetric.getResponse(function(response){ | |
| firstValue = response.result; | |
| myMetric2.getResponse(function(nextResponse){ | |
| secondValue = nextResponse.result; | |
| divided = firstValue/secondValue; | |
| console.log(divided); | |
| //Create a Number visualization for that metric. | |
| var myNumberVisualization = new Keen.Number(myMetric2, { | |
| height: "300", | |
| width: "600", | |
| label: "total logins" | |
| }); | |
| //Draw the visualization in a div | |
| myNumberVisualization.draw(document.getElementById("myDiv"), {"result":divided}); | |
| }) | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment