How to use an imported SVG with r2d3?

I'm struggling to get r2d3 to display a custom SVG.

I am trying to translate work by a friend who used used the following to
display the SVG in Python:

<!DOCTYPE html>
<meta charset="utf-8">
<script src=""></script>

where load_script is JS that loads data, inserts the SVG content, and the main_script is D3.

His main_script has

var mapSVG ='#svg24123');

Should I be doing something similar if I want to use r2d3? Below is my approach, which just outputs a blank white page in Viewer.

d3 <- "d3map/mymap.js"
css <- "d3map/style.css"
svg_path <- "d3map/campus_map.svg"
svg_content <- read_file(svg_path)
d3_content <- read_file(d3)

d3_script <- glue("
var svgContent = '{svg_content}';
var mapSVG ='body').append('svg');

r2d3(data, script = d3_script, css = css, d3_version = "6")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.