Skip to content

docs(charts): Adds developer notes to about-charts page#4488

Merged
nicolethoen merged 2 commits intopatternfly:mainfrom
edonehoo:iss2974
Apr 15, 2025
Merged

docs(charts): Adds developer notes to about-charts page#4488
nicolethoen merged 2 commits intopatternfly:mainfrom
edonehoo:iss2974

Conversation

@edonehoo
Copy link
Collaborator

Closes #2974

As a follow up to this PR, I'll need to remove redundant info that I copied from the dark theme handbook.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Feb 27, 2025

@edonehoo
Copy link
Collaborator Author

edonehoo commented Mar 4, 2025

@mcoker can you review when you have time?

I'm curious if it's clear enough, especially since I mention both the React tokens and the standard design tokens. Do you think we need to expand more on if/when to use the chart design tokens instead of or in addition to the React tokens? And if so, that's an area I think I could use clarification too 😊

@edonehoo edonehoo requested a review from mcoker March 4, 2025 14:50

## Develop with charts

Default styles in the [@patternfly/react-charts package](https://www.npmjs.com/package/@patternfly/react-charts) are aligned with our light theme. To use chart styles, you must also have the [@patternfly/patternfly package](https://www.npmjs.com/package/@patternfly/patternfly) installed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about what it means to "use chart styles". Can you elaborate on that a bit? Just so it's clear (it probably is, just want to make sure) - @patternfly/react-charts in light theme works just fine without @patternfly/patternfly or any CSS from @patternfly/patternfly. The styles are all basically hard-coded into the chart SVG's.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nope, I was misunderstanding/assuming that you had to install @patternfly/patternfly in either case! This is ringing a bell for me now, ty


Default styles in the [@patternfly/react-charts package](https://www.npmjs.com/package/@patternfly/react-charts) are aligned with our light theme. To use chart styles, you must also have the [@patternfly/patternfly package](https://www.npmjs.com/package/@patternfly/patternfly) installed.

To utilize default chart styles, you don't need to import anything else. But, to support dark-themed charts, you must also import the stylesheet that contains dark theme styles. To do so, add this line before importing your main application component:
Copy link
Contributor

@mcoker mcoker Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also confused about "utilize default chart styles" - not sure what "utilize" means exactly. Same with "to support dark-themed charts" - not sure what "support" means. If I simplifed it, I'd say charts works with light theme out of the box, no additional styles or anything are needed. However, for charts to work in dark theme, you'll need to import 1) patternfly CSS (so they have our global tokens) and 2) @patternfly/patternfly/patternfly-charts.css

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, when you say "global tokens", do you mean design tokens? Or this file? Which, this file is ultimately our design tokens..right?

I should find time to create a cheat sheet for some of these terms React tokens, design tokens, variables, styles, etc. I get so mixed up 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your simplified suggestion makes sense outside of me making sure I understand the verbiage, though! Gonna make updates based off this


`import '@patternfly/patternfly/patternfly-charts.css';`

Once you import this file, you'll have access to [all chart variables](https://www.npmjs.com/package/@patternfly/patternfly?activeTab=code). Beyond dark theme, you could use these variables to match the style of other UI elements to your chart styles.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it isn't really intuitive that "all chart variables" links to @patternfly/patternfly on NPM. I would probably be confused clicking on that, expecting it to take me to a list of chart variables or something like that. I might pair this sentence with the one below about filtering the all tokens table, but it's worth noting that chart variables and chart tokens aren't exactly the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay this is great feedback! I was thinking that the patternfly-charts.css file over on NPM was the chart variables, but I'm definitely treading water with variables, tokens, and friends lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my remaining question is, where is a list of our chart variables?

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @edonehoo! Sorry for the delay. I left some comments, but I'm not sure if they're helpful 😅 If not, I'm happy to meet up and we can probably chat through it pretty quickly.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a question, but I'm also good with this as it is! I know this PR has been open a while so I don't want to hold it up any more than I already have 😅

Default styles in the [@patternfly/react-charts package](https://www.npmjs.com/package/@patternfly/react-charts) are aligned with our light theme. Charts work with PatternFly's light theme by default—you don't need to import anything else.

To support dark-themed charts, you must:
1. Import the [@patternfly/patternfly package](https://www.npmjs.com/package/@patternfly/patternfly), so that you can use our global tokens.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we wanting to provide documentation for an app that is not using PatternFly? Or are we assuming the charts will be included in a PatternFly app? If they aren't using PatternFly already, they'll need to import some other things.

@nicolethoen nicolethoen merged commit 9f4bd2f into patternfly:main Apr 15, 2025
4 checks passed
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.

Chart styles documentation

4 participants