funnel-graph-js icon indicating copy to clipboard operation
funnel-graph-js copied to clipboard

Logged error when graph data values consists of all 0's

Open jojobobby opened this issue 2 years ago • 1 comments

Issue

Having an issue with your funnel graph library where I can have default values as 0, but it logs errors to my console when I draw the graph with those values.

Explanation

The actual functionality of the graph is fine, it displays with no data as it should and shows 0 as all values. The issue is that it also sends a error for NaN as I suspect that it is trying to draw the graph with no data to work with instead of ignoring the draw entirely.

This quickly becomes bloat in my error-logs when debugging, especially when i'm updating the graph on a timed interval of 5 seconds.

Images

Code: Screenshot 2023-05-25 at 11 58 07 AM

Error: Screenshot 2023-05-25 at 11 58 48 AM

Example

Example on how to replicate this issue: (The values are the only important part) -> The code was meant to serve as a example, may not be runnable

const graph = new FunnelGraph({
  container: ".funnel",
  gradientDirection: "horizontal",
  data: {
    labels: ["X", "Y", "Z"],
    colors: ["#000000", "#000000"],
    values: [0, 0, 0]
  },
  displayPercent: true,
  direction: "horizontal",
  width: 1000,
  height: 100,
  subLabelValue: "raw"
})
  
graph.draw();

jojobobby avatar May 25 '23 17:05 jojobobby

Did you solve it or found a solution ? I have the same issue.

cnicodeme avatar Oct 02 '24 13:10 cnicodeme