-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Quarto GHA Workflow Runner
committed
Nov 21, 2024
1 parent
ec1b899
commit 9161ff6
Showing
10 changed files
with
1,762 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
23d3c3a2 | ||
03b95846 |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.DiagrammeR,.grViz pre { | ||
white-space: pre-wrap; /* CSS 3 */ | ||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ | ||
white-space: -pre-wrap; /* Opera 4-6 */ | ||
white-space: -o-pre-wrap; /* Opera 7 */ | ||
word-wrap: break-word; /* Internet Explorer 5.5+ */ | ||
} | ||
|
||
.DiagrammeR g .label { | ||
font-family: Helvetica; | ||
font-size: 14px; | ||
color: #333333; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
HTMLWidgets.widget({ | ||
|
||
name: 'grViz', | ||
|
||
type: 'output', | ||
|
||
initialize: function(el, width, height) { | ||
|
||
return { | ||
// TODO: add instance fields as required | ||
}; | ||
}, | ||
|
||
renderValue: function(el, x, instance) { | ||
// Use this to sort of make our diagram responsive | ||
// or at a minimum fit within the bounds set by htmlwidgets | ||
// for the parent container | ||
function makeResponsive(el){ | ||
var svg = el.getElementsByTagName("svg")[0]; | ||
if (svg) { | ||
if (svg.width) {svg.removeAttribute("width")} | ||
if (svg.height) {svg.removeAttribute("height")} | ||
svg.style.width = "100%"; | ||
svg.style.height = "100%"; | ||
} | ||
} | ||
|
||
if (x.diagram !== "") { | ||
|
||
if (typeof x.config === "undefined"){ | ||
x.config = {}; | ||
x.config.engine = "dot"; | ||
x.config.options = {}; | ||
} | ||
|
||
try { | ||
|
||
el.innerHTML = Viz(x.diagram, format="svg", engine=x.config.engine, options=x.config.options); | ||
|
||
makeResponsive(el); | ||
|
||
if (HTMLWidgets.shinyMode) { | ||
// Get widget id | ||
var id = el.id; | ||
|
||
$("#" + id + " .node").click(function(e) { | ||
// Get node id | ||
var nodeid = e.currentTarget.id; | ||
// Get node text object and make an array | ||
var node_texts = $("#" + id + " #" + nodeid + " text"); | ||
//var node_path = $("#" + nodeid + " path")[0]; | ||
var text_array = node_texts.map(function() {return $(this).text(); }).toArray(); | ||
// Build return object *obj* with node-id, node text values and node fill | ||
var obj = { | ||
id: nodeid, | ||
//fill: node_path.attributes.fill.nodeValue, | ||
//outerHMTL: node_path.outerHTML, | ||
nodeValues: text_array | ||
}; | ||
// Send *obj* to Shiny's inputs (input$[id]+_click e.g.: input$vtree_click)) | ||
Shiny.setInputValue(id + "_click", obj, {priority: "event"}); | ||
}); | ||
} | ||
|
||
// set up a container for tasks to perform after completion | ||
// one example would be add callbacks for event handling | ||
// styling | ||
if (typeof x.tasks !== "undefined") { | ||
if ((typeof x.tasks.length === "undefined") || | ||
(typeof x.tasks === "function")) { | ||
// handle a function not enclosed in array | ||
// should be able to remove once using jsonlite | ||
x.tasks = [x.tasks]; | ||
} | ||
x.tasks.map(function(t){ | ||
// for each tasks add it to the mermaid.tasks with el | ||
t.call(el); | ||
}); | ||
} | ||
} catch(e){ | ||
var p = document.createElement("pre"); | ||
p.innerText = e; | ||
el.appendChild(p); | ||
} | ||
} | ||
|
||
}, | ||
|
||
resize: function(el, width, height, instance) { | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@layer htmltools { | ||
.html-fill-container { | ||
display: flex; | ||
flex-direction: column; | ||
/* Prevent the container from expanding vertically or horizontally beyond its | ||
parent's constraints. */ | ||
min-height: 0; | ||
min-width: 0; | ||
} | ||
.html-fill-container > .html-fill-item { | ||
/* Fill items can grow and shrink freely within | ||
available vertical space in fillable container */ | ||
flex: 1 1 auto; | ||
min-height: 0; | ||
min-width: 0; | ||
} | ||
.html-fill-container > :not(.html-fill-item) { | ||
/* Prevent shrinking or growing of non-fill items */ | ||
flex: 0 0 auto; | ||
} | ||
} |
Oops, something went wrong.