amcharts/amcharts4

Local formatter for ValueAxis

romkai opened this issue · 2 comments

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

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 $"
    }
  }],

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.