【问题标题】:Add one single point to a rChart dimple line chart向 rChart 酒窝折线图添加一个点
【发布时间】:2014-12-06 23:53:55
【问题描述】:

我想在酒窝折线图上添加一个点并使用它。

vo <- (round(seq(0.5,0.6,0.001),5))
sh <- (1-((vo)^(1/3)))
sh <- 100*sh
dat <- data.frame(cbind(vo,sh))
ph <- data.frame(vo=0.55, sh=16)

d1 <- dPlot(sh~vo,
            data = dat,
            type = "line"
            ,defaultColors = "#!['blue']!#"
)
d1$yAxis('addMeasureAxis')
d1$layer(
  sh ~ vo
  ,groups = c("vo","sh")
  ,data = ph
  ,type="bubble"
)

作为一个新手,我尝试了所有我能找到的解决方案,但最终 - 充其量 - 就像上面这样。我想补充的一点不是我期望他在的地方。他没有出现在定义的位置,而是在 y 轴上向上移动。 我做错了什么?

感谢 timeportfolio,我得到了一个很好的解决方案。在他从其他帖子中获得的更多帮助下,我能够将 xAxis 格式化为我所期望的更多。 但是现在出现了其他问题,我找不到答案: 1. xAxis 似乎被抑制了,尽管比例是可见的 2. 将 overrideMin 更改为 15 时,工具提示的虚线超出 xAxis。 这个可以改吗?

d1$setTemplate(afterScript = 
  "<script>
    myChart.axes[0].shapes.selectAll('text')
        .each(function(d,i){
            // remove incrementally, so something like every 5
            if( i % 20 == 0 ) {
              //remove transform - translate and rotate
              // do other styling and manipulation here also
              d3.select(this).style('transform','')
            } else {
              d3.select(this).remove()
            }
            })
        .attr('transform','rotate()')
        .style('text-anchor','middle')
        .style('font-size','50%')
    myChart.axes[0]
          .titleShape.text('Vol')
          .style('font-size','100%')
  </script>"
)
d1

我只插入了 afterScript,使用上面的代码并更改 overrideMin 应该清楚我的意思。 感谢您的帮助。

【问题讨论】:

    标签: rcharts dimple.js


    【解决方案1】:

    考虑到此功能是实验性的且未记录在案,您做得很好。到目前为止,要使其正常工作,您需要在两个位置显式设置 yAxis 上的最大值和最小值以获得正确对齐(是的,我知道它很难看)。完整的代码类似于

    library(rCharts)
    
    vo <- (round(seq(0.5,0.6,0.001),5))
    sh <- (1-((vo)^(1/3)))
    sh <- 100*sh
    dat <- data.frame(cbind(vo,sh))
    ph <- data.frame(vo=0.55, sh=16)
    
    d1 <- dPlot(sh~vo,
                data = dat,
                type = "line"
                ,defaultColors = "#!['blue']!#"
    )
    d1$yAxis('addMeasureAxis',overrideMin = 0, overrideMax = 30)
    d1$layer(
      sh ~ vo
      ,groups = c("vo","sh")
      ,data = ph
      ,type="bubble"
      ,yAxis = d1$params$yAxis
    )
    d1
    

    如果这对您有用,请告诉我。抱歉,它还是那么笨重。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多