Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

javascript - amCharts4 - in a Force Directed Tree, I want to click on any second level node and it should scroll down to a anchor in the same page

I am using the Force Directed Tree from amCharts4 as a navigation option. I have a tree with only 2 levels. When I click on the top level nodes they expand and retract as expected. If I click on the second level nodes, it should scroll down to an anchor in the same page. The id of the target anchor is part of the input data array, like:

networkSeries.data = [
   {
      "name":"Node 1",
      "value":200,
      "children": [
          { "name": "1", "label": "Children 1", value: 10, "url": "myAnchorChildren1" },
          { "name": "2", "label": "Children 2", value: 10, "url": "myAnchorChildren2" },
          { "name": "3", "label": "Children 3", value: 10, "url": "myAnchorChildren3" }
        ]
   },
   ....
];

I have managed to create clickable nodes with template.url. However, the template.url option is applied to all levels, which means that I loose the expand and retract feature of the top nodes. I guess it can be achieved with adapters, but I could not find how.

Thank you in advance.

question from:https://stackoverflow.com/questions/65622901/amcharts4-in-a-force-directed-tree-i-want-to-click-on-any-second-level-node-a

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...