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

override renderLegend(context: CGContext) #2630

Closed
SeRG1k17 opened this issue Jul 22, 2017 · 1 comment
Closed

override renderLegend(context: CGContext) #2630

SeRG1k17 opened this issue Jul 22, 2017 · 1 comment

Comments

@SeRG1k17
Copy link

SeRG1k17 commented Jul 22, 2017

I created a subclass to draw the entry color:

class ColoredLegendEntry: LegendEntry {

    open var entryColor: NSUIColor?
    
    public init(label: String?,
                entryColor: NSUIColor?,...
//...

Override the renderLegend function:

class ColoredChartLegendRender: LegendRenderer {

    open override func renderLegend(context: CGContext) {
//...
                var entryColor = labelTextColor
                
                if let coloredEntry = e as? ColoredLegendEntry {
                    entryColor = coloredEntry .entryColor ?? labelTextColor
                }
//...

I created a class to use this new renderer:

open class ColoredPieChartView: PieChartView {
//...
}

What am I doing wrong?
2017-07-22 11 52 28

@liuxuan30
Copy link
Member

liuxuan30 commented Jul 28, 2017

I don't have any issue with:

import Foundation

class ColoredChartLegendRender: LegendRenderer {

}

class MyPieChartView: PieChartView {
    internal override func initialize() {
        super.initialize()
        _legendRenderer = ColoredChartLegendRender(viewPortHandler: _viewPortHandler, legend: _legend)
    }
}

Read your error message and maybe restart your xcode or try to rebuild

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

2 participants