Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 25, 2025

The createAxisFilterMapper function was not respecting the domainLimit configuration from axis config, causing a desync between what the zoom feature thinks the current domain is versus what the actual domain is.

Problem

The createContinuousScaleGetAxisFilter function was hardcoded to always use .nice() when creating scales for zoom filtering:

[min, max] = getScale(scaleType ?? 'linear', extrema, [0, 100])
  .nice()  // Always applied regardless of domainLimit
  .domain();

This was inconsistent with computeAxisValue, which correctly respects the domainLimit configuration:

const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;

Solution

Updated createContinuousScaleGetAxisFilter to:

  1. Accept a domainLimit parameter
  2. Apply the same domain limit logic as computeAxisValue
  3. Support all domain limit types: 'nice', 'strict', and function-based limits
// Apply domain limit function if provided
let adjustedExtrema = extrema;
if (typeof domainLimit === 'function') {
  const { min: adjustedMin, max: adjustedMax } = domainLimit(extrema[0], extrema[1]);
  adjustedExtrema = [adjustedMin, adjustedMax] as const;
}

const scale = getScale(scaleType ?? 'linear', adjustedExtrema, [0, 100]);
const finalScale = domainLimit === 'nice' ? scale.nice() : scale;

Also updated createAxisFilterMapper to determine and pass the appropriate domain limit using getAxisDomainLimit, ensuring consistency with the axis computation logic.

Example

With data range [1, 99] and zoom 90%-100%:

Before (always nice):

  • Domain becomes [0, 100] (rounded)
  • Zoom range: [90, 100]

After (respects domainLimit):

  • With domainLimit: 'nice': Domain [0, 100], zoom [90, 100]
  • With domainLimit: 'strict': Domain [1, 99], zoom [89.2, 99]
  • With custom function: Domain as transformed, zoom calculated accordingly

This ensures zoom filtering behavior is now consistent with the actual axis domain configuration.

Fixes #17561.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@mui-bot
Copy link

mui-bot commented Aug 25, 2025

Deploy preview: https://deploy-preview-19332--material-ui-x.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 🔺+5B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 🔺+4B(0.00%)
@mui/x-charts 🔺+268B(+0.08%) 🔺+68B(+0.07%)
@mui/x-charts-pro 🔺+268B(+0.07%) 🔺+60B(+0.05%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 🔺+7B(+0.01%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 🔺+3B(+0.01%)

Details of bundle changes

Generated by 🚫 dangerJS against 011bde4

@Copilot Copilot AI changed the title [WIP] [charts] createAxisFilterMapper does not respect domain limit [charts] Fix createAxisFilterMapper to respect domainLimit configuration Aug 25, 2025
@Copilot Copilot AI requested a review from JCQuintas August 25, 2025 15:47
Copilot finished work on behalf of JCQuintas August 25, 2025 15:47
@JCQuintas JCQuintas added type: bug It doesn't behave as expected. scope: charts Changes related to the charts. labels Aug 26, 2025
Copy link

codspeed-hq bot commented Aug 26, 2025

CodSpeed Performance Report

Merging #19332 will not alter performance

Comparing copilot/fix-17561 (011bde4) with master (90d94c7)1

Summary

✅ 10 untouched benchmarks

Footnotes

  1. No successful run was found on master (6211c72) during the generation of this report, so 90d94c7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@JCQuintas JCQuintas marked this pull request as ready for review August 26, 2025 13:22
@JCQuintas
Copy link
Member

@JCQuintas JCQuintas changed the title [charts] Fix createAxisFilterMapper to respect domainLimit configuration [charts] Fix createAxisFilterMapper to respect domainLimit configuration Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: charts Changes related to the charts. type: bug It doesn't behave as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[charts] createAxisFilterMapper does not respect domain limit
3 participants