-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[charts] Support single color area chart #13907
Comments
I would be happy to put together a pull request for any of the possible solutions mentioned above, but would like to first assess if this is something the core team is interested in at all and, if so, align on the path forward. |
For reference, here is a sample implementation of the third solution outlined above. Tests and documentation updates to follow if maintainers approve. |
Hey @milotoor and thanks for raising this.
WDYT @alexfauquette @JCQuintas ? |
You have a last option, already existing which is to use the slotProps to override the styling slotProps={{
area: (ownerState: AreaElementOwnerState) => ({
style: { fill: ownerState.color }
})
}} https://codesandbox.io/s/nervous-glade-9vtq4j?file=/src/Demo.tsx I'm also wondering, why not just remove the line for such a case: slots={{line:() => null}} About future direction, I'm considering removing the usage of d3-color in favor of the CSS |
Thanks for the detailed feedback. I will give a look to the TS issue. |
I'm closing this issue since the TS asspect has been fixed by #13965. THe propper fix with CSS will be for next major. Feel free to reopen if something is missing |
@milotoor: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Works great, thanks @alexfauquette! |
Summary
A line chart with a filled area currently uses a lightened version of the provided color. The given color is used as the
stroke
value for the line itself, while the area underneath it uses a color derived with:This makes the area chart a two-tone chart. This may be aesthetically pleasing but is not always desirable. I would like to be able to build a chart in which the
stroke
andfill
colors are the same, effectively removing the line that divides the area elements. I can imagine several ways to achieve this:LineSeriesType
to support specifying the area color. In my case this would be the same as thecolor
field's value. This solution doesn't make a great deal of sense in general, as I am hard pressed to think of a use case where I'd need/want to specify an arbitrary color for the area regardless of thestroke
color. In practice it makes sense that the two would be (closely) related.LineSeriesType
to support specifying that thefill
color should be the same as thestroke
color. This would address my use case directly.LineSeriesType
to support specifying thefill
color's "brightness" factor, i.e. the value passed to thebrighter
method of the object returned byd3Color(ownerState.color)
. My use case would be solved by setting this parameter to 0. This seems like the best solution, as it is the most flexible without violating the principle that there should be a relationship between thestroke
andfill
colors.Examples
Motivation
I am currently developing off of designs that call for a stacked area chart in which the
stroke
andfill
colors are the same (or, alternatively, in which there is no stroke at all), and this is currently impossible (or at least impractical) to achieve. I can hypothetically do so with thegradientId
value, but this is cumbersome and feels like a feature the library ought to support.Search keywords: area chart color fill
Order ID: 87847
The text was updated successfully, but these errors were encountered: