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] Customising sparkline highlight point #14168

Closed
Manikandasubramani opened this issue Aug 12, 2024 · 7 comments
Closed

[charts] Customising sparkline highlight point #14168

Manikandasubramani opened this issue Aug 12, 2024 · 7 comments
Labels
component: charts This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@Manikandasubramani
Copy link

Manikandasubramani commented Aug 12, 2024

Steps to reproduce

I have a sparkline chart from MUI for react as follows

import * as React from 'react';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';

export default function BasicSparkLine() {
  return (
    <Stack direction="row" sx={{ width: '100%' }}>
      <Box sx={{ flexGrow: 1 }}>
            <SparkLineChart
              data={[10, 20 , 30, 40, 0, -10, 25]}
              xAxis={{
                scaleType: 'point',
                data: [1, 2, 3, 4, 5, 6, 7, 8],
              }}
              height={100}
              width={600}
              showHighlight
            />
      </Box>
    </Stack>
  );
}

Current behavior

If "showHighlight" is set to true, on hover of the sparkline chart, we can see a highlight coming on the chart on each xaxis point.

Expected behavior

Q1: Is there a way to have those highlighted points always shown ?

Q2: IS there a possibility to show the highlighted points in different colors based on the xaxis value of that exact point

Context

We are trying to have the highlighted datapoint always in the sparkline chart and as well to give a color different of each data point based on the data point value.. for ex., the highlighted data point in green is the y-axis value is >0 or in red if the value is <=0

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: DefaultChartsAxisTooltipContent

@Manikandasubramani Manikandasubramani added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 12, 2024
@github-actions github-actions bot added the component: charts This is the name of the generic UI component, not the React module! label Aug 12, 2024
@alexfauquette alexfauquette changed the title MUI Sparkline: Displaying the ShowHighlight always in the sparkline with different colored Highlight based on the values of the data point [charts] Customising sparkline highlight point Aug 12, 2024
@alexfauquette
Copy link
Member

I'm not sure to fully get your expected behavior

By reusing some hooks provided to create custom components I created an <Indicator /> component that add a circle to your chart

https://codesandbox.io/s/awesome-dust-vpcqkk?file=/src/Demo.tsx

image

Does it solve your issue?

@alexfauquette alexfauquette added status: waiting for author Issue with insufficient information support: question Community support but can be turned into an improvement and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer bug 🐛 Something doesn't work labels Aug 12, 2024
@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Aug 12, 2024
@Manikandasubramani
Copy link
Author

Yes, this is what i need..

Thank you very much

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.

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

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 12, 2024
@Manikandasubramani
Copy link
Author

Hey @alexfauquette , I am getting this error "export 'unstable_useLineSeries' (imported as 'unstable_useLineSeries') was not found in '@mui/x-charts/hooks' (possible exports: getValueToPositionMapper, useDrawingArea, useXScale, useYScale)"., is this because of a version mismatch ? My version is "@mui/x-charts: ^6.19.5"

@alexfauquette
Copy link
Member

Two solutions:

@Manikandasubramani
Copy link
Author

#2 worked out great.. Thank you very much.. :)

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.

@Manikandasubramani: 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! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants