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

[charts] Support color scale #12378

Closed
alexfauquette opened this issue Mar 8, 2024 · 1 comment · Fixed by #12490
Closed

[charts] Support color scale #12378

alexfauquette opened this issue Mar 8, 2024 · 1 comment · Fixed by #12490
Assignees
Labels
component: charts This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@alexfauquette
Copy link
Member

alexfauquette commented Mar 8, 2024

Introduce a way to map values to colors.

Rechart

Use a trick base on gradient color. We used this trick to create https://mui.com/x/react-charts/areas-demo/#areachartfillbyvalue

NB: During this PR, an idea for demo was to display bar chart with monthly temperature going from blue to red

D3 JS

Ordinal scale to map a finit number of value to a finit number of colors. It's just a maaping from and array of values to an array of hexa

const color = d3.scaleOrdinal(d3.schemeBlues[9]);

image

Sequential scales for continuous values. It can map a continuouse range to color interpolation

const color = d3.scaleSequential(d3.interpolateBlues);

image

The best might be to let developers provide the interpolation they want to use, and don't try to reinvent them

Echart

They have a notion of visual Map that map values to visual feature such as symbol, size, or color.

For the Gauge they went with a much simpler solution

{
      type: 'gauge',
      axisLine: {
        lineStyle: {
          width: 30,
          color: [
            [0.3, '#67e0e3'],
            [0.7, '#37a2da'],
            [1, '#fd666d']
          ]
        }
      },

But for Heat chart it's what they use: https://echarts.apache.org/examples/en/editor.html?c=heatmap-large

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 8, 2024
@michelengelen michelengelen added new feature New feature or request component: charts This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 8, 2024
@alexfauquette alexfauquette self-assigned this Mar 28, 2024
Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@alexfauquette: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants