Skip to content

Conversation

JCQuintas
Copy link
Member

@JCQuintas JCQuintas commented Jun 27, 2025

Fixes #18559

  • Add funnelDirection to control pyramid direction

Thoughts

  • Not sure if we should use increasing/decreasing or ascending/descending
  • We could go for direction too instead of dataDirection
  • I didn't document it as it can be done in the pyramid PR, since it works for pyramid only.

@JCQuintas JCQuintas requested a review from prakhargupta1 June 27, 2025 11:34
@JCQuintas JCQuintas self-assigned this Jun 27, 2025
@JCQuintas JCQuintas added type: new feature Expand the scope of the product to solve a new problem. plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. labels Jun 27, 2025
@mui-bot
Copy link

mui-bot commented Jun 27, 2025

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

Bundle size report

Total Size Change: ▼-640KB(-4.81%) - Total Gzip Change: ▼-136KB(-3.36%)
Files: 122 total (0 added, 0 removed, 87 changed)

Show details for 100 more bundles (22 more not shown)

@mui/x-charts-pro/RadarChartProparsed: ▼-32.2KB(-15.81%) gzip: ▼-6.76KB(-10.76%)
@mui/x-charts/RadarChartparsed: ▼-32.2KB(-16.94%) gzip: ▼-6.75KB(-11.52%)
@mui/x-charts/SparkLineChartparsed: ▼-32.2KB(-15.39%) gzip: ▼-6.73KB(-10.48%)
@mui/x-charts/BarChartparsed: ▼-32.2KB(-15.44%) gzip: ▼-6.75KB(-10.47%)
@mui/x-charts/LineChartparsed: ▼-32.2KB(-14.34%) gzip: ▼-6.83KB(-9.90%)
@mui/x-charts/PieChartparsed: ▼-32.2KB(-16.45%) gzip: ▼-6.72KB(-11.14%)
@mui/x-chartsparsed: ▼-32.1KB(-10.62%) gzip: ▼-6.8KB(-7.51%)
@mui/x-charts/ChartContainerparsed: ▼-32KB(-21.85%) gzip: ▼-6.66KB(-14.76%)
@mui/x-charts/ChartDataProviderparsed: ▼-31.9KB(-22.91%) gzip: ▼-6.56KB(-15.24%)
@mui/x-charts/ScatterChartparsed: ▼-31.9KB(-16.44%) gzip: ▼-6.87KB(-11.50%)
@mui/x-charts-proparsed: ▼-31.6KB(-8.37%) gzip: ▼-6.7KB(-5.90%)
@mui/x-charts/Gaugeparsed: ▼-31.6KB(-22.51%) gzip: ▼-6.86KB(-15.61%)
@mui/x-charts-pro/LineChartProparsed: ▼-31.6KB(-11.74%) gzip: ▼-6.58KB(-7.86%)
@mui/x-charts-pro/BarChartProparsed: ▼-31.6KB(-12.47%) gzip: ▼-6.57KB(-8.28%)
@mui/x-charts-pro/ScatterChartProparsed: ▼-31.4KB(-13.17%) gzip: ▼-6.6KB(-8.82%)
@mui/x-charts-pro/FunnelChartparsed: ▼-31.1KB(-12.78%) gzip: ▼-6.37KB(-8.50%)
@mui/x-charts-pro/Heatmapparsed: ▼-31.1KB(-13.61%) gzip: ▼-6.43KB(-8.96%)
@mui/x-charts-pro/PieChartProparsed: ▼-31.1KB(-13.46%) gzip: ▼-6.5KB(-8.97%)
@mui/x-charts-pro/ChartContainerProparsed: ▼-31.1KB(-17.59%) gzip: ▼-6.34KB(-11.44%)
@mui/x-charts-pro/ChartDataProviderProparsed: ▼-31KB(-18.35%) gzip: ▼-6.38KB(-12.05%)
@mui/x-date-pickers-proparsed: ▼-743B(-0.23%) gzip: ▼-122B(-0.15%)
@mui/x-charts-pro/ChartZoomSliderparsed: ▼-538B(-0.78%) gzip: ▼-164B(-0.68%)
@mui/x-date-pickers-pro/DateTimeRangePickerparsed: ▼-365B(-0.18%) gzip: ▼-119B(-0.19%)
@mui/x-date-pickers-pro/DesktopDateTimeRangePickerparsed: ▼-330B(-0.16%) gzip: ▼-106B(-0.18%)
@mui/x-date-pickers-pro/TimeRangePickerparsed: ▼-286B(-0.20%) gzip: ▼-76B(-0.17%)
@mui/x-date-pickers-pro/MobileDateTimeRangePickerparsed: ▼-258B(-0.13%) gzip: ▼-116B(-0.20%)
@mui/x-date-pickers-pro/DesktopTimeRangePickerparsed: ▼-251B(-0.18%) gzip: ▼-83B(-0.19%)
@mui/x-date-pickers-pro/MobileTimeRangePickerparsed: ▼-251B(-0.18%) gzip: ▼-83B(-0.20%)
@mui/x-date-pickers-pro/DateRangePickerparsed: ▼-222B(-0.13%) gzip: ▼-82B(-0.16%)
@mui/x-date-pickers-pro/DesktopDateRangePickerparsed: ▼-187B(-0.11%) gzip: ▼-77B(-0.15%)
@mui/x-date-pickers-pro/MobileDateRangePickerparsed: ▼-187B(-0.11%) gzip: ▼-81B(-0.16%)
@mui/x-date-pickers-pro/StaticDateRangePickerparsed: ▼-187B(-0.19%) gzip: ▼-68B(-0.22%)
@mui/x-charts/ChartsTooltipparsed: ▼-163B(-0.21%) gzip: ▼-142B(-0.54%)
@mui/x-date-pickers-pro/DateRangeCalendarparsed: ▼-152B(-0.20%) gzip: ▼-78B(-0.33%)
@mui/x-data-gridparsed: ▼-143B(-0.04%) gzip: ▼-137B(-0.12%)
@mui/x-data-grid/DataGridparsed: ▼-143B(-0.04%) gzip: ▼-157B(-0.15%)
@mui/x-data-grid-proparsed: ▼-142B(-0.03%) gzip: ▼-138B(-0.10%)
@mui/x-data-grid-premiumparsed: ▼-140B(-0.02%) gzip: ▼-134B(-0.08%)
@mui/x-data-grid-premium/DataGridPremiumparsed: ▼-140B(-0.03%) gzip: ▼-108B(-0.07%)
@mui/x-data-grid-pro/DataGridProparsed: ▼-140B(-0.03%) gzip: ▼-163B(-0.13%)
@mui/x-date-pickers-pro/MultiInputDateRangeFieldparsed: ▼-109B(-0.13%) gzip: ▼-27B(-0.10%)
@mui/x-date-pickers-pro/MultiInputDateTimeRangeFieldparsed: ▼-109B(-0.13%) gzip: ▼-47B(-0.18%)
@mui/x-date-pickers-pro/MultiInputTimeRangeFieldparsed: ▼-109B(-0.13%) gzip: ▼-28B(-0.11%)
@mui/x-date-pickers-pro/SingleInputDateRangeFieldparsed: ▼-74B(-0.09%) gzip: ▼-25B(-0.10%)
@mui/x-date-pickers-pro/SingleInputDateTimeRangeFieldparsed: ▼-74B(-0.09%) gzip: ▼-27B(-0.11%)
@mui/x-date-pickers-pro/SingleInputTimeRangeFieldparsed: ▼-74B(-0.09%) gzip: ▼-24B(-0.10%)
@mui/x-date-pickersparsed: ▼-25B(-0.01%) gzip: ▼-10B(-0.02%)
@mui/x-date-pickers/DateTimePickerparsed: ▼-25B(-0.01%) gzip: ▼-5B(-0.01%)
@mui/x-date-pickers/DesktopDateTimePickerparsed: ▼-25B(-0.01%) gzip: ▼-9B(-0.02%)
@mui/x-date-pickers/DesktopTimePickerparsed: ▼-25B(-0.02%) gzip: ▼-5B(-0.01%)
@mui/x-date-pickers/DigitalClockparsed: ▼-25B(-0.16%) gzip: ▼-11B(-0.18%)
@mui/x-date-pickers/MobileDateTimePickerparsed: ▼-25B(-0.01%) gzip: ▼-5B(-0.01%)
@mui/x-date-pickers/MobileTimePickerparsed: ▼-25B(-0.02%) gzip: ▼-4B(-0.01%)
@mui/x-date-pickers/MultiSectionDigitalClockparsed: ▼-25B(-0.13%) gzip: ▼-13B(-0.18%)
@mui/x-date-pickers/StaticDateTimePickerparsed: ▼-25B(-0.02%) gzip: ▼-11B(-0.03%)
@mui/x-date-pickers/StaticTimePickerparsed: ▼-25B(-0.04%) gzip: ▼-6B(-0.03%)
@mui/x-date-pickers/TimeClockparsed: ▼-25B(-0.08%) gzip: ▼-11B(-0.10%)
@mui/x-date-pickers/TimePickerparsed: ▼-25B(-0.02%) gzip: ▼-5B(-0.01%)
@mui/x-date-pickers/DateCalendarparsed: ▼-22B(-0.03%) gzip: ▼-14B(-0.07%)
@mui/x-date-pickers/DateFieldparsed: ▼-22B(-0.03%) gzip: ▼-8B(-0.03%)
@mui/x-date-pickers/DatePickerparsed: ▼-22B(-0.01%) gzip: ▼-7B(-0.02%)
@mui/x-date-pickers/DateTimeFieldparsed: ▼-22B(-0.03%) gzip: ▼-6B(-0.03%)
@mui/x-date-pickers/DesktopDatePickerparsed: ▼-22B(-0.01%) gzip: ▼-9B(-0.02%)
@mui/x-date-pickers/MobileDatePickerparsed: ▼-22B(-0.01%) gzip: ▼-9B(-0.02%)
@mui/x-date-pickers/MonthCalendarparsed: ▼-22B(-0.15%) gzip: ▼-10B(-0.18%)
@mui/x-date-pickers/StaticDatePickerparsed: ▼-22B(-0.03%) gzip: ▼-13B(-0.05%)
@mui/x-date-pickers/TimeFieldparsed: ▼-22B(-0.03%) gzip: ▼-10B(-0.04%)
@mui/x-date-pickers/YearCalendarparsed: ▼-22B(-0.14%) gzip: ▼-9B(-0.15%)
@mui/x-charts/ChartsSurfaceparsed: ▼-19B(-0.03%) gzip: ▼-20B(-0.09%)
@mui/x-charts-pro/ChartsToolbarProparsed: 0B(0.00%) gzip: ▼-9B(-0.04%)
@mui/x-charts/ChartsAxisparsed: 0B(0.00%) gzip: ▼-7B(-0.03%)
@mui/x-charts/ChartsAxisHighlightparsed: 0B(0.00%) gzip: ▼-8B(-0.04%)
@mui/x-charts/ChartsClipPathparsed: 0B(0.00%) gzip: ▼-8B(-0.24%)
@mui/x-charts/ChartsGridparsed: 0B(0.00%) gzip: ▼-9B(-0.04%)
@mui/x-charts/ChartsLabelparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsLegendparsed: 0B(0.00%) gzip: ▼-10B(-0.04%)
@mui/x-charts/ChartsLocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsOverlayparsed: 0B(0.00%) gzip: ▼-9B(-0.24%)
@mui/x-charts/ChartsReferenceLineparsed: 0B(0.00%) gzip: ▼-9B(-0.04%)
@mui/x-charts/ChartsTextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-charts/ChartsXAxisparsed: 0B(0.00%) gzip: ▼-6B(-0.02%)
@mui/x-charts/ChartsYAxisparsed: 0B(0.00%) gzip: ▼-7B(-0.03%)
@mui/x-charts/Toolbarparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterDateFnsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterDateFnsJalaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterDayjsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterLuxonparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterMomentparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterMomentHijriparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/AdapterMomentJalaaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/DateRangePickerDayparsed: 0B(0.00%) gzip: ▼-1B(-0.01%)
@mui/x-date-pickers-pro/DateRangePickerDay2parsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/LocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers-pro/PickersRangeCalendarHeaderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDateFnsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDateFnsBaseparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDateFnsJalaliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterDayjsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterLuxonparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/x-date-pickers/AdapterMomentparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against a4cc934

Copy link

codspeed-hq bot commented Jun 27, 2025

CodSpeed Performance Report

Merging #18568 will not alter performance

Comparing JCQuintas:fix-funnel-data-directionality (a4cc934) with master (7875af8)

Summary

✅ 9 untouched benchmarks

@bernardobelchior
Copy link
Member

The reason we need this is because we're trying to detect the data direction, right? If we don't detect it, then it would just be a matter of calling data={data.reverse()} in case the user wants to change the direction, correct?

@JCQuintas
Copy link
Member Author

The reason we need this is because we're trying to detect the data direction, right? If we don't detect it, then it would just be a matter of calling data={data.reverse()} in case the user wants to change the direction, correct?

This is to force a direction. Right now if the user uses data={[10, 20, 30]} or data={[30, 20, 10]} we automatically, correctly detect it.

@prakhargupta1
Copy link
Member

dataDirection and increasing/decreasing sounds good to me.

@alexfauquette
Copy link
Member

Not sure if we should use increasing/decreasing or ascending/descending

No opinion on this one

We could go for direction too instead of dataDirection

What about pyramidDirection? To make it clear this only impact the pyramide, and avoid the dataXxxx that now could be confusing with the data-xxx attribute

I didn't document it as it can be done in the pyramid PR, since it works for pyramid only.

We should probably have a link from the funnel to the pyramid page to indicate further customization are available

@bernardobelchior
Copy link
Member

This is to force a direction. Right now if the user uses data={[10, 20, 30]} or data={[30, 20, 10]} we automatically, correctly detect it.

Yeah, I think I might not have explained myself correctly. My point was: if we don't automatically detect direction, wouldn't a user be able to control the direction by the array order? I.e., data={[10,20,30]} would be increasing and data={[30,20,10]} would be decreasing.

What I'm trying to understand is if automatically detecting the direction causes unexpected behavior and maybe we should consider reverting it.

@JCQuintas
Copy link
Member Author

What I'm trying to understand is if automatically detecting the direction causes unexpected behavior and maybe we should consider reverting

The issue is when the user has 5, 10, 2 but wants it in ascending order. The direction is necessary for us to understand where the data is going (pyramid curve, but also for linear-sharp). Detecting it is necessary to provide a better dx for common cases imo.

@JCQuintas
Copy link
Member Author

We could go for direction too instead of dataDirection

What about pyramidDirection? To make it clear this only impact the pyramide, and avoid the dataXxxx that now could be confusing with the data-xxx attribute

pyramidDirection might be too specific? Unsure, we could want to add it to linear-sharp eventually. Though I didn't because it looked weird in all examples I tried...

Pretty much this is used to detect which direction the pointy shape should be

@alexfauquette
Copy link
Member

What I'm trying to understand is if automatically detecting the direction causes unexpected behavior and maybe we should consider reverting it.

Forcing the rendering to be independent from the data order would open the option to sorting data.

For example you get unsorted data from your API. You just have to put data in the Funnel, and they appear sorted according to the pyramid shape you chose. Like what Echarts is doing

Data sorting, which can be whether 'ascending', 'descending', 'none'(in data order) or a function, which is the same as Array.prototype.sort(function (a, b) { ... });

https://echarts.apache.org/en/option.html#series-funnel.sort

@bernardobelchior
Copy link
Member

bernardobelchior commented Jun 30, 2025

Forcing the rendering to be independent from the data order would open the option to sorting data.

Yeah, and is it that beneficial? The user can easily data.sort() and provide the sorted data. Obviously, we can implement sorting ourselves, but I'm not sure it makes sense. With sorting, it might also make sense to add filtering, maybe mapping, which are all things that can be done outside the scope of charts.

The only benefit I'd see is if we would be providing a more performant API, but I'm not sure that's the case.

For example you get unsorted data from your API. You just have to put data in the Funnel, and they appear sorted according to the pyramid shape you chose. Like what Echarts is doing

Yeah, makes sense. I just wonder if our effort would be better spent elsewhere since data.sort() is already something that's easily done in "userland".

@JCQuintas
Copy link
Member Author

I don't think we should sort it at all.

Pyramid is generally viewed as hierarchical data, it does not necessarily have to be sorted in the pyramid shape.

A chart like this wouldn't really make sense: 😆

Screenshot 2025-06-30 at 10 43 11

@JCQuintas
Copy link
Member Author

We could however offer data transforms, though that is another topic 🙂

@bernardobelchior
Copy link
Member

I don't think we should sort it at all.

Pyramid is generally viewed as hierarchical data, it does not necessarily have to be sorted in the pyramid shape.

A chart like this wouldn't really make sense: 😆

Screenshot 2025-06-30 at 10 43 11

Isn't that similar to the chart in #18559?

image

@JCQuintas
Copy link
Member Author

Isn't that similar to the chart in #18559?

Yes, it is similar, though your example is in the correct direction

@bernardobelchior
Copy link
Member

Isn't that similar to the chart in #18559?

Yes, it is similar, though your example is in the correct direction

What do you mean by correct direction? I think I misunderstood why the chart you posted doesn't make sense 😅

@JCQuintas
Copy link
Member Author

Isn't that similar to the chart in #18559?

Yes, it is similar, though your example is in the correct direction

What do you mean by correct direction? I think I misunderstood why the chart you posted doesn't make sense 😅

The one I posted the data is correct, the pyramid shape isn't. When you represent organisational hierarchy execs are at the top, so technically they should be the pointy bit 😆

@bernardobelchior
Copy link
Member

Ah, I see what you mean. Yeah, agreed.

Still, I'm not entirely sure that internalizing the sorting/data detection behavior is great. It's more code we need to maintain, we'll always be behind what users want (today it's sorting, tomorrow someone will need filtering), and I'm failing to see the benefit.

I think it could be beneficial if we were using this to improve performance (which we might need to do in the future), but otherwise I'm not seeing how this can be helpful.

@JCQuintas
Copy link
Member Author

Still, I'm not entirely sure that internalizing the sorting/data detection behavior is great. It's more code we need to maintain, we'll always be behind what users want (today it's sorting, tomorrow someone will need filtering), and I'm failing to see the benefit.

I think it could be beneficial if we were using this to improve performance (which we might need to do in the future), but otherwise I'm not seeing how this can be helpful.

It would be mostly performance when using a dataset I guess. But it is not high in our prio list indeed

@JCQuintas
Copy link
Member Author

I've renamed dataDirection to funnelDirection, which should make it clearer it is about the visualisation rather than the data itself.

@JCQuintas JCQuintas changed the title [charts-pro] Add dataDirection to control pyramid direction [charts-pro] Add funnelDirection to control pyramid direction Jul 2, 2025
@bernardobelchior
Copy link
Member

Just so it doesn't get lost: I'm still wondering if we should consider removing the direction detection behavior. More info here: #18568 (comment)

@JCQuintas
Copy link
Member Author

Just so it doesn't get lost: I'm still wondering if we should consider removing the direction detection behavior. More info here: #18568 (comment)

I don't think the comment you linked provides valid points.

If we don't automatically detect direction, wouldn't a user be able to control the direction by the array order? I.e., data={[10,20,30]} would be increasing and data={[30,20,10]} would be decreasing.

No, because we need to automatically detect the direction for the visualisation to change. Simply changing the order of data wouldn't do anything in a pyramid chart, where we don't calculate the sizes, we simply define the middle and boundaries of the pyramid, and plot the lines according to that. The pyramid shape can't be affected by the series data, else it wouldn't be a pyramid.

What I'm trying to understand is if automatically detecting the direction causes unexpected behavior and maybe we should consider reverting it.

For the pyramid it wouldn't change the direction at all without it.

@prakhargupta1
Copy link
Member

prakhargupta1 commented Jul 3, 2025

@bernardobelchior With {[10,20,30]} you get △, and with {[30,20,10]} you get ▽. Now if I want to represent my data so that the lowest band i.e, base of the pyramid shows lowest income level and the income level rises with pyramid, then I should be able to do that with a prop, irrespective of how my data is ordered.
So, showing {[30: high income,20: medium income ,10: low income]} in △ can only be done if we provide a data direction.

@bernardobelchior
Copy link
Member

No, because we need to automatically detect the direction for the visualisation to change. Simply changing the order of data wouldn't do anything in a pyramid chart, where we don't calculate the sizes, we simply define the middle and boundaries of the pyramid, and plot the lines according to that. The pyramid shape can't be affected by the series data, else it wouldn't be a pyramid.

With {[10,20,30]} you get △, and with {[30,20,10]} you get ▽. Now if I want to represent my data so that the lowest band i.e, base of the pyramid shows lowest income level and the income level rises with pyramid, then I should be able to do that with a prop, irrespective of how my data is ordered.
So, showing {[30: high income,20: medium income ,10: low income]} in △ can only be done if we provide a data direction.

Hm, I see! Then my proposal would be as follows:

The algorithm maps that the first value in the data to the base of the pyramid (i.e., it's widest part). The pyramid is then built from its base to its top.

We then have layout 'horizontal' | 'vertical' which defines the pyramid's orientation.

For the horizontal layout, the default is to render from left to right; bottom to top for the vertical.

Additionally, there's a invert or reverse prop that changes the direction of rendering: right to left for horizontal, top to bottom for vertical.

I think this might be clearer for the user, as I think it's counter-intuitive that the rendering direction changes with the data:

Screen.Recording.2025-07-03.at.12.46.32.mov

@JCQuintas JCQuintas force-pushed the fix-funnel-data-directionality branch from 8f3e42c to 5f0bf05 Compare July 3, 2025 14:26
@JCQuintas
Copy link
Member Author

Hm, I see! Then my proposal would be as follows:

The algorithm maps that the first value in the data to the base of the pyramid (i.e., it's widest part). The pyramid is then built from its base to its top.

We then have layout 'horizontal' | 'vertical' which defines the pyramid's orientation.

For the horizontal layout, the default is to render from left to right; bottom to top for the vertical.

Additionally, there's a invert or reverse prop that changes the direction of rendering: right to left for horizontal, top to bottom for vertical.

I think this might be clearer for the user, as I think it's counter-intuitive that the rendering direction changes with the data:

Tbh I feel this just makes something that is easy harder and the only reason is apparent consistency.

When using a linear curve we also automatically detect the direction, it just behaves differently.

Screen.Recording.2025-07-03.at.14.58.08.mov

When we want to use a funnel, the data will often be either increasing or decreasing, and we would be right most of the time out-of-the-box. If the user expects a specific direction, we are providing a way to override that in this PR.

I've pushed changes to make it similar to your suggestion, you can play with it in the curves demo. Though it doesn't feel very intuitive tbh.

Comment on lines 92 to 95
* Toggles the direction the funnel is drawn.
*
* - `decreasing`, funnel is drawn with a wide top and a point at the base.
* - `increasing`, funnel is drawn with a point at the top and a wide base.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think decreasing/increasing isn't very clear. I can't think of a clear name, so maybe a invert: boolean would make more sense.

Nevertheless, I think this should be more explicit. Something like this:

Suggested change
* Toggles the direction the funnel is drawn.
*
* - `decreasing`, funnel is drawn with a wide top and a point at the base.
* - `increasing`, funnel is drawn with a point at the top and a wide base.
* Defines the direction in which the funnel is drawn.
*
* Depending on the funnel's layout, vertical and horizontal respectively, the widest section is drawn:
* - `decreasing`: top/left first, and the funnel grows towards bottom/right;
* - `increasing`: bottom/right first, and the funnel grows towards top/left.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion adds too much context to the documentation, makes it harder to read.

Using a boolean is a bit odd, cause we are just inverting it in the case of the pyramid, but if we remove the auto mode, then this should work for all curves, which aren't really inverted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion adds too much context to the documentation, makes it harder to read.

We can reword it if you think it's too long.

IMO we should be explicit on how this prop affects the chart, otherwise people will just use trial and error to get what they want, which might be frustrating.

I'm ok with keeping increasing/decreasing, but I really think we should explain how this prop will affect the chart

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is more that I don't think this change is good. Regardless of the wording. 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why? I'm still trying to understand how the funnel works.

For example, why does setting "direction: 'increasing'" just makes the funnel sections wider?

Screen.Recording.2025-07-03.at.17.55.37.mov

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basis of the funnel is that each starts at it's own value, and then tappers to the value of the next section.

When the funnel is decreasing, we make the bottom section "static" = Straight sides, every section before that is tapered.

When it is increasing, the top section is "static" instead. To maintain the same shape overall and keep it consistent.

# linear decreasing

\     /
 \   /
  | |

# linear increasing

  | |
 /   \
/     \

For the linear-sharp version we just force the points to touch on the end

# linear-sharp

\     /
 \   /
  \ /

If we don't automatically detect the data-direction. It looks odd for some funnels, as it starts on the value of the previous section. Which for some reason look odd, although it is also technically correct.

# linear decreasing

|     |
 \   /
  \ /

If you reverse the data, then it looks as before.

Screenshot 2025-07-03 at 18 20 15

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it all makes sense now, thanks for the explanation!

So, basically, 'increasing' makes the widest section a rectangle, while 'decreasing' makes the narrowest section a rectangle, right? This for the funnel.

For the pyramid chart, 'increasing' sets the rendering direction from bottom to top, while 'decreasing' sets it to top to bottom?

Funnel is still in preview, so I'm ok with moving on with this to unblock Prakhar. IMO, we should also do a follow-up PR with documentation since I couldn't find any documentation on how the direction prop works.

Ultimately, I think we should re-evaluate this API because I feel it isn't very clear, but I'm also failing to come up with a better suggestion. Maybe in the docs PR it will become clearer how to proceed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultimately, I think we should re-evaluate this API because I feel it isn't very clear, but I'm also failing to come up with a better suggestion

The issue is that it creates charts that make no sense. A funnel with increasing value but decreasing shapes is ... uncommon

we should also do a follow-up PR with documentation since I couldn't find any documentation on how the direction prop works.

We could have a section to explain what JC just did. But for most of the users that don't want to read, they should just

  1. Don't use this prop. the "auto" covers 99% of the usecases
  2. Know that it correspond to the order they display their value for the 1% remaining

Copy link
Member

@bernardobelchior bernardobelchior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock Prakhar. We should add docs in a follow-up.

@JCQuintas JCQuintas merged commit de05657 into mui:master Jul 7, 2025
23 checks passed
@JCQuintas JCQuintas deleted the fix-funnel-data-directionality branch July 7, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. type: new feature Expand the scope of the product to solve a new problem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[charts] Pyramid Chart feedback
5 participants