Skip to content

local images do not load #477

Open
Open
@FBartos

Description

@FBartos

Hi, I wanted to add local images to the network, but I can't figure out how to do so.

I managed to reproduce the example without an error,

library(visNetwork)

path_to_images <- "https://raw.githubusercontent.com/datastorm-open/datastorm-open.github.io/master/visNetwork/data/img/indonesia/"

nodes <- data.frame(id = 1:4, 
                    shape = c("image", "circularImage"),
                    image = paste0(path_to_images, 1:4, ".png"),
                    label = "I'm an image")

edges <- data.frame(from = c(2,4,3,3), to = c(1,2,4,2))

visNetwork(nodes, edges, width = "100%") %>% 
  visNodes(shapeProperties = list(useBorderWithImage = TRUE)) %>%
  visLayout(randomSeed = 2)

Image

But whenever I try using any other images, just blank nodes appear. For example, I downloaded the corresponding images to my working directory from https://github.com/datastorm-open/datastorm-open.github.io/tree/master/visNetwork/data/img/indonesia
such as

> list.files()
[1] "1.png"  "2.png"  "3.png"  "4.png"  "test.R"

then

nodes <- data.frame(id = 1:4, 
                    shape = c("image", "circularImage"),
                    image = paste0(1:4, ".png"),
                    label = "I'm an image")

edges <- data.frame(from = c(2,4,3,3), to = c(1,2,4,2))

visNetwork(nodes, edges, width = "100%") %>% 
  visNodes(shapeProperties = list(useBorderWithImage = TRUE)) %>%
  visLayout(randomSeed = 2)

results in
Image

without any errors or warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions