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

Patch for colors array, issue #1031 #1034

Merged
merged 2 commits into from Apr 28, 2013
Merged

Conversation

BrendanFDMoore
Copy link
Contributor

(Related to flot issue #1031: #1031)

Currently, if the user declares a custom color palette with less than 5 colors (say, n), $.extend(true, options, opts) only modifies the first n colors of the default palette and leaves the last 5-n in place. When the number of series is >n, colors are used that are not part of user-defined palette, contrary to description of colors array in API.

This line overrides the extended colors array and replaces it with exactly the user-defined colors array, when present. Afterwards, the user color palette is respected by the auto tinting/shading system for when there are more series than colors.

(If I've done this Pull Request thing wrong, I apologize. This is my first time, so let me know what I should have done instead, please.)

Edit: New commit to address dnschnur requests.

(Realted to flot issue flot#1031: flot#1031)

Currently, if the user declares a custom color palette with less than 5 colors (say, n), $.extend(true, options, opts) only modifies the first n colors of the default palette and leaves the last 5-n in place. When the number of series is >n, colors are used that are not part of user-defined palette, contrary to description of colors array in API.

This line overrides the extended colors array and replaces it with exactly the user-defined colors array, when present. Afterwards, the user color palette is respected by the auto tinting/shading system for when there are more series than colors.
@ghost ghost assigned dnschnur Apr 27, 2013
@dnschnur
Copy link
Member

I think you've got exactly the right idea here; just two comments:

  1. Add a comment above your change, explaining its purpose, since the problem is a little subtle.
  2. Use braces even for a single-line statement, like this:
if (...) {
    ...
}

The codebase currently omits braces in many cases, but we're trying to move to a consistent standard, and I'd like all new contributions to follow that. Push those changes and I'll merge this right away. Thanks again for finding this, and for your patch!

Per request from dnschnur (flot#1034 (comment)), I have: 
- Added a comment explaining the purpose of the new check/override
- Changed the structure to match preferred standard structure
@BrendanFDMoore
Copy link
Contributor Author

I've made the changes requested and the commit appears to have been added to this Pull Request automatically.

Let me know if you'd like any other changes. Glad to help!

@dnschnur
Copy link
Member

Thanks!

dnschnur added a commit that referenced this pull request Apr 28, 2013
Patch for colors array, issue #1031
@dnschnur dnschnur merged commit 355b855 into flot:master Apr 28, 2013
CahyaWirawan pushed a commit to CahyaWirawan/flot that referenced this pull request Feb 17, 2023
Per request from dnschnur (flot/flot#1034 (comment)), I have: 
- Added a comment explaining the purpose of the new check/override
- Changed the structure to match preferred standard structure
PermitinYury pushed a commit to PermitinYury/flot that referenced this pull request Feb 17, 2023
Per request from dnschnur (flot/flot#1034 (comment)), I have: 
- Added a comment explaining the purpose of the new check/override
- Changed the structure to match preferred standard structure
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.

None yet

2 participants