Отображение графиков мониторинга исправлено

This commit is contained in:
goodmice 2021-10-21 11:37:30 +05:00
parent 4937dddf87
commit de72f13bac
2 changed files with 9 additions and 13 deletions

View File

@ -5,17 +5,13 @@ import {ChartTimeOnlineFooter} from './ChartTimeOnlineFooter';
const stroke = (sz='1px', c='white') => ({ textShadow: `-${sz} -${sz} 0 ${c}, ${sz} -${sz} 0 ${c}, -${sz} ${sz} 0 ${c}, ${sz} ${sz} 0 ${c}` })
export const Column = ({lineGroup, data, interval, showBorder, style, headerHeight}) => {
let dataLast = null
let pv = null
if (data?.length > 0) {
dataLast = data[data.length - 1];
pv = lineGroup.filter(line => line.showGraph).map(line => ({
let dataLast = data?.length > 0 ? data[data.length - 1] : null
let pv = lineGroup.filter(line => line.showGraph).map(line => ({
color: line.color,
label: line.label,
unit: line.units,
value: dataLast[line.xAccessorName]
value: dataLast?.[line.xAccessorName]
}))
}
return (
<div style={style}>
@ -27,7 +23,7 @@ export const Column = ({lineGroup, data, interval, showBorder, style, headerHeig
<div style={{position: 'relative'}}>
<Grid className={'display_chart_values'}>
{pv?.map((v, idx) => (
<GridItem key={idx} col={1} row={idx} style={{...stroke(), color: v.color, padding: '0 4px'}}>{v.value.toFixed(2)} {v.unit}</GridItem>
<GridItem key={idx} col={1} row={idx} style={{...stroke(), color: v.color, padding: '0 4px'}}>{v.value?.toFixed(2) ?? '--'} {v.unit}</GridItem>
))}
</Grid>
<ChartTimeOnline

View File

@ -43,7 +43,7 @@ const blockHeightGroup = [
dash
}, {
label: 'Расход',
units: 'м³/ч',
units: 'л/c',
xAccessorName: 'flow',
yAccessorName: 'date',
color: '#077',