Hi @Jipok,

Do you mean me adding gh-pages? I didn't want to put any docs up given that 
this is just a toy example. In any case, I added the output 
[here](https://sdwfrost.github.io/nim-plotly-example/) .

My library code is tiny and looks like this:
    
    
    import jsffi
    import jsbind
    
    type PlotlyObj = ref object of JsObject
    
    proc newPlotly*(): PlotlyObj {.jsimportgWithName: "function(){return 
(Plotly)}" .}
    let Plotly* = newPlotly()
    proc newPlot*(p: PlotlyObj; divname: cstring; data: seq[JsObject]; layout: 
JsObject) {.jsimport.}
    
    

The examples are as follows:
    
    
    import jsffi
    import plotly
    
    # Line plot
    
    var trace1=newJsObject()
    trace1.x = @[1, 2, 3, 4]
    trace1.y = @[18, 15, 13, 12]
    trace1.mode = "lines+markers"
    var data1 = @[trace1]
    var layout1 = newJsObject()
    layout1.title = "Line plot".cstring
    Plotly.newPlot("line-plot", data1, layout1)
    
    # Bar plot
    
    var trace2 = newJSObject()
    trace2.x = @["giraffes".cstring,"orangutans".cstring,"monkeys".cstring]
    trace2.y = @[20,14,23]
    trace2.type = "bar".cstring
    var data2 = @[trace2]
    var layout2 = newJsObject()
    layout2.title = "Bar plot".cstring
    Plotly.newPlot("bar-plot", data2, layout2)
    

Some questions:

  1. Is the use of a variable Plotly as above to emulate the Javascript API OK?
  2. How can I avoid the explicit cstring conversion?


Reply via email to