c3.js how to get a onclick event for DataGroups

↘锁芯ラ 提交于 2021-01-27 11:21:19

问题


I have been using c3.js and cant figure out how to get a JavaScript event for onClick of the Data group labels which is displayed in X Axis.

Basically i need event to which I can register a event handler in the below Circled area.

enter image description here


回答1:


There is no method, as of yet, in c3js for adding onClick events on ticks.

But you can directly use d3:

d3.selectAll('.tick')
  .on('click', function(value,index){
      alert('You clicked a tick.');
  });

This will add an event that will fire when you click a tick.

jsfiddle sample : http://jsfiddle.net/Lc3447Lb/1/

Source: https://github.com/masayuki0812/c3/issues/761



来源:https://stackoverflow.com/questions/28742630/c3-js-how-to-get-a-onclick-event-for-datagroups

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!