Is an NVD3 Line Plot with Markers Possible?

前端 未结 5 1293
野趣味
野趣味 2020-12-14 02:52

I\'m making an NVD3 line plot that will have significantly improved clarity if I can get markers to show for each data point instead of just the line itself. Unfortunately,

5条回答
  •  伪装坚强ぢ
    2020-12-14 02:57

    This puzzled me until I got help from the community:

    css styling of points in figure

    So here is my solution, based on css:

    .nv-point {
        stroke-opacity: 1!important;
        stroke-width: 5px!important;
        fill-opacity: 1!important;
    }
    

    If anyone has come here from rCharts, below is a rmarkdown template to create an nPlot with both lines and markers:

     ```{r 'Figure'}  
    require(rCharts)
    load("data/df.Rda") 
    # round data for rChart tooltip display
    df$value <- round(df$value, 2)
    n <- nPlot(value ~ Year, group = 'variable', data = df, type = 'lineChart') 
    n$yAxis(axisLabel = 'Labor and capital income (% national income)')
    n$chart(margin = list(left = 100)) # margin makes room for label
    n$yAxis(tickFormat = "#! function(d) {return Math.round(d*100*100)/100 + '%'} !#")
    n$xAxis(axisLabel = 'Year')
    n$chart(useInteractiveGuideline=TRUE)
    n$chart(color = colorPalette)
    n$addParams(height = 500, width = 800)
    n$setTemplate(afterScript = ''
    )
    n$save('figures/Figure.html', standalone = TRUE)
    ```
    

提交回复
热议问题