ChartsOrg / ChartsOrg/Charts

LineChart - different fill gradient below and above zeroLine

Open
#4,567 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

What I need, is to implement different fill gradient above and below zeroLine.
Fill gradient is set with CGGradient which needs locations and colors:

let gradientColors = [UIColor.graphRed().cgColor,
UIColor.clear.cgColor,
UIColor.blueMain().cgColor]

let locations: [CGFloat] = [0,
y0position,
1]

Basically what I need is value of y0position variable, which is somewhere 0 and 1.
ZeroLine location varies on the data. Sometimes it's lower on chartView, sometimes it's higher.
Gradient is set to LineChartDataSet.fill , but what does that really mean ?
0 is the lowest value of the graph and 1 is the highest ? Or is it the lowest and highest point of whole graphView including all the spacings and paddings ?
My calculated approximation was not precise and I thought, there must be an easier way, right ?

Many thanks for any advice.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.