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] How to add area to LineChart in a compostion chart #15062

Closed
jdferreira-biai opened this issue Oct 22, 2024 · 2 comments
Closed

[charts] How to add area to LineChart in a compostion chart #15062

jdferreira-biai opened this issue Oct 22, 2024 · 2 comments
Labels
component: charts This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@jdferreira-biai
Copy link

jdferreira-biai commented Oct 22, 2024

The problem in depth

Greetings MUI-X theme.

Consider this chart using composition, working example here: https://stackblitz.com/edit/q2tf38?file=Demo.js

The chart consist in a line chart, bar chart and scatter plot. Btw, I have to use the numeric representation of dates (using date.getTime()) to make it work with ScatterPlot series type requirements.

I want to connect the LineChart line with the axis and also add a colored area under the line. I tried many things but I cannot make it work.
image

Expected drawn visual result:
image

Please, I gently ask for your assistance. 🙏🏻

Your environment

`npx @mui/envinfo`
  System:
    OS: Linux 5.15 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
  Binaries:
    Node: 21.7.3 - ~/.nvm/versions/node/v21.7.3/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v21.7.3/bin/npm
    pnpm: 9.7.1 - ~/.nvm/versions/node/v21.7.3/bin/pnpm
  Browser:
    Edge v130.0.2849.46 (Official build) (64-bit)
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.3 
    @emotion/styled: ^11.13.0 => 11.13.0 
    @mui/base: 5.0.0-beta.40 => 5.0.0-beta.40 
    @mui/material: ^5.16.7 => 5.16.7 
    @mui/x-charts: ^7.21.0 => 7.21.0 
    @mui/x-data-grid: ^7.21.0 => 7.21.0 
    @mui/x-data-grid-premium: ^7.21.0 => 7.21.0 
    @mui/x-date-pickers-pro: ^7.21.0 => 7.21.0 
    @mui/x-license: ^7.21.0 => 7.21.0 
    @types/react: ^18.3.4 => 18.3.4 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.5.4 => 5.5.4

Search keywords: composition linechart area
Order ID: 88376

@jdferreira-biai jdferreira-biai added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Oct 22, 2024
@github-actions github-actions bot added component: charts This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ labels Oct 22, 2024
@jdferreira-biai jdferreira-biai changed the title [question] How to add area to LineChart in this Compostion chart case and fix bug when hovering y-axis [question] How to add area to LineChart in this Compostion chart case Oct 22, 2024
@jdferreira-biai jdferreira-biai changed the title [question] How to add area to LineChart in this Compostion chart case [question] How to add area to LineChart in this Compostion chart Oct 22, 2024
@alexfauquette
Copy link
Member

Here is the closer I could get: https://stackblitz.com/edit/q2tf38-ulhmra?file=Demo.js,package.json

  • For coloring the background you need to add <AreaPlot /> to render the area of your line series. Maybe you don't even want to display <LinePlot/>
  • For the scatter chart, you could replace it by a line chart with <MarkPlot /> If you keep LinePlot you can hide this line with '.MuiLineElement-series-categoryBId': { display: 'none' }
  • For extending the line before/after, I don't know. For me you're trying to display 2 bar charts on top of each over. For now we don't allow to have a modification of the bar size per series, but you can already play with it https://mui.com/x/react-charts/bars/#bar-size

image

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 23, 2024
@michelengelen michelengelen changed the title [question] How to add area to LineChart in this Compostion chart [charts] How to add area to LineChart in a compostion chart Oct 23, 2024
Copy link

The issue has been inactive for 7 days and has been automatically closed.

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! status: waiting for author Issue with insufficient information support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

3 participants