-
Notifications
You must be signed in to change notification settings - Fork 469
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
feat: custom chart colors support #836
feat: custom chart colors support #836
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Oh wow, what an amazing PR! 🤩 I am a big fan of your implementation details and thank you for the thorough description. My thoughts on Will take a look later today and thank you very much for your work! |
Thanks so much @severinlandolt 🙏 and I agree about |
🎉 This PR is included in version 3.12.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Awesome, thanks so much for the quick help on this one @severinlandolt. Appreciate this project 🙏 |
🎉 This PR is included in version 3.12.0-beta-package-updates.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hey @adamhenson, we were discussing the following: Integrate the What do you think? And would you have the time to create another PR with those changes? |
Hi @severinlandolt - yes, that makes sense to me. I was thinking about that route too as eventually I think I'd want to be able to use custom colors in more than just these charts. My only concern would be around programmatically determining if a I can definitely take a deeper dive and see what I can do. I'm pretty busy this week, but if I don't get to it this week, I can probably spend some time on this next weekend. |
That would be great @adamhenson! Feel free to branch off from |
Hey @severinlandolt - if I can pull this off, I'm assuming I should remove |
@adamhenson Yes, that would be awesome! |
Okay, I believe #843 is what you're after @severinlandolt to "Integrate the customChartColors logic into the color prop". |
🎉 This PR is included in version 3.12.0-beta-customcolors.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Was this ever released? I need the ability to use custom hex colors at run time since they aren't known at generator time. Is there any way to do that? |
Description
As described in #565, chart colors are limited to base colors typed as
Color
.For example, this chart will render line colors as expected.
But, this will not work.
This limitation seems to be due to the complexity in which
className
s are generated under the hood (dynamically at run time and statically at build time via Tailwind themesafelist
). See getColorClassNames.Changes
This change introduces a new optional
customChartColors
prop
on chart components to support custom colors (including hex or custom theme colors) on the following components.AreaChart
BarChart
DonutChart
LineChart
ScatterChart
SparkAreaChart
SparkBarChart
SparkLineChart
Implementation example below.
The caveat here is that such implementation would require an update to the Tailwind theme
safelist
to ensure Tailwind generatesclassName
s at build time to mirrorclassName
s calculated at run time in functions like getColorClassNames. This caveat is somewhat pre-existing, with the reliance onsafelist
. My thought was that we could add a new section to the theming docs if usingcustomChartColors
. Please let me know if I can help here.Example
safelist
to support the above implementation:Related issue(s)
What kind of change does this PR introduce?
Does this PR introduce a breaking change? (check one)
How has This been tested?
Storybook stories have been added for all components with the new
customChartColors
prop
.The PR fulfills these requirements:
main
branch