Skip to content

[charts][question] How to let bar gradient reflect actual value of the bar #19064

@jvskriubakken

Description

@jvskriubakken

The problem in depth

I want to have gradient on by bars in my bar chart. So I found this example here:
https://mui.com/x/react-charts/bars/#css

However, I want the gradient to be more than just for style - I want the gradient to present the value of the bar. Meaning, instead of the gradient to always go from red to gold, it should only go completely to gold if the value is the same as the max value. The gradient should reflect the value of the bar.

Do you think this is possible with the current functionality of BarChart? If so could you provide and example or guide me in the right direction?

Your environment

`npx @mui/envinfo` System: OS: macOS 15.5 Binaries: Node: 22.17.0 - /usr/local/bin/node npm: 10.9.2 - /usr/local/bin/npm pnpm: 10.14.0 - /usr/local/bin/pnpm Browsers: Chrome: 138.0.7204.184 Edge: Not Found Safari: 18.5 npmPackages: @emotion/react: 11.11.1 => 11.11.1 @emotion/styled: 11.11.0 => 11.11.0 @mui/icons-material: 7.2.0 => 7.2.0 @mui/lab: 7.0.0-beta.14 => 7.0.0-beta.14 @mui/material: 7.2.0 => 7.2.0 @mui/types: 7.4.4 => 7.4.4 @mui/utils: 7.2.0 => 7.2.0 @mui/x-charts: 8.9.2 => 8.9.2 @mui/x-charts-pro: 8.9.2 => 8.9.2 @mui/x-data-grid-premium: 8.9.2 => 8.9.2 @mui/x-date-pickers-pro: 8.9.2 => 8.9.2 @mui/x-license: 8.9.2 => 8.9.2 @mui/x-tree-view: 8.9.2 => 8.9.2 @types/react: 18.3.21 => 18.3.21 react: 18.3.1 => 18.3.1 react-dom: 18.3.1 => 18.3.1 typescript: 5.8.3 => 5.8.3

Search keywords: Charts

Order ID: 101811

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to the documentation.scope: chartsChanges related to the charts.support: commercialSupport request from paid users.support: premium standardSupport request from a Premium standard plan user. https://mui.com/legal/technical-support-sla.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions