How to make a tooltip for a chart in d3? - d3.js

We need to make it move like here.example The code is complex there, I can't figure it out.
I wrote the code my code, but I don’t understand how to make the tooltip move horizontally not behind the mouse, but near the nearest horizontal mark (as in the example)
It is not yet clear where the text above the bold text in the tooltip comes from. How to remove it so that it looks like in the picture?
How do I make the title of the tooltip match the label on the X-axis?

There are many ways to accomplish this. The way I typically do this is to create a series of SVG elements -- such as circles or rects -- using the same scale and data as the paths.
You can make these objects visible or invisible. Either way, you can attach mouseenter, mouseleave events to each to render and populate the tooltip.

Related

dimple.js: Tool-tip placement in a chart of a nested svg element

I am trying to modify Bullet Charts example of dimple.js with each bullet chart being in a child-svg of the parent-svg. Purpose of having individual svg for each bullet chart is to make their management (show/hide/remove) easier. Also, this makes the recursive definition of a chart complete - That is, a chart is contained by an svg.
The fiddle for the modified version is here....
As you can see, from 2nd chart onwards, on mouse hover, tool tips go out of place!!! Please note that, for child-svg, I've set the style overflow: visible without which tool-tips were not visible at all.
Want to know if I am missing anything in handling the attributes of child-svg elements or is it a bug in dimple.js. Also, please let me know if you know of any workaround.
Thanks.
One of the first questions I have is why do you want child svg elements? What are you trying to accomplish?
The only difference I see in your code and the example is the height / width swap at the top and the sub svg + bounds.
Keep in mind that the origin changes with each sub-svg. This might be why you are having trouble with the tool-tips. Maybe you have that worked into your add-bullet calls.
I think nagu has the right approach here if you really want separate svg elements.

How could I get a single d3 selection (or array of dom elements) that includes all the exiting elements as well as new and existing ones?

I'm trying to get a stacked bar chart to animate correctly as bars come and go. There's probably a good example of this somewhere (I'll ask as a separate question: How to correctly transition stacked bars in d3.js), but the examples I'm finding don't show transitions with individual stack elements exiting and entering.
My idea is to make a tween function that sets the y of each bar to the top of the of the bar beneath it. I want to make sure that as bars are exiting, they drag down the bars above them, and as they're entering, they push up the bars above them. And I don't want any gaps or overlaps midway through the transition.
But to get this to work, I would ideally have a list of all the bars--exiting, entering, existing--in order, and I would be able to tell which category each bar belonged to. So, I could kludge something together, assembling a single array from rects, rects.enter(), and rects.exit() (after something like
rects = d3.selectAll('g.barGroups').selectAll('rects').data(newData)
.)
But there's got to be a better way.

HTML5 Canvas: Create tooltip on customized drawing

I am using Flot to plot images for our project. For pre-defined shapes like line, pie, I can add tooltip through flot.tooltip.
However, we have some images that are drawn through Html5 canvas API, such as Here. I would like to add a tooltip for the red rectangle and another tooltip for the blank area. Any library to make it work?
With canvas there isn't a good way to detect when the mouse hovers over a particular drawn item; it's just a buffer, with no idea of what operations were used to draw into it. Flot's own hover detection has no concept of what was drawn on the canvas; it just knows that, e.g. the pie starts at a particular point and extend outwards a certain number of pixels.
So no matter what, you will have to write a function that accepts a mouse event, examines whatever data you used to draw the image, and decides what that corresponds to.
Where Flot could help is in providing a way to override the built-in hover function with your own; then the tooltip plugin would simply work with your function. Since you can't currently do that, you have a choice of a) modifying the tooltip plugin to use your function, or b) registering your own mousemove listener on the overlay element, which then generates 'fake' plothover events for the tooltip plugin to consume.

Extending a crossfilter/d3 example to handle wrapping bar charts

I am in the process of trying to extend Jason Davies' example of crossfilterjs example (you can see it here at http://square.github.io/crossfilter/) to make it able to hand larger data sets. My idea was to make the bar charts wrap.
This is what I have so far: http://bl.ocks.org/elsherbini/5564315
I am trying to figure out how I could make the axis and brush wrap as well. If you open that example in a full window, you can see that right now it just draws the axis at the bottom, and the brush goes over the whole thing. My goal is to make the brush and axis wrap as well, but I'm not sure how to proceed.
Does anyone have experience trying to extend d3.svg.axis() or d3.svg.brush()? Do I need to extend those at all, or is there some other workaround?

On Mouseover make text arc

I never have much luck trying to put code into this text area.
My question is how to modify the on mouseover (jsfiddle) so that I start with (DHTML) text and when you mouseover it arcs the text, then mouse out it returns to the original position. Even a link to a site with help.
Use one of the following methods to generate the arc and the text:
SVG
CSS3
Raphael.js
CSSWarp generator
Then bind a mouseover event to the container of the text content to produce the desired effect.

Resources