标签: rcharts

rCharts nvd3 lineWithFocusChart Customization

我在rCharts上使用nvd3,并且想知道是否有一种方法可以在lineWithFocusChart上自定义下部取景器图形的轴.我在下面提供了一个可重现的示例,其中我自定义x和y轴以使逗号分隔数千个位置,但该格式不显示在下部取景器图表上.怎么能解决这个问题?谢谢!

      library(rCharts)
      temp <- data.frame(x = 1:2000, y = 1:2000, z = c(rep(1,1000), rep(0,1000)))
      g <- nPlot(y ~ x, group = "z", data = temp, type = "lineWithFocusChart")
      g$templates$script <- "http://timelyportfolio.github.io/rCharts_nvd3_templates/chartWithTitle_styled.html"
      g$set(title = "Example")  
      g$chart(transitionDuration = -1,
              tooltipContent = "#! function(key, x, y) {
                                return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y 
                              }!#", 
              showLegend = FALSE, margin = list(left = 200, 
                                                right = 100, 
                                                bottom = 100,
                                                top = …
Run Code Online (Sandbox Code Playgroud)

javascript r nvd3.js rcharts

50
推荐指数
1
解决办法
810
查看次数

rMaps ichoropleth与自定义地图/ shp

在R,我想帮助试图复制教程在这里为自己的自定义SHP(Shape文件)文件或映射是一个交互式的地区分布图...

该地图是北爱尔兰的小地区.哪个可以在这里找到.

以下是我到目前为止采取的步骤......

我认为问题是geographyConfig数据的设置......

任何帮助将非常感激....

# Download and unzip the data
system('wget http://www.nisra.gov.uk/archive/geography/digital_products/SA2011_Esri_Shapefile.zip')
system('unzip SA2011_Esri_Shapefile.zip')

# Load libraries
library(rgdal)
library(rgeos)
library(rMaps)

shp.file <- 'SA2011.shp'

# Convert projection
system(paste0('ogr2ogr tmp.shp ',
               shp.file,
              ' -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"'))

# Read in the data
xx <- readOGR(dsn=getwd(),layer='tmp')
mm <- xx@data
head(mm)
n <- nrow(mm)
dat.val <- mm$Hectares

# Add extra year data
mm <- mm[rep(seq(n),3),]
mm$Hectares <- c(dat.val,rev(dat.val),dat.val/2)
mm$year <- rep(c(2000:2002),each=n)
colnames(mm)[1] <- 'ID'
id.var <- …
Run Code Online (Sandbox Code Playgroud)

r d3.js rcharts

46
推荐指数
1
解决办法
1117
查看次数

rCharts和DT是否兼容rmarkdown?

我正在尝试使用rmarkdown创建一个文档,其中包括来自rCharts包的图和使用htmlwidgets中包含的DT库的数据表.出于某种原因,我不能一起显示它们.

---
title: "Untitled"
output: html_document
---

```{r, echo=FALSE}
library(DT)
library(rCharts)

df<-data.frame(Name=c("a","Z","h","k","j"),Value=(sample(10^7,5)))

datatable(df, filter = 'top', options = list(
  pageLength = 10,iDisplaylength=10, autoWidth = TRUE
))
```

```{r, message=FALSE, echo=FALSE, results='asis'}
df<-data.frame(label=c("One","Two","Three"),valuea=c(1,2,3),
               othera=c(10,11,12),stringsAsFactors = FALSE)
p1 <- nPlot(valuea~ label, data = df, type = 'pieChart')

#Different options I tried

p1$print('inline', include_assets = TRUE, cdn = FALSE)
#p1$show('inline', include_assets = TRUE, cdn = FALSE)

#p1$print('inline', include_assets = TRUE)
#p1$show('inline', include_assets = TRUE)

#These provide an error
#p1$print('inline', include_assets = TRUE, cdn …
Run Code Online (Sandbox Code Playgroud)

r r-markdown rcharts

14
推荐指数
1
解决办法
467
查看次数

rCharts - 如何将轴标签和标题添加到NVD3图表

我正在研究rCharts.我把Lables添加到Y轴和标题时卡住了.我是rCharts的新手.

这是我的示例代码

require(rCharts)
n2 <- nPlot(Hours ~ Month, group = "Task", data = cars, type = "multiBarChart",
height = 900, width = 1110)
n2$xAxis(axisLabel = 'Year and Month')
n2
Run Code Online (Sandbox Code Playgroud)

请帮忙.

r rcharts

13
推荐指数
1
解决办法
4543
查看次数

使用R突出显示Sankey图中从头到尾的所有连接路径

当我点击节点以了解特定节点的整个故事时,我想强调整个路径,这里是一个例子 - http://bl.ocks.org/git-ashish/8959771.

请检查此链接,你会发现在javscript中突出显示路径的功能,但请注意,此功能不能达到我想要的效果,它突出显示与被点击的节点相关的链接以及与目标节点相关的链接.我想要的是突出显示与点击的节点相关的所有链接.

d3 Sankey - 从开始到结束突出显示所有连接的路径

这是我需要的一个例子, 在此输入图像描述 这是整个图,我需要的是,当我点击曼谷时,它突出显示与数据框中曼谷相同的所有节点,如突出显示与ClimateChange和EnergyShortage的链接,......然后突出显示基础设施和生态系统,和领导力和战略,......这就是我想要的.这是另一张图片,显示与曼谷相关的节点使用闪亮来分析它.

在此输入图像描述

这是当我在bl.ocks和链接的问题中使用highlight_node_links时会发生什么,这是错误的,并没有显示节点和曼谷之间的关系. 在此输入图像描述

以下是曼谷的数据,向您展示列如何相互关联,当您使用这些数据时,它将仅生成第二张图片.

structure(list(City = c("Bangkok", "Bangkok", "Bangkok", "Bangkok", 
"Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok", 
"Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok"
), ResiliencyChallenge = c("ClimateChange", "ClimateChange", 
"ClimateChange", "ClimateChange", "ClimateChange", "InfrastructureFaliure", 
"EnergyShortage", "Pollution", "Pollution", "Pollution", "TransportationSystemFailure", 
"TransportationSystemFailure", "TransportationSystemFailure", 
"TransportationSystemFailure", "TransportationSystemFailure", 
"TransportationSystemFailure"), CRI.Dimesnsion.1 = c("Infrastructure & Ecosystems", 
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems", 
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems", 
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems", 
"Leadership & Strategy", "Leadership & Strategy", "Infrastructure …
Run Code Online (Sandbox Code Playgroud)

r rcharts sankey-diagram networkd3 htmlwidgets

12
推荐指数
1
解决办法
1774
查看次数

rCharts与Highcharts一起作为闪亮的应用程序

我有一个由三个文件组成的闪亮应用程序.server.R,ui.R和用于启动应用程序的文件

require(shiny)
require(rCharts)
runApp("shinyApp")
Run Code Online (Sandbox Code Playgroud)

应用程序启动,但图表不可见.它适用于正常的r-plot和polycharts,但经过多次尝试后,我仍然没有成功使用rCharts(包括rHighcharts).

这是最后一次尝试的文件:

server.R:

library(rCharts)
shinyServer(function(input, output) {
  output$myChart <- renderChart({
    h1 <- Highcharts$new()
    h1$chart(type = "spline")
    h1$series(data = c(1, 3, 2, 4, 5), dashStyle = "longdash")
    h1$series(data = c(NA, 4, 1, 3, 4), dashStyle = "shortdot")
    h1$legend(symbolWidth = 80)
    return(h1)
  })
})
Run Code Online (Sandbox Code Playgroud)

ui.R:

require(rCharts)
shinyUI(pageWithSidebar(
  headerPanel("rCharts: Highcharts"),
  sidebarPanel(
    selectInput(inputId = "x",
      label = "Choose X",
      choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'),
      selected = "SepalLength")
    ),
  mainPanel(showOutput("myChart", "Highcharts")
  )
))
Run Code Online (Sandbox Code Playgroud)

我的假设是"showOutput"的第二个参数可能是错误的,但我没有找到任何东西.

r highcharts shiny rcharts

11
推荐指数
1
解决办法
9577
查看次数

在rcharts NVD3 lineChart中的绘图区域

我想用rCharts的NVD3 lineChart图使用area = true选项绘制不同种群的分布,如http://nvd3.org/examples/line.html.

我在这里工作:

require(devtools)
install_github('ramnathv/rCharts')
require(rCharts)

df<-data.frame(X=rep(1:4,2),Y=1:8,fil=c(rep("A",4),rep("B",4)))

denp <- nPlot(Y ~ X, group = 'fil', data = df, type = 'lineChart')
denp$chart(color =c('#ff7f0e', 'blue', 'green'))
denp$yAxis(axisLabel= 'Density')
denp$xAxis(axisLabel= 'Value')
denp$chart(margin = list(left=80,bottom=80))
denp$yAxis(tickFormat = "#!function (x,y,e) { return }!#")
denp$xAxis(tickFormat = "#!function (x,y,e) { 
tickformat = ['0,01','0,1',1,10,100,1000,10000,'100k'];
return tickformat[x+2];}!#")
denp$chart(tooltipContent = "#! function(key, val, e, graph){
return '<h3>' + '<font color=blue>'+ key +'</font>'+ '</h3>' + '<p>'+ val } !#")

denp
Run Code Online (Sandbox Code Playgroud)

我发现的问题是我无法将area参数切换为true.我试过了:

denp$chart(area=TRUE)
denp$chart(area=c(TRUE,TRUE,TRUE))
denp$chart(area=c('true'))
denp$chart(area=c('true','true','true'))
denp$chart(area=c('#!true!#')) …
Run Code Online (Sandbox Code Playgroud)

r linechart area nvd3.js rcharts

10
推荐指数
1
解决办法
561
查看次数

街道地址到地理位置lat/long

我正在考虑rChart/LeafLet为我县的房屋销售创建一个闪亮的应用程序.在任何给定的时间有几百个房子待售.想要为所有人映射街道地址到地理位置(纬度/经度)并在地图上显示它们.所以,我正在寻找可以将街道地址映射到地理位置的ar包,服务或数据库.

r geolocation leaflet rcharts

10
推荐指数
2
解决办法
2万
查看次数

Rcharts nvd3 2-D zoom可能吗?

在nvd3中是否有缩放功能,我可以直接输入我的R源代码(如果只要我不需要更改nvd3源代码就需要javascript无关紧要)?我尝试了lineWithFocusChart,但只是沿着x轴放大,而我想理想的是在缩放部分周围画一个框,它会缩放到我绘制框的位置.即使这是不可能的,如果nvd3支持任何类型的2-d变焦,那将是非常棒的!我提供了一个可重现的例子,我到目前为止,但我还没有找到我正在寻找的缩放功能.谢谢!

      library(rCharts)
      temp <- data.frame(x = 1:100, y = 1:100, z = c(rep(1,50), rep(0,50)))
      g <- nPlot(y ~ x, group = "z", data = temp, type = "lineChart")
      g$templates$script <- "http://timelyportfolio.github.io/rCharts_nvd3_templates/chartWithTitle_styled.html"
      g$set(title = "Example")  
      g$chart(transitionDuration = -1,
              tooltipContent = "#! function(key, x, y) {
                                    return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y 
                                  }!#", 
              showLegend = FALSE, margin = list(left = 200, 
                                                right = 100, 
                                                bottom = 100,
                                                top = …
Run Code Online (Sandbox Code Playgroud)

javascript r zoom nvd3.js rcharts

9
推荐指数
1
解决办法
246
查看次数

在rCharts中为Sankey图添加颜色

我在rCharts中创建了一个sankey图,但有一个问题.如何添加颜色?我想用不同的颜色来表示每个节点,这样就可以更容易地对路径进行虚拟化,而不是仅仅看到连接所有内容的相同灰线.代码和输出如下:

    require(rCharts)
    require(rjson)

    x = read.csv('/Users/<username>/sankey.csv', header=FALSE)

    colnames(x) <- c("source", "target", "value")

    sankeyPlot <- rCharts$new()

    sankeyPlot$set(
     data = x,
     nodeWidth = 15,
     nodePadding = 10,
     layout = 32,
     width = 500,
     height = 300,
     units = "TWh",
     title = "Sankey Diagram"
    )

    sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey')

    sankeyPlot
Run Code Online (Sandbox Code Playgroud)

这是我的图表的样子

在此输入图像描述

非常感谢!

r rcharts sankey-diagram

8
推荐指数
1
解决办法
4284
查看次数