styling the popup tooltips

1,339 views
Skip to first unread message

Jacob Hite

unread,
Oct 8, 2013, 3:11:11 AM10/8/13
to dc-js-us...@googlegroups.com

Hi,

I'm a little stumped on how to add styling to the popup tooltips. I'd like to be able to customize the size of the popup box (add some padding, maybe round the corners), change the background color of the popup box, adjust fonts, font sizes, bold, etc...

I haven't been able to find the 'hook' to allow me to do this.

Can someone please point me in the right direction?

Thanks!

Nick Zhu

unread,
Oct 9, 2013, 12:09:52 PM10/9/13
to Jacob Hite, dc-js-us...@googlegroups.com
You cant. the tooltip is currently generated using SVG title which gets rendered as tooltip on most browser. Though it is possible to implement your own tooltip using javascript and html div however not currently supported by dc.js out-of-box.

Jacob Hite

unread,
Oct 9, 2013, 11:55:57 PM10/9/13
to Nick Zhu, dc-js-us...@googlegroups.com
Thanks Nick. I'll go ahead and implement my own. Can you advise though on how I turn off the SVG title tooltips?

Jacob Rideout

unread,
Oct 10, 2013, 5:37:42 PM10/10/13
to dc-js-us...@googlegroups.com, Jacob Hite
Something like this: http://bl.ocks.org/ilyabo/1373263 shouldn't be to hard to adopt on top of a dc chart.

Jacob Hite

unread,
Oct 11, 2013, 4:16:41 AM10/11/13
to Jacob Rideout, dc-js-us...@googlegroups.com
Thanks...this looks pretty good. I'll give it a go and try it with dc. There is still the question of if you put this on top of a dc chart how can the dc tooltip be disabled so that you don't get 2 tooltips (dc's tooltip and your custom html tooltip)?


Gordon Woodhull

unread,
Oct 11, 2013, 4:23:06 AM10/11/13
to Jacob Hite, Jacob Rideout, dc-js-us...@googlegroups.com
.renderTitle(false)
?

Jacob Hite

unread,
Oct 11, 2013, 5:08:16 AM10/11/13
to dc-js-us...@googlegroups.com, Jacob Hite, Jacob Rideout

Doh! Yeah. I knew that... %-)

Thanks for the reminder and sorry for the silly question.

Gordon Woodhull

unread,
Oct 11, 2013, 5:56:21 PM10/11/13
to Jacob Hite, dc-js-us...@googlegroups.com, Jacob Hite, Jacob Rideout
Someone also recently pointed out
on the d3 mailing list.

Please let us know what you come up with. It would be nice to have an option or an example since this is a FAQ.

Jacob Hite

unread,
Oct 14, 2013, 2:00:28 AM10/14/13
to Gordon Woodhull, dc-js-us...@googlegroups.com, Jacob Rideout
Will look into d3-tip. Looks interesting.

Unfortunately there seems to be a bug (feature) in dc.js regarding bar charts. Setting renderTitle(false) has no effect on bar charts. I'm using dc.js 1.6.0 and looking at how bar charts get rendered on lines: 3372 - 3380

function renderBars(layer, d, i) {
  var bars = layer.selectAll("rect.bar")
        .data(d.points);

  bars.enter()
         .append("rect")
         .attr("class", "bar")
         .attr("fill", _chart.getColor)
         .append("title").text(_chart.title());

...

There is no check of if renderTitle is set to true or false. It appends the title no matter what.



Jacob Rideout

unread,
Oct 14, 2013, 11:36:30 AM10/14/13
to dc-js-us...@googlegroups.com, Gordon Woodhull, Jacob Rideout
I went ahead and fixed the bug. 

Sara Quigley

unread,
Oct 14, 2013, 5:30:47 PM10/14/13
to dc-js-us...@googlegroups.com, Gordon Woodhull, Jacob Rideout
I included some tooltips in some dc.js charts (using https://github.com/Caged/d3-tip) here:   http://saraquigley.github.io/uc-trends/

I hope that helps!

Sara

Jacob Hite

unread,
Oct 14, 2013, 10:27:44 PM10/14/13
to Sara Quigley, dc-js-us...@googlegroups.com, Gordon Woodhull, Jacob Rideout
Thanks Jacob for the quick fix!

Thanks Sara for the pointer to d3-tip usage with dc.js!


NK

unread,
Nov 18, 2013, 7:20:06 PM11/18/13
to dc-js-us...@googlegroups.com, Gordon Woodhull, Jacob Rideout
Hey Sara,

Any feedback on how you got rid of the browser enabled yellow tooltip boxes? I can't seem to get rid of them

Thanks

-N

Jacob Rideout

unread,
Nov 20, 2013, 4:53:21 PM11/20/13
to dc-js-us...@googlegroups.com, Gordon Woodhull, Jacob Rideout
Not setting .title(), should work.

jinges

unread,
Mar 16, 2014, 1:53:53 PM3/16/14
to dc-js-us...@googlegroups.com, Jacob Rideout
Hi Jacob,

I'm looking into building a custom tiptip. How did yours turned out? Do you have any links?

Thanks!

Wilson Fok

unread,
Aug 10, 2014, 8:14:08 AM8/10/14
to dc-js-us...@googlegroups.com, gor...@woodhull.com, ja...@jacobrideout.net
I couldn't get the tooltip to work with dc line chart, please help. Should I be using d3.selectAll('g.stack') ?

Regards,
Wilson
Reply all
Reply to author
Forward
0 new messages