有没有一种方法可以通过API在Chord图amChart中切换节点?

时间:2019-11-26 16:10:38

标签: amcharts amcharts4

和弦图使用户可以单击节点并切换其非活动状态。查看预览。

Chord diagram with some disabled nodes

是否可以通过api禁用此节点?我想使用JS功能同时禁用某些节点。

1 个答案:

答案 0 :(得分:0)

与图表中的大多数对象一样,每个节点都有showhide方法,可用于切换其外观。和弦图将每个节点存储在Dictionary中,因此您将要使用getKey通过其名称访问该节点,然后调用openssl x509 -in client.crt -text -noout

hide

理想情况下,您希望在节点字典完全填充后调用此函数,例如在chart.nodes.getKey('Senica').hide() 事件期间。

datavalidated

演示:

chart.events.on('datavalidated', function() {
  chart.nodes.getKey('Senica').hide()
})
am4core.useTheme(am4themes_animated);

var chart = am4core.create("chartdiv", am4charts.ChordDiagram);
chart.hiddenState.properties.opacity = 0;

chart.data = [
    { from: "A", to: "D", value: 10 },
    { from: "B", to: "D", value: 8 },
    { from: "B", to: "E", value: 4 },
    { from: "B", to: "C", value: 2 },
    { from: "C", to: "E", value: 14 },
    { from: "E", to: "D", value: 8 },
    { from: "C", to: "A", value: 4 },
    { from: "G", to: "A", value: 7 },
    { from: "D", to: "B", value: 1 }
];

chart.dataFields.fromName = "from";
chart.dataFields.toName = "to";
chart.dataFields.value = "value";

// make nodes draggable
var nodeTemplate = chart.nodes.template;
nodeTemplate.readerTitle = "Click to show/hide or drag to rearrange";
nodeTemplate.showSystemTooltip = true;
nodeTemplate.cursorOverStyle = am4core.MouseCursorStyle.pointer

chart.events.on('datavalidated', function() {
  chart.nodes.getKey('A').hide();
  chart.nodes.getKey('B').hide();
  chart.nodes.getKey('D').hide();
})
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

#chartdiv {
  width: 100%;
  height: 500px;
}