greghub / funnel-graph-js

SVG Funnel Graph Javascript Library
MIT License
294 stars 70 forks source link

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

Open jojobobby opened 1 year ago

jojobobby commented 1 year ago

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();
cnicodeme commented 3 weeks ago

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