ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.63k stars 6k forks source link

Interact with legend and display the selected data in line chart #1306

Open Huang-Libo opened 8 years ago

Huang-Libo commented 8 years ago

Can Charts do the job below ?

1. Just like the picture below, by default three legends are selected and displayed on line chart, then user can tap at legend to highlight some legends and append new data at line chart.

2. If user tap at line chart to select a day (x value), it will display today's (x value's) associated title and value in the center of line chart.

img_2920 img_2921 img_2922

danielgindi commented 8 years ago

Displaying that black box in the middle - is possible by implementing a custom Marker. (In v3 this also becomes much more easier).

Interactive legends are not yet supported - but are a nice feature request.

Huang-Libo commented 8 years ago

@danielgindi If I can get each legend's container(UILabel?) , then I can add gesture to interact with legend.

danielgindi commented 8 years ago

It's not a label - it's dynamically rendered. But the sizes are available internally. There's a function that calculates the expected layout, and then the renderer uses it to render. Since it is now implemented this way for a few months already - it makes it much easier to make the legend interactive.

We've thought about using layers - but it over complicates stuff, as we might change the rendering engine from CoreGraphics to something else in the future. I'm considering SK or a subset of it.

Huang-Libo commented 8 years ago

I see. By the way, what is SK?

liuxuan30 commented 8 years ago

@danielgindi I used to use a scroll view to hold the legend, clickable and has synergy with the highlight. I think current legend still has the space issue.

farshidce commented 8 years ago

i also highly need this feature for what i am working on. I looked at the code and as @danielgindi mentioned the legends are not distinct UILabels which you can attach recognizers. I don't mind spending time on adding this feature if this is not picked up by anyone else.

just thinking out loud here , is it possible to actually find out where user clicked using "(ChartViewBase *__nonnull)chartView" ?

reallyseth commented 8 years ago

I'm also interested in helping add this feature. @farshidce have you made any progress on this?

monkeyRing commented 8 years ago

+1

xuyecan commented 7 years ago

+1

manishpathak99 commented 7 years ago

+1

manishpathak99 commented 7 years ago

I want to add similar feature . Any progress ?

jlubeck commented 5 years ago

Is there any progress on this feature?