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

Adding color information to targets #263

Closed
wants to merge 2 commits into from

Conversation

dominicbarnes
Copy link
Contributor

I was needing to write a custom legend for my charts, and the only piece of information I was missing was color. Thus, I've added it as a part of the target object.

@masayuki0812
Copy link
Member

Hi, Thank you for the PR, but I think there would be better way to get the color by id. How about color API that we can get the color by id? I think this is better because the color could change according to the situation (color can be change by data and updated by some API), and I think it's more flexible as a interface to colors. API would be like c3.color(id, data) and return the hex;

What do you think about this idea? If this is acceptable, I'll add this feature in the next version.

@dominicbarnes
Copy link
Contributor Author

I don't think a c3.color method makes much sense, as you said there are lots of internal factors to consider. I'd be willing to change this and expose the color function directly, and then it will still reflect the internal state of the chart. (maybe chart.getTargetColor(targetId)?)

@masayuki0812
Copy link
Member

Sorry, I meant chart.getTargetColor as you wrote. This method will be exposed like other APIs. By this API, you can get the color by id through the chart object generated by c3.generate().

@dominicbarnes
Copy link
Contributor Author

I've made the change you suggested, let me know if there's anything else I can do.

@masayuki0812
Copy link
Member

Thank you!
Could you change the name getTargetColor to color? This method can accept not only id but also an object that includes id, value and etc, so I think color would be more appropriate.

masayuki0812 added a commit that referenced this pull request May 29, 2014
@masayuki0812
Copy link
Member

I added this feature as color, so I'll close this PR. Thank you for your help.

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

Successfully merging this pull request may close these issues.

2 participants