如何在 googleVis 中设置 "formatted value"?
How to set a "formatted value" in googleVis?
我正在使用 googleVis 和 shiny 来(自动)创建组织结构图。
类似于这个问题:
Google Visualization: Organizational Chart with fields named the same,我想在 googleVis 中使用格式化值,以便能够在组织结构图中创建具有相同名称的字段。我怀疑它与角色有关,但我无法找出正确的语法。
gvisOrgChart 的帮助页面提到了格式化的值,但没有说明如何设置它们:
"You can specify a formatted value to show on the chart instead, but the unformatted value is still used as the ID."
## modified example from help page
library(googleVis)
Regions[7,1] = Regions[8,1] # artificially create duplicated name in another parent node
Org <- gvisOrgChart(Regions)
plot(Org)
在上面的示例中,重复的名称(墨西哥)仅在图表中显示一次。我希望它们都被绘制(一个在欧洲,一个在美国父节点)。
感谢您的帮助
卡特兰
在与 googleVis 包的开发人员之一交谈后,我现在找到了问题的解决方案。格式化值包含额外的说话标记,必须在文本用作 HTML.
之前将其删除
## modified example from help page
library(googleVis)
# add new entry
levels(Regions$Region) = c(levels(Regions$Region), "{v: 'Germany.2', f: 'Germany'}")
Regions[8,1] = "{v: 'Germany.2', f: 'Germany'}"
Org <- gvisOrgChart(Regions)
# remove extra speak marks
Org$html$chart <- gsub("\"\{v", "\{v", Org$html$chart)
Org$html$chart <- gsub("\}\"", "\}", Org$html$chart)
plot(Org)
在生成的图表中有两次 "Germany",一次在节点 "America" 下,一次在 "Europe" 下。与您可以向文本添加 HTML 格式(颜色、字体等)的方式相同。
也感谢 Markus Gesmann 在这方面帮助我。
我正在使用 googleVis 和 shiny 来(自动)创建组织结构图。 类似于这个问题: Google Visualization: Organizational Chart with fields named the same,我想在 googleVis 中使用格式化值,以便能够在组织结构图中创建具有相同名称的字段。我怀疑它与角色有关,但我无法找出正确的语法。
gvisOrgChart 的帮助页面提到了格式化的值,但没有说明如何设置它们: "You can specify a formatted value to show on the chart instead, but the unformatted value is still used as the ID."
## modified example from help page
library(googleVis)
Regions[7,1] = Regions[8,1] # artificially create duplicated name in another parent node
Org <- gvisOrgChart(Regions)
plot(Org)
在上面的示例中,重复的名称(墨西哥)仅在图表中显示一次。我希望它们都被绘制(一个在欧洲,一个在美国父节点)。
感谢您的帮助
卡特兰
在与 googleVis 包的开发人员之一交谈后,我现在找到了问题的解决方案。格式化值包含额外的说话标记,必须在文本用作 HTML.
之前将其删除## modified example from help page
library(googleVis)
# add new entry
levels(Regions$Region) = c(levels(Regions$Region), "{v: 'Germany.2', f: 'Germany'}")
Regions[8,1] = "{v: 'Germany.2', f: 'Germany'}"
Org <- gvisOrgChart(Regions)
# remove extra speak marks
Org$html$chart <- gsub("\"\{v", "\{v", Org$html$chart)
Org$html$chart <- gsub("\}\"", "\}", Org$html$chart)
plot(Org)
在生成的图表中有两次 "Germany",一次在节点 "America" 下,一次在 "Europe" 下。与您可以向文本添加 HTML 格式(颜色、字体等)的方式相同。
也感谢 Markus Gesmann 在这方面帮助我。