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

Draw gradient line in line chart #537

Closed
luhui opened this issue Nov 6, 2015 · 19 comments
Closed

Draw gradient line in line chart #537

luhui opened this issue Nov 6, 2015 · 19 comments

Comments

@luhui
Copy link

luhui commented Nov 6, 2015

I want to draw a gradient line chart like the picture below:
image

It is a human temperature record. The gradient value follow the temperature, the color guide is the picture below:

image

In MPAndroidChart, below code will be work:

Paint paint = mChart.getRenderer().getPaintRender();
        paint.setShader(new LinearGradient(0, 0, 0, height, Color.RED, Color.BLUE, Shader.TileMode.REPEAT));

Did iOS-charts support these feature?

@liuxuan30
Copy link
Member

Currently, no. But it will be a good feature to have.

@ondrejhanslik
Copy link

In my opinion, ios charts need a more stable internal API and then removal of the internal keyword from most renderer methods. Then it will be simple to override a line drawing method with custom implementation. A chart library can never cover all use cases but it should be customizable.

@danielgindi
Copy link
Collaborator

We need to look into CoreGraphics and see if there's something similar to that shader effect

The problem with it though (on Android also!) is that it does not correlate to the colors that you have specified on your yAxis. It advances with the line, but not specifically on the yAxis.

I'm guessing that on both platforms it should be much more complex, as we'll need to break this stuff down ourselves and interpolate the colors.

Anyway, all the stuff in the renderers is public since v2.2.0!

@ondrejhanslik
Copy link

Thanks for the info, I am still on v2.1.x and didn't notice this. Good job! Then I believe this issue could be closed. On iOS everything is drawn through CGContext and for drawing gradients there is a special function CGContextDrawLinearGradient. Overriding the line drawing method is probably the only solution.

@liuxuan30
Copy link
Member

@danielgindi Do we support such gradient line already? I took some days off, not sure if we can close this.

@mobidever
Copy link

Hey do we have any update on the integration of the gradient lines?

@owenhay
Copy link

owenhay commented Apr 18, 2016

I'm interested in this issue, and I'm doing a chart UI implementation this week with a gradient, and I'll try the CGContextDrawLinearGradient override approach and report back.

@rohinb
Copy link

rohinb commented Aug 1, 2016

Any update on this? I'm working on a design with line charts using a gradient where the lines simply fades away toward the end.

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 2, 2016

@rohinb do you see the PR above? It's not merged yet. But you could give a try, overriding some methods

@coolioxlr
Copy link

any update on this?

@hananRiazz
Copy link

any update on this issue?

@thierryH91200
Copy link
Contributor

see #649

@jjatie
Copy link
Collaborator

jjatie commented Dec 28, 2017

#3141

@getabhishekified
Copy link

I have created a video tutorial for this task. Kindly refer to my video.

https://www.youtube.com/watch?v=zT6zMyYpkXM&t=13s

@Maxim-Gorin
Copy link

any update on this?

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 4, 2020

this is implemented in 4.0 branch, we are working on 4.0 merge actively, so stay tuned.

@a1049145827
Copy link

Is it finished now?

@YutaLin
Copy link

YutaLin commented Feb 24, 2021

Hi @liuxuan30, In previous version api I can set gradient color, but can't use it now. I got error when I fetch branch 4.0.0 currently.

Here's how I did, please help me, I implement in production app and can't work after I try pod install now, thanks!

pod 'Charts', :git => 'https://github.com/danielgindi/Charts.git', :branch => '4.0.0'
Screen Shot 2021-02-24 at 3 37 00 PM

@DhavalUmraliya
Copy link

DhavalUmraliya commented May 3, 2022

Hi @liuxuan30, In previous version api I can set gradient color, but can't use it now. I got error when I fetch branch 4.0.0 currently.

Here's how I did, please help me, I implement in production app and can't work after I try pod install now, thanks!

pod 'Charts', :git => 'https://github.com/danielgindi/Charts.git', :branch => '4.0.0' Screen Shot 2021-02-24 at 3 37 00 PM

have you found any solution?

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

No branches or pull requests