The Wayback Machine - http://web.archive.org/web/20200705235020/https://github.com/PhilJay/MPAndroidChart/issues/4571
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

Scatter Chart displays WRONG COLOR for each point #4571

Open
ceciliaLI1003 opened this issue Jun 12, 2019 · 1 comment · May be fixed by #4638
Open

Scatter Chart displays WRONG COLOR for each point #4571

ceciliaLI1003 opened this issue Jun 12, 2019 · 1 comment · May be fixed by #4638

Comments

@ceciliaLI1003
Copy link

@ceciliaLI1003 ceciliaLI1003 commented Jun 12, 2019

Refer to the code below, the colors of points shown on the scatter chart is not equal to the color list, ColorTemplate.MATERIAL_COLORS.

MyScatterDataSet  set1 = new MyScatterDataSet(yVals1, "DS 1");
 set1.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
set1.setColors(ColorTemplate.MATERIAL_COLORS);

WeChatWorkScreenshot_6a1486ac-2d86-4703-9d07-e51fdf075c90

For Example,
while ColorTemplate.MATERIAL_COLORS = [a, b, c, d]
the chart displayed points with colors, [a, a, b, b]

To workaround that, I have override your ScatterDataSet class as shown below.
Then, the colors is displayed as I expected, [a, b, c, d]

public class MyScatterDataSet extends ScatterDataSet {
    static int currentIndex = 0;

    public MyScatterDataSet(List<Entry> yVals, String label) {
        super(yVals, label);
    }

    @Override
    public int getColor(int index) {
        int ret =super.getColor(currentIndex);
                currentIndex+=1;
        return ret;
    }
}

I hope you can fix this bug. Thank you!

@ceciliaLI1003
Copy link
Author

@ceciliaLI1003 ceciliaLI1003 commented Jun 12, 2019

I ve found out that its
Duplicate of #4483

However, it has not been fixed.
It's not appearing on the IOS version. So, I will regard it as a bug

SpencerHowell added a commit to SpencerHowell/MPAndroidChart that referenced this issue Aug 7, 2019
Closes PhilJay#4571 and closes PhilJay#4483

When setting colors for each entry of a dataSet, this code was skipping every odd color value. This resulted in only half of the colors being applied, with the other half of points getting duplicate values. When trying to set custom colors for each point, this presented an issue.

@SpencerHowell SpencerHowell linked a pull request that will close this issue Aug 7, 2019

3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.