Matheus Vinícius
Matheus Vinícius

Reputation: 25

Am charts v3 XY not working with logarithmic scale

I'm woking with angularJS and npm package amcharts3 "^3.21.15". I'm having a little issue with logarithmic scale in my XY chart. This is my chart without logarithmic scale:

Working Chart without logarithmic scale

ValueAxes code:

"valueAxes": [{
          //"logarithmic": true,
          "minMaxMultiplier": 1.2,
          "position": "bottom",
          "axisAlpha": 0,
          "title": "Grupos"
        }, {
          //"logarithmic": true,
          "minMaxMultiplier": 1.2,
          "axisAlpha": 0,
          "position": "left"
          }
        ]

When I activate both log scale, the chart just get blank:

Not working blank chart

And when I activate only one scale (X or Y), the chart still not showing the data, only the respective axes lines and values:

Not working chart showing only one axes information

And there's no error in browser console.

Could someone help me, please?

Thanks.

Upvotes: 1

Views: 428

Answers (1)

xorspark
xorspark

Reputation: 16012

Logarithimic scale only supports positive, non-zero values and will break if you have data that doesn't meet this condition, which your working chart screenshot seems to show. For zero values, you can use the treatZeroAs property to remap those values to a small decimal value; negative values need to be removed:

"valueAxes": [{
 "logarithmic": true,
 "treatZeroAs": 0.01,
 "minMaxMultiplier": 1.2,
 "position": "bottom",
 "axisAlpha": 0,
 "title": "Grupos"
}, {
 "logarithmic": true,
 "treatZeroAs": 0.001
 "minMaxMultiplier": 1.2,
 "axisAlpha": 0,
 "position": "left"
 }
]

Upvotes: 4

Related Questions