Display apexchart from Statistic entity

And not sure why I did not see this before but… you can ‘fake’ an entity via the datagenerator and collect the stats using the websocket.
In below sensor.0c414c7e_b64a8a9a_browser_user is just a random entity as Apexcharts demands an existing entity …it is a dummy entry but has to be an existing one
the stat_entity has to be added twice and then it works.
Note that for my statistiuc data, I am using the ‘state’ value, you may want ‘sum’ or 'mean’or anything else IF that exists for your entity (check via the HA statistics graph)

type: custom:apexcharts-card
graph_span: 100d
series:
  - entity: sensor.0c414c7e_b64a8a9a_browser_user
    name: current
    color: red
    stroke_width: 1.3
    data_generator: |
      const stat_entity = 'gazpar:gazpar_thuis_consumption_stat';
      var statistics = await hass.callWS({
          type: 'recorder/statistics_during_period',
          start_time: new Date(start).toISOString(),
          end_time: new Date(end).toISOString(),
          statistic_ids: [stat_entity],
          period: "hour",
      });
      var stats = statistics[stat_entity];
      var result = [];
      var len = stats.length;
      for (let i = 0; i < len; i++) {
        let stat = stats[i].state;
        result.push([(new Date(stats[i].end).getTime()),stat]);
        }
      return result;