ApexCharts card - A highly customizable graph card

Hi there, I am new to Apex charts and try to limit the graph on the X-Axis to show up only when there is any data to display. So far I am only able to control this by hardcoding the graph span.
Is there any way to handle this dynamically based on the date from the data generator?

type: custom:apexcharts-card
graph_span: 12h
span:
  start: day
  offset: +7h

header:
  show: true
  title: Solar Prognose für heute
  show_states: false
  colorize_states: true
series:
  - entity: sensor.forecast_solar_power_estimate_watt_today
    type: line
    data_generator: |
      const sensorData = hass.states['sensor.forecast_solar_power_estimate_watt_today'].attributes.data;
      const data = [];
      
      // Iteriere über die Daten des Sensors und wandle die Timestamps um
      sensorData.forEach(item => {
        // Nur Daten verwenden, die einen Wert haben
        if (item.value > 0) {
          // Wandle den timestamp in Millisekunden um, da ApexCharts dies erwartet
          const timestamp = new Date(item.timestamp).getTime();
          
          // Wandle den Wert von Watt in Kilowatt um
          const valueInKW = item.value / 1000;

          // Füge die Daten im [timestamp, valueInKW] Format hinzu
          data.push([timestamp, valueInKW]);
        }
      });

      return data;

Hello,
Im trying to show temperature from last 365d, averaged by week.
It works fine with history stats:

But when im trying with apex it shows (my HA running only few weeks)

Is there any way to fulfill whole plot when there is no data?
(workaround is to set now graph span to 5week and increase it every week, but is any better solution?

Thanks bro! working good

1 Like

Confusing statement, you want data 365d ago and you only run since few weeks? If the latter then Apex shows correct and the other not