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

Create cScale for color? #138

Closed
mhkeller opened this issue Jun 28, 2023 · 5 comments
Closed

Create cScale for color? #138

mhkeller opened this issue Jun 28, 2023 · 5 comments
Labels
discussion Talk about implementation of different chart types.

Comments

@mhkeller
Copy link
Owner

@techniq:

What do you think if we add a cScale or colorScale to LayerCake? I know any of the scales (x,y,z,r) can be used for color, but I think it could be helpful for reusable components to have a common scale used for color. I currently use the r scale in LayerChart (coloR) but there are cases where r overlaps with radius scales, for example. z can also overlap with faceted charts, or another dimension (stack/group/etc). I haven't looked deeply, but I know Plot has an explicit color scale (just called color).

That's an interesting idea. I use the zScale for color in the examples. How would you use it for faceting from within Layer Cake?

@mhkeller mhkeller added the discussion Talk about implementation of different chart types. label Jun 28, 2023
@techniq
Copy link
Contributor

techniq commented Jun 28, 2023

To be honest, I don't currently, but I've considered exploring, although the more I think about it, it's probably best to create new LayerCake instances as they would need individual scales/etc. I know that's how the Small multiples example works (with an opt-in shared scale).

I was going to investigate more how Plot does facets / small multiples (they use fx and fy scales). This is way down my priority list, I mostly mention that the z scale might be used for a third dimension (for example a multi-series line/area chart might use this approach, although I also just render separate explicit instances here).

@mhkeller
Copy link
Owner Author

Got it. Let me know if there's an example that you think would make good use of that fifth scale. In retrospect, probably calling zScale cScale may have made more sense! Do you mind if I close this one for now? I have an ambitious plan to get to "Issue Tracker Zero" and I think I'm close. If you want to lend a hand on any of these that would be much appreciated! Your examples with LayerChart are helpful too!

@techniq
Copy link
Contributor

techniq commented Jun 28, 2023

Sure thing. I might switch to using zScale within LayerChart if we end up not adding a cScale, although I still hope to use zScale for multi-series visualizations once I have more time to think how they should work (or won't :) ). I think the data / flatData would need to better support a structure for this third dimension though (nested array's for each each series, or a key/value object/map, etc).

Thanks for chatting it through, and if you think it's worth pursuing, I could create a PR. for the cScale (should be pretty straight forward).

@techniq
Copy link
Contributor

techniq commented Jun 28, 2023

Btw I was going to close this issue, but I don't have the permissions :)

@mhkeller
Copy link
Owner Author

In case you need another scale, you can create one yourself and pass it through the custom prop. I know you won't get automatic domain calculation but at least it gets you part of the way there in that you have a context value accessible from your chart components.

I will probably hold off on adding a cScale for now. I want to square these existing issues and it may add overhead to the final compiled library. It may be too many options for people to learn. Sometimes constraints make things easier.

But if you come across something where that fifth scale is really necessary, drop a comment and we'll check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Talk about implementation of different chart types.
Projects
None yet
Development

No branches or pull requests

2 participants