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

Customize scatter chart color for each data in dataSets #1443

Closed
anishparajuli555 opened this issue Sep 15, 2016 · 5 comments
Closed

Customize scatter chart color for each data in dataSets #1443

anishparajuli555 opened this issue Sep 15, 2016 · 5 comments

Comments

@anishparajuli555
Copy link

I want to set different color for each data in dataSet set1. Setting the color of dataSet as [set1 setColor:ChartColorTemplates.colorful[0]];, sets every color to same.Is there a way to set each dataSet color to different and may be shapes too?

- (void)setDataCount:(int)count range:(double)range
{
    NSMutableArray *yVals1 = [[NSMutableArray alloc] init];

    for (int i = 0; i < count; i++)
    {
        double val = (double) (arc4random_uniform(range)) + 3;
        [yVals1 addObject:[[ChartDataEntry alloc] initWithX:(double)i y:val]];

    }

    ScatterChartDataSet *set1 = [[ScatterChartDataSet alloc] initWithValues:yVals1 label:@"DS 1"];
    [set1 setScatterShape:ScatterShapeSquare];
    [set1 setColor:ChartColorTemplates.colorful[0]];
    set1.scatterShapeSize = 8.0;
    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    [dataSets addObject:set1];

    ScatterChartData *data = [[ScatterChartData alloc] initWithDataSets:dataSets];
    [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:7.f]];

    _chartView.data = data;
}
@liuxuan30
Copy link
Member

liuxuan30 commented Sep 18, 2016

dataSet.colors can do the job I think.
you can take a look at renderShape():

renderer.renderShape(context: context, dataSet: dataSet, viewPortHandler: viewPortHandler, point: point, color: dataSet.color(atIndex: j))

@anishparajuli555
Copy link
Author

@liuxuan30 I dont think i can set holeColors this way?

@liuxuan30
Copy link
Member

hole colors? I don't see it. Anyway.. code is there, so if existing properties can't solve you problem, time to override :)

@anishparajuli555
Copy link
Author

@liuxuan30 Yes scatterShapeHoleColor ...ahh....I have to override for every problems i face..

@liuxuan30
Copy link
Member

basically, there are too many requirements to satisfy with just a few people. If you find something useful, you are more than welcome to file a PR following the code style :)

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