graph2js: Generate the JSON code using D3js that draws A network from...

Description Usage Arguments Value Examples

View source: R/graph2js.R

Description

Generate the JSON code using D3js that draws A network from Adjacency matrix and edges, nodes properties.

Usage

1
2
3
4
5
6
7
8
graph2js(A, innerValues = NULL, innerColors = NULL, innerTexts = NULL,
  starplotValues = NULL, starplotColors = NULL, starplotLabels = NULL,
  starplotTooltips = NULL, starplotUrlLinks = NULL,
  starplotSectorStartedRad = NULL, starplotCircleFillColor = NULL,
  starplotCircleFillOpacity = NULL, nodesGlobal = NULL, nodesProp = NULL,
  edgesGlobal = NULL, edgesProp = NULL, outputDir = NULL,
  filename = NULL, opts = list(), userCssStyles = NULL,
  toolsPar = list(), id = getUUID())

Arguments

A

signed weighted adjacency matrix or an instance of the class graphAM, graphBAM, graphNEL or clusterGraph from the graph package

innerValues

A matrix of inner node values to display Barplot or other component. In a row, numerical values for a node.

innerColors

A matrix of colors for coloring the inner node barplot or component . In a row, colors values for a node.

innerTexts

A matrix of labels for each bar in inner barplots. In a row, labels values for a node.

starplotValues

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

starplotColors

A matrix of hex RGB colors for sectors colors

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

starplotSectorStartedRad

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 background opacity

nodesGlobal

A list of global nodes properties.

nodesProp

A data.frame object containing properties for specifics nodes width, shape (in 'rect', 'circle', 'lozenge', 'triangle'), link, tooltip, highlight.X (X from 0 to N for animation) columns

edgesGlobal

A list of global edges properties.

edgesProp

A data.frame object containing properties for specific edges from, to, width, type, link, color columns

outputDir

String that corresponds to the path to a folder or file where js code and dependencies will be generated. If NULL is provided, javascript code is returned in the returned list by the function with the slots:
'jsIncludes' A character string containing JS code for including the necessary JS files

'styling' A character string which contains the CSS code for the GraphRenderer component

'js' A character string containing the JavaScript code for the rendering of the data

'html' A character string containing the HTML code for the rendering of the component

filename

String the name of the result HTML file, a name will be automatically generated if not provided and by default.

opts

list of options of the GraphRenderer component (See getDefaultOptions function available options)

userCssStyles

String containing user css styles. (See starplot demo)

toolsPar

list of options for tools attached to GraphRenderer component. (See getDefaultToolParameters for details)

id

function, Unique IDs generator, Internal function getUUID by default.

Value

A list containing information of the generated js code.

Examples

1
2
3
4
5
6
7
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]
g <- graph2js(a)

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>.

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.