Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in avg function when all values are the same #845

Open
4 tasks done
pat-iphone opened this issue Jan 8, 2025 · 0 comments
Open
4 tasks done

Bug in avg function when all values are the same #845

pat-iphone opened this issue Jan 8, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@pat-iphone
Copy link

Checklist

  • I updated the card to the latest version available
  • I cleared the cache of my browser
  • I verified that I'm really running the lastest version in my browser console
  • I checked if there is another issue opened with the same problem

Describe the bug
Hi,

I encountered an issue with the avg function in apexcharts-card. When the values to be averaged are all identical, the card crashes and fails to render properly.

Steps to reproduce:

Configure apexcharts-card with a dataset where all values are the same.
Use the avg function to calculate the average.
Observe that the chart fails to display.

Expected behavior: The card should handle datasets with identical values correctly and display the average without errors.

Actual behavior: The card crashes or fails to render when the dataset contains identical values.

Version of the card
Version:
v2.1.2

To Reproduce
This is the configuration I used:

type: custom:apexcharts-card
graph_span: 7d
yaxis:
  - id: first
    decimals: 0
    apex_config:
      tickAmount: 4
  - id: second
    opposite: true
    decimals: 0
    apex_config:
      tickAmount: 4
span:
  start: day
  offset: "-6d"
apex_config:
  chart:
    height: 200px
header:
  show: true
  show_states: true
  colorize_states: true
color_list:
  - blue
  - green
  - black
series:
  - entity: sensor.pompes_energy
    yaxis_id: first
    group_by:
      func: diff
      duration: 1d
    type: column
    name: Consommation journalière Pompes
    show:
      datalabels: true
      legend_value: false
  - entity: sensor.blueriiot_pool_sensor_pool_temperature
    yaxis_id: second
    stroke_width: 2
    group_by:
      func: avg
      duration: 1d
    unit: ºC
    name: Temp. Moy. piscine
    show:
      datalabels: false
      in_chart: true
      legend_value: false

The problem is on the "blueriiot_pool_sensor_pool_temperature" value

Screenshots
If applicable, add screenshots to help explain your problem.

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • Browser [Firefox]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [iPhone15pro]
  • OS: [iOS18.2]
  • Browser [Safari]

Additional context

This issue seems to be related to how the avg function processes identical values. It might be a division by zero or an assumption of variability in the dataset.

Thank you for looking into this!

@pat-iphone pat-iphone added the bug Something isn't working label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant