Comments (12)
@NoAbdulrahman I have the same problem. It renders the first time but when I completely change the dataset I get the same error. If the Vue component is destroyed then recreated it works, but you can't just change the data. I did this by applying a key to the tree and changing it everytime the dataset changed
from vue.d3.tree.
@sunh11373 Hi, Please have a look at the closed issue #54. Use the prop identifier can solve your problem.
from vue.d3.tree.
Not sure how this can be resolved with "prop identifier". I need to replace the tree with a total different set of data with different number of nodes.
-thanks
from vue.d3.tree.
Hi @sunh11373 @Joun-lee Did you solve the problem? If yes, could you please tell me how to do? I have a similar problem and I don't understand how to solve it with the props identifier
from vue.d3.tree.
Hi, @NoAbdulrahman You can try my code below, see if it can solve your problem.
The html part
<tree
:data="currentRegionTree"
:duration="200"
node-text="name"
:identifier="getId" //this is a function defined in your 'methods' section
layoutType="horizontal"
type="tree"
:zoomable="true"
linkLayout="orthogonal"
></tree>
In the methods section of your vue component
getId(node) {
return node.id;
}
from vue.d3.tree.
@Joun-lee Thanks, I used the identifier, I have no error now, but the tree is still not displayed. I don't know if I'm missing something. Here is my code if you could have a look.
The html part:
<tree :data="tree" :identifier="getId" node-text="title" layoutType="horizontal"
type="tree" Duration="0" style="width:600px; height:600px" ...>
</tree>
The script:
export default Vue.extend({
name: "Products",
components: {
tree,
},
data() {
return {
tree:{}
};},
async created(){
const products = await this.FetchedData();
this.tree=products;
console.log(this.tree);
},
methods: {
async FetchedData(){
let response = await Service.getProducts()
let products = response.data.data;
products= JSON.stringify(products);
return products
},
getId(node) {
return node.id;
}, });
from vue.d3.tree.
Hi, @NoAbdulrahman Not sure why, but i would suggest you first check the 'tree' value, does it comply with the rule? Might use some simple static data firstly to check that, for example use the data below
tree: {
name: "father",
children:[{
name: "son1",
children:[ {name: "grandson"}, {name: "grandson2"}]
},{
name: "son2",
children:[ {name: "grandson3"}, {name: "grandson4"}]
}]
}
from vue.d3.tree.
@Joun-lee Thanks for your reply. The tree is displayed very well when I use my data as static, but it is not displayed when I try to fetch the same data from the API. The "console.log" in created() prints the data which means the data is fetched correctly, but I don't know why the tree is not displayed.
from vue.d3.tree.
Hi @David-Desmaisons , Do you have an idea about my issue above?
from vue.d3.tree.
Hi @NoAbdulrahman , usually I fetch data in the mounted function, maybe you can try do it in your mounted function.
from vue.d3.tree.
Using mount or created should not make any diference.
@NoAbdulrahman From waht you are describing nothing I can do. Try to check the example and apdat them.
It looks like something related on the data you are using not the component itself.
from vue.d3.tree.
My problem is solved by adding v-if=“dataLoaded” on the tree component and set the dataLoaded property to true loading the data. Also, I had to use json object instead of json string.
from vue.d3.tree.
Related Issues (20)
- Provide URL Link to the nodes
- how to collpase vued3tree data at first level
- Tree Rendering
- Highlight node
- Adding a child node expands all nodes in the tree. HOT 2
- The tree is not displayed when fetching data from API HOT 3
- Expected number > undefined HOT 1
- zoomable -> Error in mounted hook: "TypeError: Cannot read property 'transform' of undefined"
- not able to add the popup for adding the child from the node and deleting node HOT 3
- Any plans to support Vue3? HOT 1
- Draggable support?
- could not call event listener on node slot
- node at bottom
- [Vue warn]: Error in nextTick: "TypeError: Cannot read properties of undefined (reading 'x')" HOT 2
- Node structure does not update when the data is updated via code HOT 1
- How link one node with multiple parent nodes ?
- Does it have support to drag and drop one node under another node? There is a zoomable property and it doesn't seem to work for dragging and dropping nodes
- 请问支持自定义文本吗
- Usability and customizability issues in tree layout options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue.d3.tree.