dbuezas / lovelace-plotly-graph-card

Highly customisable Lovelace card to plot interactive graphs. Brings scrolling, zooming, and much more!
411 stars 20 forks source link

Maximum call stack size exceeded on IOS App #452

Closed Woodstockskipper closed 1 month ago

Woodstockskipper commented 2 months ago

Describe the bug Hi, since some days I get the following error (see screenshot) on the IOS App on all devices. Android App and Browser work fine:

Screenshots This is the error respond: (IOS) grafik This it should look like: (browser) newplot

yaml

type: custom:plotly-graph

entities:
  - entity: sensor.si_6_0_battery_voltage_a
    filters:
      - resample: 0.5h
    internal: true
    fn: $fn ({ xs, ys, vars }) => { vars.y_axis = ys; vars.xs = xs; }
  - entity: sensor.si_6_0_battery_soc_total
    filters:
      - resample: 0.5h
    internal: true
    fn: |-
      $fn ({xs, ys, vars }) => { vars.x_axis = ys; 
        const clr =[]
      for (let i = 1; i < xs.length; i++){         
              if(i < xs.length -1)
              {clr[i] = "blue"}
              else
              {clr[i] = "crimson"}
       }
       vars.clr = clr;}
  - entity: ''
    name: Ladezustände
    x: $fn ({ vars }) => vars.x_axis
    'y': $fn ({ vars }) => vars.y_axis
    type: scatter
    mode: markers
    marker:
      size: 5
      color: $fn ({ vars }) => vars.clr
  - entity: ''
    name: Nom. Entladekurve
    x:
      - 10
      - 20
      - 30
      - 80
      - 95
      - 98
      - 100.01
    'y':
      - 46.6
      - 49.6
      - 50.1
      - 51.7
      - 52.2
      - 53
      - 55
    mode: lines
    line:
      color: darkslateblue
      shape: spline
hours_to_show: 750
raw_plotly_config: true
ha_theme: true
layout:
  margin:
    t: 10
    l: 60
    r: 10
    b: 70
  height: 500
  yaxis:
    title:
      text: Batteriespannung [V]
  xaxis:
    title:
      text: SOC [%]
    autorange: true
  legend:
    orientation: h
    bgcolor: transparent
    x: 0
    'y': 1
    yanchor: bottom

Additional context I had a long search to find this powerful tool and I´m verry excited. It would be nice if someone could help me to make it work again.

dbuezas commented 2 months ago

That's odd.

Maybe try adding all semicolons, just in case there's any ambiguous statement:

type: custom:plotly-graph

entities:
  - entity: sensor.si_6_0_battery_voltage_a
    filters:
      - resample: 0.5h
    internal: true
    fn: |
      $fn({ xs, ys, vars }) => { 
        vars.y_axis = ys; 
        vars.xs = xs; 
      }
  - entity: sensor.si_6_0_battery_soc_total
    filters:
      - resample: 0.5h
    internal: true
    fn: |
      $fn({ xs, ys, vars }) => { 
        vars.x_axis = ys; 
        const clr = [];
        for (let i = 1; i < xs.length; i++) {         
          if (i < xs.length - 1) {
            clr[i] = "blue";
          } else {
            clr[i] = "crimson";
          }
        }
        vars.clr = clr;
      }
  - entity: ''
    name: Ladezustände
    x: $fn({ vars }) => vars.x_axis
    y: $fn({ vars }) => vars.y_axis
    type: scatter
    mode: markers
    marker:
      size: 5
      color: $fn({ vars }) => vars.clr
  - entity: ''
    name: Nom. Entladekurve
    x:
      - 10
      - 20
      - 30
      - 80
      - 95
      - 98
      - 100.01
    y:
      - 46.6
      - 49.6
      - 50.1
      - 51.7
      - 52.2
      - 53
      - 55
    mode: lines
    line:
      color: darkslateblue
      shape: spline
hours_to_show: 750
raw_plotly_config: true
ha_theme: true
layout:
  margin:
    t: 10
    l: 60
    r: 10
    b: 70
  height: 500
  yaxis:
    title:
      text: Batteriespannung [V]
  xaxis:
    title:
      text: SOC [%]
    autorange: true
  legend:
    orientation: h
    bgcolor: transparent
    x: 0
    y: 1
    yanchor: bottom
Woodstockskipper commented 2 months ago

Thank you for cleaning up the code (I'm not so experienced). But even after cleaning up the code, the behaviour with IOS remains. The strange thing is, that this code ran for some weeks on all devices. May it be, that there is a limitation for the shown dots in IOS? The number of dots in the graph are already increasing every day, up to about 1500 (750h with 2 dots per hour) I tried already to reduce the number of dots, but this didn't change the behaviour. Stephan

dbuezas commented 2 months ago

Could be. Does changing hours to show to 24 makes it work on iOS?

Woodstockskipper commented 2 months ago

Yes! In my tests I went down to 100. The diagram shall show the long term discharging curve for a Battery, there I would need about two month of data. In the browser it works. That should be ok for analysis. But strange with the IOS...-

Woodstockskipper commented 1 month ago

Hi, now after 6 weeks of problems with the iOS, it now works again without problem. May be, that an update of the iOS solved it. Thank you for your support! We can close the issue now.