Skip to content

data_generator and graph_span and zooming #407

Description

@Culan

Checklist

  • I updated the card to the latest version available
  • I cleared the cache of my browser
  • I verified that I'm really running the lastest version in my browser console
  • I checked if there is another issue opened with the same problem

Describe the bug
I'm using data_generator to get my series data.
The xaxis is a datetime axis.
The data_generator is producing data timestamped in the future (prices of electricity of coming day).
I do not use graph_span as i want it to zoom to the data available.

The data are (probably) rendered correctly but the zoom of the graph starts from now (so it shows some columns in the end).
Then, i activated the toolbar and if i click on "Reset zoom" it zooms correctly to the area where my data is.

Version of the card
Version: 2.0.1

To Reproduce
This is the configuration I used:

type: custom:apexcharts-card
update_interval: 5s
apex_config:
  chart:
    zoom:
      enabled: true
    toolbar:
      show: true
      tools:
        zoom: true
        zoomin: true
        zoomout: true
        pan: true
        reset: true
    autoScaleXaxis: true
  xaxis.type: datetime
  yaxis:
    min: 0
    decimalsInFloat: 2
hours_12: false
now:
  show: false
series:
  - entity: sensor.nordpool_kwh_se4_sek_3_095_025
    name: Test
    type: column
    float_precision: 3
    data_generator: |
      let res = [];
      res.push([(new Date()).setHours(((new Date()).getHours() + 1)), 1]);
      res.push([(new Date()).setHours(((new Date()).getHours() + 2)), 2]);
      res.push([(new Date()).setHours(((new Date()).getHours() + 3)), 3]);
      res.push([(new Date()).setHours(((new Date()).getHours() + 4)), 4]);
      res.push([(new Date()).setHours(((new Date()).getHours() + 5)), 5]);
      res.push([(new Date()).setHours(((new Date()).getHours() + 6)), 6]);
      res.push([(new Date()).setHours(((new Date()).getHours() + 7)), 7]);

      return res;


Screenshots
Before reset zoom:
image

After zoom:
image

Expected behavior
I would expect the zoom to recalculate once the data_generator data has been added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions