ssthouse / tree-chart

Flexible tree chart using Canvas and Svg, powered by D3.js; ✅Support Vue, Vue3 and React;
https://ssthouse.github.io/tree-chart/#/svgTree
MIT License
435 stars 96 forks source link

Vue 2 version missing enableCollapse param on init() method #112

Closed freestyledork closed 2 years ago

freestyledork commented 2 years ago

When testing out the functionality of this package I noticed the collapse wasn't working. I traced it to the core init not properly setting the enableCollapse param. Not sure if other versions are affected.

TreeVue.vue

    init() {
      this.treeChartCore = new TreeChartCore({
        svgElement: this.$refs.svg,
        domElement: this.$refs.domContainer,
        treeContainer: this.$refs.container,
        dataset: this.dataset,
        direction: this.direction,
        treeConfig: this.config,
        collapseEnabled: this.collapseEnabled,       <---------- not present in TreeVue.vue 
      });
      this.treeChartCore.init();
      this.nodeDataList = this.treeChartCore.getNodeDataList();
      this.initialTransformStyle =
        this.treeChartCore.getInitialTransformStyle();
    },

...tree-chart/index.js

    this.treeConfig = {
      nodeWidth: DEFAULT_NODE_WIDTH,
      nodeHeight: DEFAULT_NODE_HEIGHT,
      levelHeight: DEFAULT_LEVEL_HEIGHT,
    };
    this.linkStyle = TreeLinkStyle.CURVE;
    this.direction = Direction.VERTICAL;
    this.collapseEnabled = true;
    this.currentScale = 1;
    if (params.treeConfig) {
      this.treeConfig = params.treeConfig;
    }
    this.collapseEnabled = params.collapseEnabled;       <------------ ends up being undefined.
    this.svgElement = params.svgElement;
    this.domElement = params.domElement;
    this.treeContainer = params.treeContainer;
    this.dataset = this.updatedInternalData(params.dataset);
  }
ssthouse commented 2 years ago

@freestyledork Hi, sorry for the late reply!

this issue has been fixed in version 0.6.6, please check.