回来交作业了,楼上用电情况的表,按楼主提供的方法修改后正常了
type: custom:apexcharts-card
graph_span: 30d
locale: zh-cn
all_series_config:
stroke_width: 2
opacity: 0.8
type: line
header:
show: true
title: 用电情况
show_states: true
colorize_states: true
series:
- entity: sensor.historyelectricity
name: 峰用电
data_generator: |
const data = [];
entity.attributes.history.map((peak, index) => {
data.push([new Date(peak.datetime).getTime(), peak.ZXYGZ2]);
});
for( var i = 0; i < data.length; i++ ){
for( var j = i + 1; j < data.length; j++ ){
if(data[i][0] > data[j][0]){
const data1 = data[i];
data[i] = data[j];
data[j] = data1;
}
}
}
return data;
- entity: sensor.historyelectricity
name: 谷用电
data_generator: |
const data = [];
entity.attributes.history.map((peak, index) => {
data.push([new Date(peak.datetime).getTime(), peak.ZXYGZ4]);
});
for( var i = 0; i < data.length; i++ ){
for( var j = i + 1; j < data.length; j++ ){
if(data[i][0] > data[j][0]){
const data1 = data[i];
data[i] = data[j];
data[j] = data1;
}
}
}
return data;
- entity: sensor.historyelectricity
name: 全天用电
data_generator: |
const data = [];
entity.attributes.history.map((peak, index) => {
data.push([new Date(peak.datetime).getTime(), peak.ZXYGZ]);
});
for( var i = 0; i < data.length; i++ ){
for( var j = i + 1; j < data.length; j++ ){
if(data[i][0] > data[j][0]){
const data1 = data[i];
data[i] = data[j];
data[j] = data1;
}
}
}
return data;
|