graph2json: Generates JSON string correponding the the graph description

Description Usage Arguments Value Author(s) Examples

View source: R/dataformating.R

Description

Generates JSON string correponding the the graph description

Usage

1
2
3
4
5
graph2json(ndf, edf, innerValues = NULL, innerColors = NULL,
  innerTexts = NULL, starplotColors = NULL, starplotValues = NULL,
  starplotLabels = NULL, starplotTooltips = NULL, starplotUrlLinks = NULL,
  starplotSectorStartRad = NULL, starplotCircleFillColor = NULL,
  starplotCircleFillOpacity = NULL)

Arguments

ndf

A data.frame correponding to nodes definition

edf

A data.frame correponding to edges definition

innerValues

A matrix of numerical values for plotting in the node

innerColors

A matrix of string colors values for plotting in the node

innerTexts

A matrix of strings for plotting in the node

starplotColors

A matrix of hex RGB colors for sectors colors

starplotValues

A matrix of [0,1] values for starpot sectors size

starplotLabels

A matrix of labels identifying the sectors

starplotTooltips

A matrix of text or even html content for the sectors tooltips

starplotUrlLinks

A matrix of text for the sectors url links

starplotSectorStartRad

A matrix with a single column of [0,2PI] values for the sector start in radians

starplotCircleFillColor

A matrix of hex RGB colors for the circle background

starplotCircleFillOpacity

A matrix of [0.0,1.0] values for the circle background opacity

Value

A JSON string with formatting

Author(s)

Sylvain Gubian DL.RSupport@pmi.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
v <- c(0, 0, 1, 1, 0,
       0, 0, 0, 0, 0,
      -1, 0, 0, 1, 0)
a <- matrix(v, 3, 5)
colnames(a) <- LETTERS[1:5]
rownames(a) <- LETTERS[1:3]

nGlobal <- list(color="#dedeff")
nProp <- data.frame(shape=c('triangle', 'lozenge'))
rownames(nProp) <- c('C', 'E')
ndf <-getNodesDataFrame(A=a, nGlobal=nGlobal, nProp=nProp)

eGlobal <- list(color="#5555ff")
eProp <- data.frame(from=c('A','C'), to=c('B', 'A'), width=c(2,2))
edf <- getEdgesDataFrame(A=a, eGlobal=eGlobal, eProp=eProp)

graph2json(ndf=ndf, edf=edf)

Example output

RGraph2js: Convert a Graph into a D3js Script
Version 1.4.0 created on 2016-05-09.
Copyright (c) 2015 Stephane Cano, Sylvain Gubian, Florian Martin, PMP S.A.
Licensed under the GNU GENERAL PUBLIC LICENSE Version 2 <https://www.gnu.org/licenses/gpl-2.0.txt>.

[1] "{\"nodes\":[{\"shape\":\"circle\",\"color\":\"#dedeff\",\"id\":\"A\",\"urlLink\":\"\",\"name\":\"A\",\"nodeTooltipHtmlContent\":\"\",\"borderWidth\":1,\"barplotTexts\":[\"\"],\"barplotValues\":[0],\"barplotColors\":[\"#FFFFFF\"],\"starplotValues\":null,\"starplotColors\":null,\"starplotLabels\":null,\"starplotTooltips\":null,\"starplotUrlLinks\":null,\"starplotSectorStartRad\":[],\"starplotCircleFillColor\":[],\"starplotCircleFillOpacity\":[],\"x\":null,\"y\":null,\"fixed\":null},{\"shape\":\"circle\",\"color\":\"#dedeff\",\"id\":\"B\",\"urlLink\":\"\",\"name\":\"B\",\"nodeTooltipHtmlContent\":\"\",\"borderWidth\":1,\"barplotTexts\":[\"\"],\"barplotValues\":[0],\"barplotColors\":[\"#FFFFFF\"],\"starplotValues\":null,\"starplotColors\":null,\"starplotLabels\":null,\"starplotTooltips\":null,\"starplotUrlLinks\":null,\"starplotSectorStartRad\":[],\"starplotCircleFillColor\":[],\"starplotCircleFillOpacity\":[],\"x\":null,\"y\":null,\"fixed\":null},{\"shape\":\"triangle\",\"color\":\"#dedeff\",\"id\":\"C\",\"urlLink\":\"\",\"name\":\"C\",\"nodeTooltipHtmlContent\":\"\",\"borderWidth\":1,\"barplotTexts\":[\"\"],\"barplotValues\":[0],\"barplotColors\":[\"#FFFFFF\"],\"starplotValues\":null,\"starplotColors\":null,\"starplotLabels\":null,\"starplotTooltips\":null,\"starplotUrlLinks\":null,\"starplotSectorStartRad\":[],\"starplotCircleFillColor\":[],\"starplotCircleFillOpacity\":[],\"x\":null,\"y\":null,\"fixed\":null},{\"shape\":\"circle\",\"color\":\"#dedeff\",\"id\":\"D\",\"urlLink\":\"\",\"name\":\"D\",\"nodeTooltipHtmlContent\":\"\",\"borderWidth\":1,\"barplotTexts\":[\"\"],\"barplotValues\":[0],\"barplotColors\":[\"#FFFFFF\"],\"starplotValues\":null,\"starplotColors\":null,\"starplotLabels\":null,\"starplotTooltips\":null,\"starplotUrlLinks\":null,\"starplotSectorStartRad\":[],\"starplotCircleFillColor\":[],\"starplotCircleFillOpacity\":[],\"x\":null,\"y\":null,\"fixed\":null},{\"shape\":\"lozenge\",\"color\":\"#dedeff\",\"id\":\"E\",\"urlLink\":\"\",\"name\":\"E\",\"nodeTooltipHtmlContent\":\"\",\"borderWidth\":1,\"barplotTexts\":[\"\"],\"barplotValues\":[0],\"barplotColors\":[\"#FFFFFF\"],\"starplotValues\":null,\"starplotColors\":null,\"starplotLabels\":null,\"starplotTooltips\":null,\"starplotUrlLinks\":null,\"starplotSectorStartRad\":[],\"starplotCircleFillColor\":[],\"starplotCircleFillOpacity\":[],\"x\":null,\"y\":null,\"fixed\":null}],\"links\":[{\"color\":\"#5555ff\",\"source\":0,\"direction\":\"->\",\"target\":1,\"width\":2,\"linkTooltipHtmlContent\":\"\"},{\"color\":\"#5555ff\",\"source\":1,\"direction\":\"-|\",\"target\":3,\"width\":1,\"linkTooltipHtmlContent\":\"\"},{\"color\":\"#5555ff\",\"source\":1,\"direction\":\"->\",\"target\":4,\"width\":1,\"linkTooltipHtmlContent\":\"\"},{\"color\":\"#5555ff\",\"source\":2,\"direction\":\"->\",\"target\":0,\"width\":2,\"linkTooltipHtmlContent\":\"\"}]}"
Warning messages:
1: In nl$nodes[i] <- c(nl$nodes[i], list(contrastColors = ndf$name[highlightNodeColorsIdx],  :
  number of items to replace is not a multiple of replacement length
2: In nl$nodes[i] <- c(nl$nodes[i], list(contrastColors = ndf$name[highlightNodeColorsIdx],  :
  number of items to replace is not a multiple of replacement length
3: In nl$nodes[i] <- c(nl$nodes[i], list(contrastColors = ndf$name[highlightNodeColorsIdx],  :
  number of items to replace is not a multiple of replacement length
4: In nl$nodes[i] <- c(nl$nodes[i], list(contrastColors = ndf$name[highlightNodeColorsIdx],  :
  number of items to replace is not a multiple of replacement length
5: In nl$nodes[i] <- c(nl$nodes[i], list(contrastColors = ndf$name[highlightNodeColorsIdx],  :
  number of items to replace is not a multiple of replacement length

RGraph2js documentation built on Nov. 8, 2020, 8:17 p.m.