title: Setting the interaction model of a Dygraph in Shiny for R
body: <p>I am looking to add the custom interaction seen at <a href="http://dygraphs.com/gallery/#g/interaction" rel="nofollow">http://dygraphs.com/gallery/#g/interaction</a> under "Custom interaction model" into my Shiny web app. </p>
  
  <p>As far as I understand it, this requires attaching some JS to the page and  setting the interaction model on the graph: </p>
  
  <p><code>interactionModel : {
      'mousedown' : downV3,
      'mousemove' : moveV3,
      'mouseup' : upV3,
      'click' : clickV3,
      'dblclick' : dblClickV3,
      'mousewheel' : scrollV3 
  }</code></p>
  
  <p>However, <code>interactionModel</code> does not seem to be listed as a parameter in the <code>dyOptions</code> function on the R side. </p>
  
  <p><strong>Is there a way to work around this?</strong>  </p>
  
  <p>Update: </p>
  
  <p>Looking at the source for <code>dyOptions</code>, it seems that options can be modified directly: </p>
  
  <pre><code>g &lt;- dyGraph(series)
  
  g$x$attr$option &lt;- "Value"
  </code></pre>
  
  <p>However, setting the <code>interactionModel</code> here does not seem to work. </p>
  
  <p>See: <a href="https://github.com/rstudio/dygraphs/blob/master/R/options.R" rel="nofollow">https://github.com/rstudio/dygraphs/blob/master/R/options.R</a></p>
  
  <p>Update: </p>
  
  <p>You can indeed set the options using:</p>
  
  <pre><code>g$x$attrs$option &lt;- "Value" # Note that it is "attrs", not "attr"
  </code></pre>
  
  <p>This can be used to switch off the interaction mode: </p>
  
  <pre><code>graph$x$attrs$interactionModel &lt;- "{}"
  </code></pre>
  
  <p>The remaining problem is passing JS function references via JSON to the page. </p>