Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lines between labels and slices #363

Closed
boygirl opened this issue Sep 16, 2016 · 11 comments · Fixed by #2734 or #2738
Closed

Lines between labels and slices #363

boygirl opened this issue Sep 16, 2016 · 11 comments · Fixed by #2734 or #2738
Assignees
Labels
Type: Enhancement ✏️ An enhancement or feature proposal that will be addressed after the next release

Comments

@boygirl
Copy link
Contributor

boygirl commented Sep 16, 2016

From @ekmartin on July 14, 2016 21:14

Would be nice if there was an option to enable indicator lines between the labels and the chart. Makes it a lot easier to see what labels belong to what slice.

Example (taken from react-d3):
image

Copied from original issue: FormidableLabs/victory-pie#106

@boygirl boygirl added the Type: Enhancement ✏️ An enhancement or feature proposal that will be addressed after the next release label Mar 11, 2017
@BrendanFDMoore
Copy link

I was surprised to discover this was not possible when looking at the label styling.

Can anybody speak to the place that might be appropriate for adding support for this in the code? Part of Pie vs part of Label etc.

Thanks!

@BrendanFDMoore
Copy link

BrendanFDMoore commented Jan 8, 2018

Digging down, I think I'd start poking around the getLabelProps in victory-pie and perhaps add support for a connectingLine style, or something like that.
https://github.com/FormidableLabs/victory-pie/blob/master/src/components/helper-methods.js#L55

Since we have the label x and y position and the chart center and outerRadius, we ought to be able to draw a line from the label to the chart when labelRadius > outerRadius.

@ngocht143
Copy link

How can we use @BrendanFDMoore ? Could you give a example?

@BrendanFDMoore
Copy link

Unfortunately I can't, @ngocht143 - sorry.

The above was my initial investigation to determine if it would be feasible to extend this functionality to meet a requirement.

I determined it should be possible to shoehorn in without too much trouble, but never actually did the work. We made the case for adjusting the requirements instead, so we no longer needed this capability.

Good luck! And if you do make the changes, I'd be happy to review the PR back to victory 👍

boygirl added a commit that referenced this issue Jul 17, 2018
@antonbehaeghe
Copy link

I'm trying to implement something like this with a custom LabelComponent. This component receives the x and y coordinates as props, but how do I go about positioning them correctly? I draw a line from the pie center to the x and y coordinates, but I want my actual label to be aligned with this. It also needs to be further away but I can't figure out the math for this. I've tried looking at the source for the label components and there seems to be a function the calculate the position, but I can't figure out what props it needs etc. Any ideas?

@DraGonM
Copy link

DraGonM commented Nov 22, 2019

@antonbehaeghe I've made demo
https://codesandbox.io/s/basic-victory-example-rfb7s

Things you looking for in Label and LabelLine, but this works only if you pass to chart width and height, otherwise you can't get the center point of the chart for lines calculation
And also I'm not sure why for correct render of lines it is necessary to rotate line by 90 degrees, in the demo, in utils/math.js
export const getXOffsetMultiplayerByAngle = angle => Math.cos(angle - 90 * radian)

Actually it will be cool if Chart by default passed coordinates of chart's center to Label

I hope this demo will help someone, who struggling with drawing lines from chart to labels

@carlaiau
Copy link

carlaiau commented Oct 6, 2021

Beautiful @DraGonM thank you very much

@presdec
Copy link

presdec commented May 6, 2022

Would love to see this implemented

@trancongdung12
Copy link

@DraGonM
Screen Shot 2022-06-17 at 11 05 21
How to draw the line like that? Pls help me

@DraGonM
Copy link

DraGonM commented Jun 17, 2022

@trancongdung12 Hey, I didn't work with charts for a long time, so it's not an ideal solution, but I think you can check this fork of the solution above https://codesandbox.io/s/basic-victory-example-forked-b090ed?file=/LabelLine.js

but basically, I just added one more point to <polyline> and played with some numbers for calculation, I hope this helps somehow.

@carbonrobot
Copy link
Contributor

Polyline will be tracked #2820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement ✏️ An enhancement or feature proposal that will be addressed after the next release
Projects
None yet
10 participants