venkatesh
Posts: 5
Joined: Mon Sep 05, 2022 11:33 am

Logarithmic axis - negative values.

in my chart, when I'm using the linear type on the x-axis or y-axis the chart was loading properly. but when I try to change the linear type to log type, the chart was not loading properly, if we give the positive values it was working fine if the values are negative it does not work. Does anyone have an idea to solve this issue, also referred this link also https://github.com/highcharts/highcharts/issues/13914
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Logarithmic axis - negative values.

Hello venkatesh!
Thanks for contacting us with your question!

Logarithms of negative numbers are not defined in the real numbers. The natural logarithm function ln(x) is defined only for x>0. So the natural logarithm of a negative number is undefined. But there is a little trick in Highcharts, you can use some custom options and use custom plugin to wrap some core functions to achieve working negative values in logarithmic type. You can check it in the demo below.

Demo: https://jsfiddle.net/gh/get/library/pur ... -negative/

Let me know if you have any further questions.
Regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Usage”