knitr::opts_chunk$set(echo = TRUE) library(svgR)
For initial SVG development it is convenient to keep the svgR in a seperate file Thus we - put svgR code in a seperate file: shinyInputControl_svg.R - create a wrapper to source the svg - call that wrapper from the constructor for shinyInputControl
Updating is the act of sending a message from the server to the client. The message contains info to recreate appearence and value
The purpose of updating is to perform 2 objectives:
I. Braindead: (minimal js)
1. Recreate the svgTree with using new params 2. Form message = value + svg 3. send to the client 4. client replaces tree and updates value
II. Mixedup:
1. Recreate the svg with using new params 2. get id of svg node that is affected 3. Extract affected node from svg to send 4. Form message = value + replacement-node + id of node 5. send to the client 6. find node given id and replace with replacement-node
III. Traditional: (uses more js)
1. Form message = value 2. Send to client 3. Use javascript to update appearence base on value.
We recommend the Kindergarden strategy to begin with.
The appearance of the control can be changed in one of two ways:
Prior to sending the value to the server via setValue use javascript to modify the appearance. For example, one might do this inside the :clicked function.
Inside the inputhandler function, after receiving the value, call an update with the new value to force the client to redraw the control with that new value.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.