Hi,
I have 12 sensors with numeric values in them corresponding to 12 months of data.
I want to make a graph line with the values of each month.
I tried this:
type: custom:apexcharts-card
header:
show: true
title: Évolution
show_states: true
colorize_states: true
series:
- entity: sensor.evolution_month_01
data_generator: |
const data = [];
const now = new Date();
const monthNames = ["Janv.", "Fév.", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Sept.", "Oct.", "Nov.", "Déc."];
for (let i = 0; i < monthNames.length; i++) {
const monthData = states['sensor.evolution_month_' + (i + 1)];
const value = monthData && monthData.state ? parseFloat(monthData.state) : 0;
const timestamp = new Date(now.getFullYear(), i, 1).getTime();
data.push([timestamp, value]);
}
return data;
But the graph does not load, it remains “loading”.
Each sensor has a numeric value in it. Anyone have an idea?