@netdata/charts
Version:
Netdata frontend SDK and chart utilities
59 lines • 1.72 kB
JavaScript
import React from "react";
import { Flex, TextSmall, Select } from "@netdata/netdata-ui";
import { useAttributeValue, useChart } from "../../../provider";
import TimeAggregation from "./timeAggregation";
import PointsToFetch from "../pointsToFetch";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var nullHandlingOptions = [{
value: false,
label: "Show gaps"
}, {
value: true,
label: "Treat as zero"
}];
var NullHandling = function NullHandling() {
var chart = useChart();
var nulls2zero = useAttributeValue("nulls2zero");
var current = nullHandlingOptions.find(function (o) {
return o.value === !!nulls2zero;
}) || nullHandlingOptions[0];
var handleChange = function handleChange(option) {
chart.updateAttributes({
nulls2zero: !!(option !== null && option !== void 0 && option.value)
});
chart.trigger("fetch", {
processing: true
});
};
return /*#__PURE__*/_jsxs(Flex, {
column: true,
gap: 2,
children: [/*#__PURE__*/_jsx(TextSmall, {
color: "textNoFocus",
strong: true,
children: "Null handling"
}), /*#__PURE__*/_jsx(Select, {
value: current,
onChange: handleChange,
options: nullHandlingOptions,
"data-testid": "chartSettings-nullHandling"
})]
});
};
var DataBody = function DataBody() {
return /*#__PURE__*/_jsxs(Flex, {
column: true,
gap: 3,
padding: [3],
width: {
min: "260px"
},
children: [/*#__PURE__*/_jsx(TimeAggregation, {}), /*#__PURE__*/_jsx(NullHandling, {}), /*#__PURE__*/_jsx(PointsToFetch, {})]
});
};
export default {
id: "data",
label: "Data",
Component: DataBody,
resetKeys: ["groupingMethod", "nulls2zero", "points"]
};