GithubHelp home page GithubHelp logo

searchtree's Issues

missing colname

ggtree(
  list(
    root = d3r::d3_nest(
      Titanic%>%data.frame%>%mutate(value=NA)%>%distinct,
    ),
    layout = "collapse"
  ),
  name="name"
)

d3r nesting order for SearchTree widget

#Doesnt give the value column in the leaves when branch fully grown
Titanic%>%as.data.frame

#Does give the value column in the leaves when branch fully grown
Titanic%>%data.frame%>%mutate(value=NA)%>%distinct

#Current Call
  #d3_nest doesnt nest in the correct order for ggtree.js making the links float to the last open parent
ggtree(
  list(
    root = d3r::d3_nest(
      Titanic%>%data.frame%>%mutate(value=NA)%>%distinct,
      value_cols = "Freq"
    ),
    layout = "collapse"
  ),
  name = "id",
  value = "colname"
)

#Call with old df2tree function
  #df2tree nests in the correct order for ggtree.js giving a unique parent for each child
ggtree(
  list(
    root=df2tree(Titanic%>%data.frame%>%mutate(value=NA)%>%distinct),
    layout = "collapse"
  ),
  name = "name",
  value = "value"
)

#Compare different nesting orders visually
jsonedit(d3r::d3_nest(
  Titanic%>%data.frame%>%mutate(value=NA)%>%distinct,
  value_cols = "Freq",
  json = F
))

jsonedit(df2tree(Titanic%>%data.frame%>%mutate(value=NA)%>%distinct))

wrapping text on tree

can you add this function to the js code to have text wrap on the tree? or switch out the .text() attr for .html() attr so users can input to names <br/>?

http://bl.ocks.org/mbostock/7555321

function wrap(text, width) {
  text.each(function() {
    var text = d3.select(this),
        words = text.text().split(/\s+/).reverse(),
        word,
        line = [],
        lineNumber = 0,
        lineHeight = 1.1, // ems
        y = text.attr("y"),
        dy = parseFloat(text.attr("dy")),
        tspan = text.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", dy + "em");
    while (word = words.pop()) {
      line.push(word);
      tspan.text(line.join(" "));
      if (tspan.node().getComputedTextLength() > width) {
        line.pop();
        tspan.text(line.join(" "));
        line = [word];
        tspan = text.append("tspan").attr("x", 0).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word);
      }
    }
  });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.