【问题标题】:How to hide the legend with uvCharts in R or Javascript如何在 R 或 Javascript 中使用 uvCharts 隐藏图例
【发布时间】:2015-08-12 18:57:07
【问题描述】:

我正在通过 R 中的 RCharts 使用 uvCharts。我想要做的就是能够在需要时将图例隐藏在条形图上。下面是来自http://rcharts.io/howitworks/part2/ 的代码和示例(我认为我还不能插入图像)。如果您滚动到页面的大约中间,您会看到条形图,其中带有棕色、蓝色、淡褐色和绿色的图例。

hair_eye_male <- subset(as.data.frame(HairEyeColor), Sex == "Male")
dataset = make_dataset('Hair', 'Freq', hair_eye_male, group = 'Eye')
u1 <- uPlot("Hair", "Freq", 
  data = hair_eye_male, 
  group = "Eye",
  type = 'StackedBar'
)
u1$config(meta = list(
  caption = "Hair vs. Eye Colors",
  vlabel  = "Hair Color"
))
u1$config(graph = list(
  palette = "Olive"  
))
u1

有谁知道如何在 uvCharts 中隐藏图例?我知道我可以做一个

u1$config(legend = list()) 

但文档 (http://imaginea.github.io/uvCharts/documentation.html) 并没有真正提供有关图例的任何进一步信息。任何有关如何在 R 或 JavaScript 中执行此操作的信息将不胜感激。提前感谢您的帮助。

【问题讨论】:

    标签: javascript r hide legend rcharts


    【解决方案1】:

    你可以试试

    u1$config(legend = list(
      showlegends = false
    ))
    

    在 uvCharts 中,必须将其作为配置属性传递

    {
       legend: {
          showlegends: false
       }
    }
    

    【讨论】:

    • 感谢完美,非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 2019-02-26
    • 1970-01-01
    相关资源
    最近更新 更多