Changing line thickness and opacity in scatterplot on onRender() htmlWidgets in R

后端 未结 1 1728
醉话见心
醉话见心 2021-01-26 10:57

I am hoping to make a plot using the R package htmlwidgets\' onRender() function in which a user can click on a point and a line is drawn. I have the crux of it working right no

相关标签:
1条回答
  • 2021-01-26 11:58

    The opacity would need to be in the trace object. Your line object has some syntax issues which prevents Javascript from reading it.

    gp %>% onRender("
    function(el, x, data) {
    
      el.on('plotly_click', function(e) {
    
      var trace1 = {
        x: [100, 400],
        y: [100, 400],
        mode: 'lines',
        line: {
            color: 'gray', 
            width: 100
        },
        opacity: 0.8,
      }
      Plotly.addTraces(el.id, trace1);
    })
    }", data=dat)
    
    0 讨论(0)
提交回复
热议问题