Methods
The following methods can be used to interact with TreeSpider programmatically
initialize
- Params:
none
If you want to manually initialize TreeSpider, set the autoInitialize
option to false
then programmatically call this method to manually initialize TreeSpider, example below:
const instance1 = new TreeSpider({
targetContainer: "#container-1",
autoInitialize: false
})
// ...
document.querySelector("#random-btn").onclick = () => instance1.initialize()
Click on the button below to initialize TreeSpider
resetZoom
- Params:
none
Call this method to reset the zoom level to the default zoom level, and this will also recenter or re-place the root chart head back to the default position.
updateChartHeadBg
- Params:
color: string
This method is for programmatically setting the background color of the chart heads, it takes in the color as the argument, the color can be in hex format or a color name or any other CSS formats, example below
const instance1 = new TreeSpider({
targetContainer: "#container-1"
})
// ...
document.querySelector("#random-btn").onclick = () => instance1.updateChartHeadBg('black')
on
- Params:
eventName: TEventType, callbackFn: (data?: any) => null
This method is a short form of the addEventListener
method and it works exactly like it, it can be used to listen to events, to learn more about using events check the events page, example below:
const instance1 = new TreeSpider({
targetContainer: "#container-1"
})
instance1.on("library.init", (e) => {
console.log("library has been initialized", e)
})