Comments (7)
in 1f37d1d, I start to add the Shiny
integration, by returning the celltext
/likely name of the clicked cell. Here is a basic example.
library(shiny)
library(treemap)
library(d3treeR)
data(business)
tm <- treemap(business,
index=c("NACE1", "NACE2","NACE3"),
vSize="employees",
fontsize.labels=12,
lowerbound.cex.labels=1, draw = F)
ui <- list(
d3tree2Output( 'tree' )
,textOutput( "clickedinfo", container = p )
)
server <- function( input, output, session ){
output$tree <- renderD3tree2({
d3tree2( tm )
})
# from https://github.com/rstudio/leaflet/blob/master/inst/examples/shiny.R
v <- reactiveValues(msg = "")
observeEvent(input$tree_click, {
v$msg <- paste("Clicked ", input$tree_click$name)
})
output$clickedinfo <- renderText(v$msg)
}
shinyApp( ui, server )
I'll start experimenting with the second part of the request which is a generalizable click handler that could trigger actions on the JavaScript side.
from d3treer.
@ellisp ad0d8b0 should provide a first implementation of clickAction
for d3tree2
. I opted for what I considered the easier but much more limited form of the implementation. If I can broaden my assumption that someone providing clickAction
understands JavaScript call
/this
, then I could use the more powerful form where I call
the clickAction
with d
which is all the node info, g
which is the SVG element, and el
which is the htmlwidget element. In this case function(){return this}
would give us an object {d:...,g:...,el:...}
from d3treer.
brilliant, I'll have a look some time this week
from d3treer.
This is great and gets me most of the way where I was hoping, except that when you get to the end of the hierarchy and click on one of the twigs of the tree it doesn't register. It doesn't need to for treemap-drawing purposes as it's already got the most granular graphic up there, but it would be good to have that final twig known to the app when it's clicked on.
from d3treer.
Oh I missed that. I should be able to push that out tonight. Thanks.
from d3treer.
I think I got it right in 3f30077. The examples provided above now communicate click/selection on the top grandparent level (title bar), parent level, and at the cell level including the leaves. If possible, please test on your end.
It is still not the most elegant solution, but I'll probably leave it as is for now.
Thanks again.
from d3treer.
Tested at my end and it does the job, thanks.
from d3treer.
Related Issues (20)
- Can Treemap options be maintained after rendering d3tree3 HOT 6
- height and width setting in d3tree or d3tree2 not working in shiny HOT 2
- cant install the library HOT 3
- package d3treeR not available HOT 10
- Treemap as input for reactive variable/function? HOT 4
- Interactive treemaps in loop (d3treeR) HOT 3
- Treemap isnt displayed HOT 1
- update to d3v5 HOT 1
- d3tree doesn't render HOT 5
- CRAN Any plan? HOT 17
- New Line in Group Name HOT 1
- Disable top right number and grey bar HOT 4
- tooltip help HOT 1
- d3TreeR not working in R version 3.5.3 HOT 2
- d3tree2 is not collapsing back when rootname is clicked HOT 3
- conflict between d3treeR and forceNetwork
- Can clickActions be set to follow a URL?
- xml error?
- R v4.0 HOT 1
- Cannot download this awesome package for R version 4.1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3treer.