Skip to content
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

[Feature]: Multiple y-axes in AreaChart #855

Open
scaltunsoy opened this issue Dec 14, 2023 · 0 comments
Open

[Feature]: Multiple y-axes in AreaChart #855

scaltunsoy opened this issue Dec 14, 2023 · 0 comments
Labels
Hint: Duplicate Marked as duplicate Type: Feature New feature for existing component

Comments

@scaltunsoy
Copy link

What problem does this feature solve?

I want to have two y-axes which have different domains. For example, y axis on the left side shows the amount of money while the one on the right side may shows the percentage.

It looks like recharts support this: https://codesandbox.io/p/sandbox/simple-line-chart-forked-c2h5cw. yAxisId and orientation may be used.

Here is an example from another library: https://www.chartjs.org/docs/latest/samples/line/multi-axis.html

What does the proposed API look like?

AreaChart may have optional orientation property which is an array of left and right.

Example: orientation=["left", "right"]

It means that the y axis of the first category is on the left side. The other one is on the right side. If orientation is provided, more than one YAxis (from recharts) can be used. If orientation is not provided as it is optional, the current behavior should not be changed.

This API also solves #827. orientation=["right"] may be passed in that case.


In addition to orientation, valueFormatter property should be modified. Since the values on different axes are from different domains, they should be formatted differently. The valueFormatter function may have an optional second parameter: index.

function formatter(value, index) {
 switch (index) {
  case 0:
   return formatCurrency(value, locale, currency)
  case 1:
   return formatPercentage(value, locale)
 }
}

valueFormatter={formatter}


I think neither adding orientation property nor modifying valueFormatter is a breaking change.

@scaltunsoy scaltunsoy mentioned this issue Dec 14, 2023
15 tasks
@severinlandolt severinlandolt added Type: Feature New feature for existing component Hint: Duplicate Marked as duplicate labels Dec 15, 2023
@severinlandolt severinlandolt linked a pull request Apr 12, 2024 that will close this issue
15 tasks
@scaltunsoy scaltunsoy mentioned this issue Apr 29, 2024
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hint: Duplicate Marked as duplicate Type: Feature New feature for existing component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants