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;