d3.js - minimal cubism.js horizon chart example (TypeError: callback is not a function) -


i'm having devil of time going code found on d3 , cubism api pages altering things work need them do...

i'm trying follow steps horizon graph listed here https://github.com/square/cubism/wiki/horizon don't have cube or graphite data source.

so i'm trying make minimal example metric mbostock's answer here using other data sources cubism.js and/or random-value-returning metric example here https://github.com/square/cubism/wiki/context

i guess on context api page, explains parameters context.metric(), don't understand part "...and callback function when results available". have following on server , when view/refresh in browser "typeerror: callback not function" in browser's console:

            <body>                  <div class="mag"></div>                  <script type="text/javascript">  var mycontext = cubism.context();  var myhoriz = mycontext.horizon()         .metric(function(start, stop, step, callback) {                 var values = [];                 start = +start;                 stop = +stop;                 while (start < stop) {                         start += step;                         values.push(math.random());                 }                 callback(null, values);         });  d3.select(".mag").selectall("p")         .data([1, 2, 3, 7])             // "times" want graph data         .enter().append("p")         .call(myhoriz);                  </script>         </body> 

oh (edit), should add, code run, in document 4 paragraphs added div, , text contents of each paragraph numbers 1, 2, 3, 7. guess @ least select(), data(), enter(), , append() bits working.

it looks confusing horizon.metric context.metric. context.metric takes function of signature you're defining.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -