veg / phylotree.js

Interactive viewer of phylogenetic trees
http://phylotree.hyphy.org
MIT License
169 stars 71 forks source link

I don't know how make it work #437

Closed pedrogiroldo closed 7 months ago

pedrogiroldo commented 11 months ago

I wrote a little code to test the library, and it doesn't works... Why?

import React, { Component } from 'react'
  // @ts-ignore
  import { phylotree, TreeRender } from 'phylotree'

  export default function Home() {

      const tree = () => {
          const tree_nwk = new phylotree('(A,(B));')

          const renderedTree = tree_nwk.render({
              height: 1000,
              width: 1000,
              'left-right-spacing': 'fit-to-size',
              'top-bottom-spacing': 'fit-to-size',
              container: 'a'

          })

          renderedTree.show()
          console.log('aqui')
          console.log(tree_nwk)

      }

      tree()

      return (
          <div className='a'>
            Hello World
          </div>
      )
  }
thomasstjerne commented 8 months ago

I think you need to prefix the container with a dot when you are selecting by class name: container: '.a'

stevenweaver commented 8 months ago

Yes, and preferably, an id should be used.

    return (
        <div id='a'>
          Hello World
        </div>
    )
pedrogiroldo commented 7 months ago

Thanks for that, I already solved that problem!