-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Add domainLimit
to axis config
#15294
Conversation
Deploy preview: https://deploy-preview-15294--material-ui-x.netlify.app/ Updated pages: |
CodSpeed Performance ReportMerging #15294 will not alter performanceComparing Summary
|
It's to simplify user life. for example if you just want to start/end at a multiple of 10 you could do something like
Effectively user could do the same with It replace the |
I assume they both work the same way since the processing of axis config is the same for x and y. We don't talk about it in the docs because the spark line uses band/point scale which are not impacted by the The failing CI is because you need to run What about adding a demo in sparline docs such that other user can know about this new feature https://github.com/mui/mui-x/blob/master/docs/data/charts/sparkline/sparkline.md It could be a subsection of "Y-axis range". To add a demo, create a |
Make sense now, thanks for explanation also I prioritize the domain limit function over min-max hope its okay Also added example in docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good for me @JCQuintas Do you want to have a second look, especially to the docs aspect
domainLimit
to axis config.
@JCQuintas @GuillaumeMeheut I moved the detail explanation into the axis page, and kept a smaller one in the sparkling. After some test, I think having a select to chose between the different option make it simpler to see the differences between the values of |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@alexfauquette should we cherry pick this into v7? |
We could, but If we have conflict, it might not worths resolving them |
Cherry-pick PRs will be created targeting branches: v7.x |
Co-authored-by: alex <[email protected]> Co-authored-by: Jose Quintas <[email protected]>
domainLimit
to axis config.domainLimit
to axis config
@@ -58,3 +58,11 @@ The following demo shows two sparklines, one with small and another with large v | |||
The first row has the default y-axis values, while on the second row a fixed range from `0` to `100` has been set. | |||
|
|||
{{"demo": "CustomYAxis.js"}} | |||
|
|||
You can adjust the y-axis range of a sparkline relatively to its data by using the `domainLimit` option in the `yAxis` configuration. | |||
See the [axis docs page](http://localhost:3001/x/react-charts/axis/#relative-axis-sub-domain) form more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken link and typo
See the [axis docs page](http://localhost:3001/x/react-charts/axis/#relative-axis-sub-domain) form more information. | |
See the [axis docs page](/x/react-charts/axis/#relative-axis-subdomain) for more information. |
* Defines the axis scale domain based on the min/max values of series linked to it. | ||
* - 'nice': Rounds the domain at human friendly values. | ||
* - 'strict': Set the domain to the min/max value provided. No extras space is added. | ||
* - function: eceives the calculated extremums as parameters, and should return the axis domain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* - function: eceives the calculated extremums as parameters, and should return the axis domain. | |
* - function: Receives the calculated extremums as parameters, and should return the axis domain. |
</TextField> | ||
<Typography>y-axis range: {yRange[domainLimitKey]}</Typography> | ||
</Stack> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { Theme } from '@mui/material/styles'; | ||
import { SparkLineChart } from '@mui/x-charts/SparkLineChart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid the blank line in the JavaScript generated demo?
import { Theme } from '@mui/material/styles'; | |
import { SparkLineChart } from '@mui/x-charts/SparkLineChart'; | |
import { SparkLineChart } from '@mui/x-charts/SparkLineChart'; | |
import { Theme } from '@mui/material/styles'; |
@@ -86,6 +86,20 @@ xAxis={[ | |||
|
|||
{{"demo": "MinMaxExample.js"}} | |||
|
|||
### Relative axis sub domain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
### Relative axis sub domain | |
### Relative axis subdomain |
<MenuItem value="strict">strict</MenuItem> | ||
<MenuItem value="function">function</MenuItem> | ||
</TextField> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { SparkLineChart } from '@mui/x-charts/SparkLineChart'; | ||
|
||
const settings = { | ||
valueFormatter: (v: number | null) => `${v}%`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueFormatter: (v: number | null) => `${v}%`, | |
valueFormatter: (value: number | null) => `${value}%`, |
import MenuItem from '@mui/material/MenuItem'; | ||
|
||
const settings = { | ||
valueFormatter: (v: number | null) => `${v}%`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueFormatter: (v: number | null) => `${v}%`, | |
valueFormatter: (value: number | null) => `${value}%`, |
Fix #13316
@alexfauquette Not sure if thats all it take ? Should I add docs?
Is it useful to add it to
axisX
aswell or should only beaxisY
?Also why here #13316 (comment) you wanted to add function since we already have min/max on the axis, supposed to replace it ?
Preview: https://deploy-preview-15294--material-ui-x.netlify.app/x/react-charts/axis/#relative-axis-sub-domain