d3-area-label icon indicating copy to clipboard operation
d3-area-label copied to clipboard

Support Vertical Areas

Open curran opened this issue 7 years ago • 12 comments

Like this image

from Original StreamGraph Paper

curran avatar Aug 11 '17 05:08 curran

wrapping of text feature is also not available

vchouksey avatar Aug 21 '17 15:08 vchouksey

Indeed, that would be a cool feature! Any ideas on how it could be implemented?

curran avatar Aug 21 '17 19:08 curran

I tried to wrap using MBosstock wrapper function but not succeeded, here is the example where i used your d3 area label and MBosstock wrapper function https://jsfiddle.net/vishal_29/8zk9jqcg/

vchouksey avatar Aug 23 '17 21:08 vchouksey

Could you please clarify where this "MBosstock wrapper function" came from?

I think it can work. The label position function will need to know how many lines there are, and will need to know the bounding box of all the lines combined.

curran avatar Aug 24 '17 07:08 curran

Hey I got it working. It works if you apply the wrap function before positioning the labels. Here's a working jsFiddle https://jsfiddle.net/8zk9jqcg/1/ image

curran avatar Aug 24 '17 08:08 curran

Wow, we added new feature...

vchouksey avatar Aug 24 '17 10:08 vchouksey

topic_river

Does D3-AreaLabel can handle like labeling in image?

vchouksey avatar Aug 24 '17 10:08 vchouksey

Currently, it can position a single thing within an area, based on the bounding box of that thing. That single thing can contain multiple things, for example it could be an SVG <g> element with anything inside it.

From the image, I'm not sure what is really going on. But it seems there are multiple labels inside each stream, and those labels are each positioned individually. This is not something that D3-AreaLabel can do (yet).

curran avatar Aug 24 '17 13:08 curran

https://jsfiddle.net/vkchouksey/axor08ph/8/

Here, words getting overlap with other layers

vchouksey avatar Aug 25 '17 09:08 vchouksey

Yeah, this happens when there's a low number of data points. It's because of the curvyness of d3.curveBasis. This is what it looks like if you switch it to d3.curveLinear:

image

The label placement algorithm does linear interpolation, so effectively it treats the curve as though it's using d3.curveLinear, even thought it may not be. I haven't figured out a way to use the actual curve - I would love to change it to use the real curve, but I'm not sure how.

curran avatar Aug 25 '17 12:08 curran

HI Curran,

Little stucked labelling is not working this time, I am attaching image of chrome debugging console screen and code on codepen.

https://codepen.io/vchouksey/project/editor/XwKbMe

screen shot 2017-08-31 at 11 03 23

vchouksey avatar Aug 31 '17 09:08 vchouksey

I got vertical areas working in sort of a hacky way here, with word wrapping https://bl.ocks.org/curran/c567efde3b3da7bc1f642627072aabfc

image

curran avatar Oct 04 '17 14:10 curran