apexcharts / apexcharts.js

📊 Interactive JavaScript Charts built on SVG
https://apexcharts.com
MIT License
14.43k stars 1.31k forks source link

Logarithmic Scale incorrectly displayed when some values are 1 #2909

Closed JamieMair closed 2 years ago

JamieMair commented 2 years ago

Description

Height of bars are incorrectly set on a histogram with a logarithmically scaled y axis, this is shown in the first screenshot.

Steps to Reproduce

  1. Create a chart of histogram type series values of integers spanning from 1 to 100,000+, as in the first screenshot.
  2. Set the yaxis to logarithmic:
    yaxis: {
    logarithmic: true
    }

    Expected Behavior

    The graph should roughly look like screenshot 2, expect the scale should be large enough to include all the values in the histogram (except zeros) - including the values of 1.

The screenshot is produced by applying a "fix" in the settings, making the yaxis on the chart options:

yaxis: {
  logarithmic: true,
  min: 0.1
}

Notice that the chart cuts off all values which are 1, instead of setting the y scale to include "0.1".

Actual Behavior

Larger values are clipped and not displayed according to the axis correctly.

Screenshots

Screenshot 1: image Screenshot 2: image

Reproduction Link

Original: https://codepen.io/jfm1029/pen/XWeLBKo Almost fixed: https://codepen.io/jfm1029/pen/mdBZjEE

Ben0909 commented 2 years ago

I have similar problem . The problem with the wrong height of the bars when using logarithmic scale isn't only when inserting series value with the value 1, but with any numbers greater then or equal to 0.

For Example, for this series values : [50,40,30,20,10]

Actual Behavior: image

Expected Behavior: image