@iotready/nextjs-components-library 1.0.0-preview7 → 1.0.0-preview8
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,
|
@@ -121,7 +121,7 @@ const chartConfigByPeriod = {
|
|
121
121
|
scaleUnit: 'year',
|
122
122
|
}
|
123
123
|
};
|
124
|
-
function
|
124
|
+
function getChartPoints(data) {
|
125
125
|
const points = data.results[0].series[0].values.map((row) => {
|
126
126
|
return {
|
127
127
|
x: moment.unix(row[0]),
|
@@ -198,7 +198,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
198
198
|
const [loadingButton, setLoadingButton] = useState(false);
|
199
199
|
const csvLinkRef = useRef(null);
|
200
200
|
const [csvData, setCsvData] = useState('');
|
201
|
-
const [spanGapsOption, setSpanGapsOption] = useState(
|
201
|
+
const [spanGapsOption, setSpanGapsOption] = useState(true);
|
202
202
|
const [options, setOptions] = useState({
|
203
203
|
...lineOptions,
|
204
204
|
plugins: {
|
@@ -285,7 +285,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
285
285
|
const datasetsPromises = measures.map(async (measure) => {
|
286
286
|
const polltime = getPollTime(intervalInSeconds, measure.polltime || 30);
|
287
287
|
const influxData = await handleGetInfluxData(measure.name, timeStart, timeEnd, deviceId, polltime, !measure.polltime && rawQuery);
|
288
|
-
const points =
|
288
|
+
const points = getChartPoints(influxData);
|
289
289
|
return {
|
290
290
|
label: measure.name,
|
291
291
|
data: points,
|
@@ -454,10 +454,10 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
|
|
454
454
|
}, 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
455
|
// sx={{ boxShadow: 1 }}
|
456
456
|
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]
|
457
|
+
_jsx(_Fragment, { children: dataMeasures && (dataMeasures.length > 1 || (dataMeasures.length === 1 && dataMeasures[0].data?.length)) ?
|
458
458
|
(_jsx(Line, { options: options, data: {
|
459
|
-
datasets: dataMeasures || [{ data: [] }]
|
460
|
-
|
459
|
+
// datasets: dataMeasures || [{ data: [] }]
|
460
|
+
datasets: dataMeasures.map(d => ({ ...d, showLine: spanGapsOption || !d.change })) || [{ data: [] }]
|
461
461
|
} })) : _jsxs(Box, { sx: {
|
462
462
|
display: 'flex',
|
463
463
|
flexDirection: 'column',
|