Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
baseline
property to theLineChart
series
#14153[charts] Add
baseline
property to theLineChart
series
#14153Changes from 2 commits
897e24a
7c9e96a
f0c4fe7
b2063dc
9c99b81
ec44a0a
0ade537
f09013e
a60dd3d
8d6aaa9
dbbd4b3
ec44e0a
9942358
bb563f4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This only impacts the plotting. Here is an example with values fluctuating between 200-300, and with baseline set to 1000.
Notice that:
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.
Potential solution
When computing the extremum values, you replace when needed the base (
d[0]
) by the user defined baselineInstead of providing a number, user can provide
'top' | 'bottom'
. Then you just need to ignore thed[0]
by doingand in the commented line return
mui-x/packages/x-charts/src/LineChart/extremums.ts
Lines 43 to 44 in 38184fe
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 behaves a bit weirdly when
baseline
changes the extremums.This happens because the extremum getter value is then passed into the
nice()
function, it can have unintended consequences, which means I would also have to check the baseline where that is calculated.But we already have the axis
min/max
values for that. So I believe we should use the min/max values when the axis extremums need to be changed.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.
TLTR: I don't think it's an issue
Technically speaking, we have two behavior to define:
Should the baseline impact the extremums
For stacked data, I can not think of a usecase where the answer would be no. Otherwise you would compare some area wherase the base one would have missing part.
For a single series, where the area is more aesthetic, seems it can be ignored. Here foe example the NASDAQ evolution during the day. Nobody care of the space between 0 and 16.500. Only the relative evolution matter. Otherwise you would see nothing.
Where does the area set the baseline
I only see two reasons to modify the default 0:
So basically the weird case you define should not exist
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.
Ah, but those are just working as expected. The issue that appears when we have the
baseline
affect the extremums is that the extremums will getniced
after. So if we have a non-round number like below, it will not work properly. Then this starts to get more complex and would clash with a feature that already existsyAxis.min/max