@iotready/nextjs-components-library 1.0.0-preview7 → 1.0.0-preview9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ import MuiTooltip from '@mui/material/Tooltip';
|
|
23
23
|
const lineOptions = {
|
24
24
|
parsing: false,
|
25
25
|
normalized: true,
|
26
|
-
spanGaps:
|
26
|
+
spanGaps: true, // enable for all datasets
|
27
27
|
// showLine: false, // disable for all datasets
|
28
28
|
animation: false,
|
29
29
|
responsive: true,
|
@@ -76,15 +76,7 @@ const lineOptions = {
|
|
76
76
|
drawOnChartArea: false,
|
77
77
|
}
|
78
78
|
},
|
79
|
-
y: {
|
80
|
-
ticks: {
|
81
|
-
callback: function (value) {
|
82
|
-
if (Math.floor(value) === value) {
|
83
|
-
return value;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
}
|
87
|
-
},
|
79
|
+
y: {},
|
88
80
|
},
|
89
81
|
};
|
90
82
|
const chartConfigByPeriod = {
|
@@ -121,7 +113,7 @@ const chartConfigByPeriod = {
|
|
121
113
|
scaleUnit: 'year',
|
122
114
|
}
|
123
115
|
};
|
124
|
-
function
|
116
|
+
function getChartPoints(data) {
|
125
117
|
const points = data.results[0].series[0].values.map((row) => {
|
126
118
|
return {
|
127
119
|
x: moment.unix(row[0]),
|
@@ -198,7 +190,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
198
190
|
const [loadingButton, setLoadingButton] = useState(false);
|
199
191
|
const csvLinkRef = useRef(null);
|
200
192
|
const [csvData, setCsvData] = useState('');
|
201
|
-
const [spanGapsOption, setSpanGapsOption] = useState(
|
193
|
+
const [spanGapsOption, setSpanGapsOption] = useState(true);
|
202
194
|
const [options, setOptions] = useState({
|
203
195
|
...lineOptions,
|
204
196
|
plugins: {
|
@@ -285,7 +277,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
285
277
|
const datasetsPromises = measures.map(async (measure) => {
|
286
278
|
const polltime = getPollTime(intervalInSeconds, measure.polltime || 30);
|
287
279
|
const influxData = await handleGetInfluxData(measure.name, timeStart, timeEnd, deviceId, polltime, !measure.polltime && rawQuery);
|
288
|
-
const points =
|
280
|
+
const points = getChartPoints(influxData);
|
289
281
|
return {
|
290
282
|
label: measure.name,
|
291
283
|
data: points,
|
@@ -321,9 +313,9 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
321
313
|
let paddedMin = null;
|
322
314
|
let paddedMax = null;
|
323
315
|
if (min !== null && max !== null) {
|
324
|
-
const diff =
|
325
|
-
paddedMin = min - diff;
|
326
|
-
paddedMax = max + diff;
|
316
|
+
const diff = ((max - min) * 0.2) < 0.1 ? 0.1 : (max - min) * 0.2;
|
317
|
+
paddedMin = Math.floor((min - diff) * 10) / 10;
|
318
|
+
paddedMax = Math.ceil((max + diff) * 10) / 10;
|
327
319
|
}
|
328
320
|
setDataMeasures([...datasets]);
|
329
321
|
setTimeStartPicker(minTime || timeStart);
|
@@ -454,10 +446,10 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
454
446
|
}, children: [_jsx(ZoomOut, { fontSize: 'small' }), _jsx(Box, { sx: { display: { xs: 'none', lg: 'block' }, ml: { md: 1 } }, children: "Reset" })] }))] }), _jsxs(Box, { sx: { display: 'flex', justifyContent: 'flex-end' }, children: [enableDatePicker && _jsx(Box, { sx: { display: { xs: 'none', lg: 'flex' } }, children: datePicker }), _jsxs(ToggleButtonGroup, { color: "primary", value: !datePickerUsed && !zoomed ? chartPeriod : null, exclusive: true, onChange: handleChange, size: "small",
|
455
447
|
// sx={{ boxShadow: 1 }}
|
456
448
|
disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 2 }, children: _jsx(TimelineIcon, {}) }) })] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { height: { xs: enableDatePicker && props.height ? `calc(${props.height} - 50px)` : props.height, lg: props.height }, minHeight: 300, mt: 2 }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
|
457
|
-
_jsx(_Fragment, { children: dataMeasures && dataMeasures[0]
|
449
|
+
_jsx(_Fragment, { children: dataMeasures && (dataMeasures.length > 1 || (dataMeasures.length === 1 && dataMeasures[0].data?.length)) ?
|
458
450
|
(_jsx(Line, { options: options, data: {
|
459
|
-
datasets: dataMeasures || [{ data: [] }]
|
460
|
-
|
451
|
+
// datasets: dataMeasures || [{ data: [] }]
|
452
|
+
datasets: dataMeasures.map(d => ({ ...d, showLine: spanGapsOption || !d.change })) || [{ data: [] }]
|
461
453
|
} })) : _jsxs(Box, { sx: {
|
462
454
|
display: 'flex',
|
463
455
|
flexDirection: 'column',
|
@@ -28,7 +28,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
28
28
|
const [selectedGroup, setSelectedGroup] = useState(group);
|
29
29
|
const [groups, setGroups] = useState(null);
|
30
30
|
const [usersList, setUsersList] = useState([]);
|
31
|
-
const [usersGroup, setUsersGroup] = useState(
|
31
|
+
const [usersGroup, setUsersGroup] = useState(null);
|
32
32
|
const [groupInfo, setGroupInfo] = useState(null);
|
33
33
|
const [openAdd, setOpenAdd] = useState(false);
|
34
34
|
const [groupName, setGroupName] = useState('');
|
@@ -132,7 +132,9 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
132
132
|
if (currentGroup && !checkboxSelection) {
|
133
133
|
setSelectedGroup(currentGroup);
|
134
134
|
setGroupInfo(groups && groups.find((g) => g.id === currentGroup));
|
135
|
-
|
135
|
+
if (currentGroup !== 'all') {
|
136
|
+
getUsersGroup(currentGroup);
|
137
|
+
}
|
136
138
|
fetchDevices(currentGroup, currentGroup);
|
137
139
|
}
|
138
140
|
}, [currentGroup]);
|