Mini-graph-card: Unexpected value

Created on 16 Jul 2019  路  4Comments  路  Source: kalkih/mini-graph-card

I'm getting a lot of these errors in the browser inspector:


Unexpected value -Infinity% parsing offset attribute. mini-graph-card.js:1:29437
Unexpected value NaN% parsing offset attribute. mini-graph-card.js:1:29437

Graphs seem to be displaying ok.

Example config:

color_thresholds:
  - color: '#039BE5'
    value: 0
  - color: '#0da035'
    value: 235
  - color: '#e0b400'
    value: 250
  - color: '#e45e65'
    value: 253
color_thresholds_transition: hard
entities:
  - sensor.lounge_av_voltage
group: false
hour24: true
line_width: 4
lower_bound: 220
points_per_hour: 1
show:
  extrema: true
  fill: fade
  labels: false
style: |
  ha-card {
    border: solid 2px var(--primary-color);
  }
type: 'custom:mini-graph-card'
upper_bound: 260

bug

All 4 comments

Just having a guess here, but the only use of offset followed by a "%" that I could see is line 458 of main.js:

<stop stop-color=${stop.color} offset=${`${stop.offset}%`} />

And offset comes from line 119 of graph.js:

offset: (this._max - stop.value) * (100 / scale),

So if scale was zero, you'd get Infinity. And scale comes from line 106:

const scale = this._max - this._min;

So if the graph had a matching min and max, you would probably get this error.

Untitled

I've pushed a fix to the dev branch. Can you try it out and see if it fixes the errors? You would need to follow the Development instructions at the bottom of the page to build a copy of the dev branch.

Should be fixed in the latest release, thanks @michaelblight

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PipeDeveloper picture PipeDeveloper  路  4Comments

clydefrog76 picture clydefrog76  路  6Comments

skarfacegc picture skarfacegc  路  7Comments

isabellaalstrom picture isabellaalstrom  路  6Comments

simonwood0609 picture simonwood0609  路  7Comments