-
-
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] Allow basic customization of Sparkline y-axis #13316
Comments
Surprising that you don't have access to the y-axis config. That's definitely something we could fix. The reason why the chart does not fill the entire space is the use of We coudl propagate the |
+1 The min and max values for y-axis would definetely be an important feature! For example, if plotting percentage data (0...100%) now with dataset containing only small values (say between 0...20%), the plot scales between that range and user could get an idea of high values. By setting y-axis to always be 0...100%, it would make more sense. |
The next release will allow you to specify the min/max of y-axis. We are still thinking about what could be a good DX to take control of this |
@JCQuintas what do you think about this property? /**
* Defines the axis scale domain based on the min/max values of series linked to it.
* - 'nice': Uses the `.nice()` method from d3-scale to round the domain at human friendly values.
* - 'strict': Set the domain to the min/max value displayed. No extras space is added.
* - function: takes as an argument an array with the min/max displayed values, and return the domain.
*/
domainDefinition?: 'nice' | 'strict' | ([Value, Value]) => [Value, Value] |
Seems promising. Not sure about the naming, maybe |
Will go with |
If someone wants to pick this issue, here are the file of interest mui-x/packages/x-charts/src/internals/computeAxisValue.ts Lines 207 to 210 in 9fd4c04
|
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @marvinruder 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. |
Summary
Right now the scaling mechanism of the y-axis in sparkline charts is somewhat obscure to me, and there are no parameters that influence that scale. It would be great to at least have a way to set the min and max values on the y-axis.
Examples
The following two sparklines have the same parameters except for color and dataset:
(The numbers below the slider on the left show the min and max values in the datasets)
Both
svg
s have a height of 42px. The upper one’s line is 32px high, the lower one’s line is 14px high. Why? How are the min and max values of the y axis calculated?Motivation
I want my sparklines to fill the entire area made available to the
svg
element, i.e., the min and max values of the dataset should match the min and max values of the y-axis. A property for configuring those axis values would allow such customization.Search keywords: sparkline
The text was updated successfully, but these errors were encountered: