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

How to creat a custom LimitLine with two labels #4344

Closed
norman93sun opened this issue Apr 20, 2020 · 0 comments
Closed

How to creat a custom LimitLine with two labels #4344

norman93sun opened this issue Apr 20, 2020 · 0 comments

Comments

@norman93sun
Copy link

norman93sun commented Apr 20, 2020

now i want to custom a LimitLine with two labels

class CustomChartLimitLine: ChartLimitLine {
   
    @objc open var extraLabel = ""

    @objc public init(limit: Double, label: String, extraLabel: String) {
        super.init(limit: limit, label: label)
        self.extraLabel = extraLabel
    }
    
}

then creat custom XAxisRenderer

open class CustomXAxisRenderer: XAxisRenderer {
    open override func renderLimitLines(context: CGContext) {
// TODO: custom renderLimitLines
        super.renderLimitLines(context: context)
    }
}

and set chartView

view.xAxisRenderer = CustomXAxisRenderer(viewPortHandler: view.viewPortHandler, xAxis: view.xAxis, transformer: view.getTransformer(forAxis: .left))
let midLimit = CustomChartLimitLine(limit: yesterdayPrice, label: yesterdayPrice.fractionDigitsStr, extraLabel: "")
view.leftAxis.addLimitLine(midLimit)

after this renderLimitLines not called

Did I code it right? or anyone have a better idea

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

1 participant