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

Moving pie chart location (legend overlaps chart) #707

Closed
royherma opened this issue Jan 25, 2016 · 8 comments
Closed

Moving pie chart location (legend overlaps chart) #707

royherma opened this issue Jan 25, 2016 · 8 comments

Comments

@royherma
Copy link

Is there a way to control the location of the actual chart within the actual PieChartView? My view spans across the whole view controller's UIView, but is always centered. The rendering rect is private for the PieChartView so I can't access it, any ideas of how I can solve the issue (could involve legend as well). I added a picture for reference.

Thanks!

img_4660

@liuxuan30
Copy link
Member

I just played with the ChartsDemo pie chart, similar case. I guess you have to modify some code and re-build it so you can use.
however, I think this is not a good way, but actually you can choose write your own chart legend, like putting it in a scroll view, or some tricks
@danielgindi I found another bug is, in charts demo, if you drag the slider, the pie chart radius trend is: decreasing --> increasing

@dushiarlind
Copy link

Hi royhema

I want to use pieBarChar but there's no documentation on how to use it , and I tried to translate demo project as I don't know Objective-C but a lot of errors are showing , can you just show me how to get and put hard coded values just as an example , so I get an idea on how to work with dynamic numbers . Thanks very much.
And sorry for the off-topic question.

@liuxuan30
Copy link
Member

@dushiarlind your question is not clear. you have to understand you just needs to create pie chart data set with your values, and create pie chart data and feed it to pie chart view. Objc is one of the most easiest code to read and understand, you just have to get the idea. take a look at - (void)setDataCount:(int)count range:(double)range in pieChartViewController,

PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithYVals:yVals1 label:@"Election Results"];
_chartView.data = data;
is how you create it and feed it to chart view.
But do remember, first configure your chart view, and then set the data, not the revsered way.

@dushiarlind
Copy link

@liuxuan30 Sorry for not clearing things up.

I've put a uiview in my storyboard , set class to PieChartView and created an IBOutlet .

Now I need this pie to show me 3 slices with different numbers which will come to me from json object.
Let's say I parsed the numbers and stored them in 3 variables. Now I want to put them in the pieChart.
How do I do that .
So I've got myPieChart and variables let slice1 , let slice2 and let slice3 which containt 3 different numbers.

@liuxuan30
Copy link
Member

as I said, "you have to understand you just needs to create pie chart data set with your values, and create pie chart data and feed it to pie chart view." You should look at the ChartsDemo first.
Please avoid your further questions on this thread. It's distracting. I do not suggest you open a new one for the same question, as the answer is obvious and already in the code, I merely say what the code say.

@keakalamudo
Copy link

@royherma Were you able to figure out moving the location of the PieChart or did you create a custom Scroll view for the legend like @liuxuan30 suggested?

@royherma
Copy link
Author

royherma commented Mar 2, 2016

I created a custom scroll view legend from scratch.

On Wed, Mar 2, 2016 at 11:14 AM, Kelo Akalamudo [email protected]
wrote:

@royherma https://github.com/royherma Were you able to figure out
moving the location of the PieChart or did you create a custom Scroll view
for the legend like @liuxuan30 https://github.com/liuxuan30 suggested?


Reply to this email directly or view it on GitHub
#707 (comment)
.

@danielgindi
Copy link
Collaborator

If you want complete control, you can now (on master) set the legend to drawInside, to avoid affecting the Pie's position. And then use custom offsets to move the pie around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants