bracketryjs
Visualize a knockout tournament in the browser

Lifecycle methods

These are the members of an object returned from createBracket():



// for example

import { createBracket } from 'bracketry'

const bracket = createBracket(your_data, your_wrapper_element, your_options)

bracket.setBaseRoundIndex(2)

moveToPreviousRound()

Parameters
     No parameters
Return value
     undefined

Calling this method will increment the base round index. You may need it when you implement your own navigation mechanism instead of a default one.





moveToNextRound()

Parameters
     No parameters
Return value
     undefined

Calling this method will decrement the base round index. You may need it when you implement your own navigation mechanism instead of a default one.





moveToLastRound()

Parameters
     No parameters
Return value
     undefined

Calling this method will set the base round index to a maximum possible number. You may need it when you implement your own navigation mechanism instead of a default one.





setBaseRoundIndex()

Parameters
Return value
     undefined

Calling this method will set the base round index to a given number. This number can be fractional if you like. You may need it when you implement your own navigation mechanism instead of a default one. You can also use this method to show Nth round at the very beginning (the last contentful round perhaps. But it will be your job to define the last contentful round):

import { createBracket } from 'bracketry'
        
const bracket = createBracket(data, wrapper)

bracket.setBaseRoundIndex(4)





getNavigationState()

Parameters
     No parameters
Return value
     An object containing some navigation info:





replaceData()

Parameters
Return value
     undefined

This method replaces the old data entirely. It's NOT a merge of old and new. If you need to update not the entire tournament but individual matches, then you probably need applyMatchesUpdates method instead of replaceData.





applyMatchesUpdates()

Parameters
Return value
     undefined

See this method in action here





getAllData()

Parameters
     No parameters
Return value

     An object containing all the tournament data which was previously provided to createBracket() or replaceData()





applyNewOptions()

Parameters
Return value
     undefined

Some options are not updatable, i.e. they will be ignored when passed to applyNewOptions:

   - all functional options (like "getMatchElement")
   - "verticalScrollMode"

import { createBracket } from 'bracketry'
        
const bracket = createBracket(your_data, your_wrapper_element, your_options)

bracket.applyNewOptions({ visibleRoundsCount: 1 })




getUserOptions()

Parameters
     No parameters
Return value

     An object containing all the options provided to createBracket() and (if applyNewOptions was called) merged with options provided to applyNewOptions()





highlightContestantHistory()

Parameters
Return value
     undefined

If a Contestant will be found for a given contestantId, such contestant's path within a tournament will be highlighted (connecting lines will attain a color specified by "highlightedConnectionLinesColor" option and contestant's title will attain a color specified by "highlightedPlayerTitleColor" option) To unhighlight what was highlighted before call highlightContestantHistory(null)





uninstall()

Parameters
     None
Return value
     undefined

Calling this method is recommended if you decide to install another bracket into the same wrapper element. Calling uninstall() in such cases will help release some precious memory. Though in most cases the best decision will be NOT to install another bracket into the same wrapper. If you need to switch to another tournament, better use replaceData().