I'm trying to compile Nim source to JavaScript. I use a simple (partial) Nim 
wrapper for Dygraphs library and I create some graphs from my Nim code. The 
problem is that I don't understand ho to pass to Dygraphs an option with the 
function reference. In Javascript it should be like this:
    
    
          
          new Dygraph(
              document.getElementById("div_g"),
              data,
              {
                labels: ['X', 'Est.', 'Actual'],
                animatedZooms: true,
                underlayCallback: function(canvas, area, g) {
                  var bottom_left = g.toDomCoords(highlight_start, -20);
                  var top_right = g.toDomCoords(highlight_end, +20);
                  
                  var left = bottom_left[0];
                  var right = top_right[0];
                  
                  canvas.fillStyle = "rgba(255, 255, 102, 1.0)";
                  canvas.fillRect(left, area.y, right - left, area.h);
                }
              
              }
          );
    
    
    
    Run

How should I define underlayCallback in Nim and how should I declare this 
option in wrapper?

My wrapper is here: 
[https://raw.githubusercontent.com/Peter2121/noogest/master/dygraph.nim](https://raw.githubusercontent.com/Peter2121/noogest/master/dygraph.nim)

I create the graph from another module like this:
    
    
    var opts = NimDygraphOpts()
    ...
    tempGraphs[channel] = newDygraph(parent,cData,opts[])
    
    
    Run

So, probably, I need to declare a new option in NimDygraphOpts object, set it 
to some function pointer and then pass it to newDygraph. But I dont't 
understand what type of object should I use for this option and how should I 
assign it.

Reply via email to