apexcharts / apexcharts.js

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

Line Plot Y-range incorrect when series has multiple points with same x-value #4560

Closed alankalb closed 1 month ago

alankalb commented 1 month ago

Description

When plotting a line chart, the y-axis range is not correct if the series has multiple points with the same x value and one of those points is outside of the range of all other points in the series.

From my testing, it appears that this occurs when there are more than two points that share the same x value. Only the first two points are used to calculate the range. All others seem to be discarded.

Steps to Reproduce

  1. Create a line plot with at-least three points that have the same x value. Ensure the last point has a y value that is greater than any other y value in the series.

Expected Behavior

Y-axis range for axis is calculated from absolute range of series

Actual Behavior

Y-axis range axis range is not calculated correctly when multiple points in a series have the same x value.

Screenshots

image

Reproduction Link

https://codepen.io/Alan-Kalbfleisch/pen/KKLorJe

alankalb commented 1 month ago

The same issue occurs with scatter plots. This is actually more concerning for scatter plots as a scatter plot should definitely be able to plot multiple points with the same x-values without breaking. I can somewhat understand why this may break for line charts as there could be an assumption that line charts should be for results from well-defined functions.

junedchhipa commented 1 month ago

@rosco54 can you take a look at this one? This seems to be broken after v3.46.0

rosco54 commented 1 month ago

@junedchhipa Working on it.