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

added color for each legendEntry(if not set, using default legend color) #2640

Closed
wants to merge 1 commit into from
Closed

Conversation

SeRG1k17
Copy link

@SeRG1k17 SeRG1k17 commented Jul 25, 2017

Simple way add color for each legendEntry.
Usage:

    NSMutableArray *legendEntries = [[NSMutableArray alloc] init];
    
    for (int i = 0; i < count; i++)
    {
        UIColor *entryColor = colors[i];
        ChartLegendEntry *entry = [[ChartLegendEntry alloc] initWithLabel:parties[i % parties.count]
                                                               labelColor:entryColor // <-- New property
                                                                     form:ChartLegendFormCircle
                                                                 formSize:8
                                                            formLineWidth:0
                                                        formLineDashPhase:0
                                                      formLineDashLengths:0
                                                                formColor:entryColor];
        
        [legendEntries addObject:entry];
    }
    
    [_chartView.legend setCustomWithEntries: legendEntries];

@codecov-io
Copy link

codecov-io commented Jul 25, 2017

Codecov Report

Merging #2640 into master will increase coverage by <.01%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2640      +/-   ##
==========================================
+ Coverage   19.65%   19.65%   +<.01%     
==========================================
  Files         112      112              
  Lines       13717    13721       +4     
==========================================
+ Hits         2696     2697       +1     
- Misses      11021    11024       +3
Impacted Files Coverage Δ
Source/Charts/Components/LegendEntry.swift 81.81% <100%> (+1.81%) ⬆️
Source/Charts/Renderers/LegendRenderer.swift 42.19% <25%> (-0.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6698fd3...0c516b4. Read the comment docs.

@jjatie jjatie added the feature label Jan 6, 2018
@jjatie jjatie requested a review from danielgindi January 6, 2018 15:28
@jjatie jjatie changed the base branch from master to 4.0.0 January 12, 2018 00:58
@jjatie jjatie added this to the 4.0.0 milestone Jan 12, 2018
@@ -205,7 +205,7 @@ open class LegendRenderer: Renderer
}

let labelFont = legend.font
let labelTextColor = legend.textColor
var labelTextColor = legend.textColor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be let legendTextColor...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjatie It's been a long time. I have to double-check it

@@ -431,6 +431,10 @@ open class LegendRenderer: Renderer

var posX = originPosX

if let labelColor = e.labelColor {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be let labelTextColor = e.labelColor ?? legendTextColor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjatie It's been a long time. I have to double-check it

@pmairoldi
Copy link
Collaborator

closed in favour of #3558

@pmairoldi pmairoldi closed this Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants