apache/echarts

[Bug] Bar width is too wide and span accross other dates in x-axis when series has limited data points

Opened this issue · 3 comments

Version

5.2.2

Link to Minimal Reproduction

https://tinyurl.com/mr3h2jyk

Steps to Reproduce

Configuration

  1. x-axis is set to "time".
  2. x-axis is set with "min" and "max" value.
  3. series has very limited available data points within the timeframe between "min" and "max" value.

The following example is to achieve showing 2 series in bars on 12:00 a.m. each day. The described defect is occured when there is only one data point ["2024-11-22", 1000] is available in the series while the x-axis is set to be shown from "2024-11-21" to "2024-11-28".

Possible solutions by manipulating the "barWidth" & "barMaxWidth" has been tried, but the "barWidth" will be too slim when series has sufficient data points (e.g. 4 data points within "2024-11-21" and "2024-11-28").

Current Behavior

1732889595124

As shown in the chart, the bars on "2024-11-22" are too wide and span accross other dates in the x-axis. The x-axis is also no longer shown from "2024-11-21" to "2024-11-28" although the "min" and "max" (or "startValue" and "endValue") are set.

Expected Behavior

1732890109968

The expected behaviour is the bars with appropriate width are shown on "2024-11-22" and the x-axis shows the defined period "2024-11-21" to "2024-11-28".

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Your two bar charts overlap on a single point in time. "Appropriate width" could be controlled thru something like barWidth:'3%'.
Couldn't replicate the X-axis problem.

Hi Helgasoft, the bar chart is intended to display 2 series on a single point of time (e.g. 12:00 a.m. every day). The problems of the chart are the bar width is inappropriate and the x-axis does not show the defined timeframe (from "2024-11-21" to "2024-11-28").

For your information, I have tried to set the barWidth to "x%" in order to achieve the "Appropriate width" in this case. However, if the barWidth is set to "3%", when the chart is set with shorter period (e.g. from "2024-11-21" to "2024-11-25") , the bars will be too slim. (https://tinyurl.com/3wwjrak7)

On the other hand, when the chart is set with larger period (e.g. from "2024-11-21" to "2024-12-31"), the bars will span accross other dates too. In this URL (https://tinyurl.com/5c3tmer5), the data on "2024-11-22" still spans to "2024-11-21" and "2024-11-23".

Moreover, when the chart has no missing data, the barWidth with "3%" will be too slim. (https://tinyurl.com/ycyjd9uu)

The bar width should be adaptive and the x-axis period should always show the defined min and max value.

Here is a possible workaround which seems to work reasonably well.