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

Local formatter for ValueAxis #4394

Open
romkai opened this issue Apr 8, 2024 · 2 comments
Open

Local formatter for ValueAxis #4394

romkai opened this issue Apr 8, 2024 · 2 comments

Comments

@romkai
Copy link

romkai commented Apr 8, 2024

https://www.amcharts.com/docs/v4/concepts/axes/value-axis/#Setting_label_format

A problem has been found with amCharts 4 when using the function to create a chart from a config (createFromConfig), the local formatting does not work correctly.

Example of a chart created using the "create()" function - https://codepen.io/srcmzzwr-the-flexboxer/pen/dyLdJEp
Example of a chart created using the "createFromConfig()" function - https://codepen.io/srcmzzwr-the-flexboxer/pen/GRLQyLv

In my example, the category axis is based on numerical values, and formatting has been added to the value axis (not category axis).

The 1st example (the "create" function) works correctly, but in the 2nd example (the "createFromConfig" function), the formatting is applied to the category axis (although I did not specify this).

Can you suggest how to solve this problem? Thank you in advance.

image

@martynasma
Copy link
Collaborator

You need to use forceCreate: true setting if you want to create a new object in JSON config.

Otherwise it will access existing (global) formatter reference, and will modify it.

  "yAxes": [{
    "type": "ValueAxis",
    "numberFormatter": {
      "forceCreate": true,
      "type": "NumberFormatter",
      "numberFormat": "#.##a $"
    }
  }],

Copy link

github-actions bot commented May 9, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants