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

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}` }) 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}) => { export const Column = ({lineGroup, data, interval, showBorder, style, headerHeight}) => {
let dataLast = null let dataLast = data?.length > 0 ? data[data.length - 1] : null
let pv = null let pv = lineGroup.filter(line => line.showGraph).map(line => ({
if (data?.length > 0) {
dataLast = data[data.length - 1];
pv = lineGroup.filter(line => line.showGraph).map(line => ({
color: line.color, color: line.color,
label: line.label, label: line.label,
unit: line.units, unit: line.units,
value: dataLast[line.xAccessorName] value: dataLast?.[line.xAccessorName]
})) }))
}
return ( return (
<div style={style}> <div style={style}>
@ -27,7 +23,7 @@ export const Column = ({lineGroup, data, interval, showBorder, style, headerHeig
<div style={{position: 'relative'}}> <div style={{position: 'relative'}}>
<Grid className={'display_chart_values'}> <Grid className={'display_chart_values'}>
{pv?.map((v, idx) => ( {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> </Grid>
<ChartTimeOnline <ChartTimeOnline

View File

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