最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - c3.js - how to show hand cursor on bar chart hover - Stack Overflow

programmeradmin1浏览0评论

In pie charts c3js by default shows a hand cursor (pointer) when pie slice is hovered. I would like to have the same behavior for each bars in a bar chart. How to achieve that?

I tried the below css but it shows the hand cursor even when you hover in between 2 bars.

.c3-event-rect {
    cursor:pointer;
}

To clarify this is a jsfiddle example I'd like to have pointer cursor only on bar items because only them are clickable.

In pie charts c3js by default shows a hand cursor (pointer) when pie slice is hovered. I would like to have the same behavior for each bars in a bar chart. How to achieve that?

I tried the below css but it shows the hand cursor even when you hover in between 2 bars.

.c3-event-rect {
    cursor:pointer;
}

To clarify this is a jsfiddle example I'd like to have pointer cursor only on bar items because only them are clickable.

Share Improve this question edited Sep 22, 2015 at 11:47 zmark asked Sep 22, 2015 at 9:24 zmarkzmark 1272 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

After way too much time spent, I finally figured out a solution. Here is a jsfiddle, which explains the two lines of code in some detail (in ments).

If you don't understand the details, don't worry about it or just ask me to elaborate. :)

tl;dr:

  1. data: { selection: { enabled: true }, [...]
  2. .c3-bar { cursor: pointer; }

Just use the following CSS

.c3-bar {
    pointer-events: auto !important;
}

Note that you need the !important to override the inline pointer-events: none that C3 adds to the bars.

发布评论

评论列表(0)

  1. 暂无评论