okrad / svelte-progressbar

A multiseries, SVG progressbar component made with Svelte
https://okrad.github.io/svelte-progressbar/
MIT License
129 stars 18 forks source link

Error #3

Closed emiola closed 5 years ago

emiola commented 5 years ago

Updating the bar, I see an error:

Error: <stop> attribute offset: Expected number or percentage, "NaN%".,

coming from this row.

okrad commented 5 years ago

How are you updating the bar?

emiola commented 5 years ago

I think it's simply a divide by zero issue.

See here:

<script>
  import ProgressBar from "@okrad/svelte-progressbar";

  export let series = [];
  export let thickness = 0;

  let bar;

  const updateBar = values => {
    values.map((v, i) => bar.updatePerc(v, i));
  };

  const resetBar = () => {
    updateBar([0, 0]);
  };
</script>

<ProgressBar bind:this={bar} {series} />

<button on:click={() => updateBar([100, 100])}>update</button>
<button on:click={resetBar}>reset</button>

resetBar() triggers the issue.

okrad commented 5 years ago

You were right, it was a division by zero... Now it should be solved.