Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
downsampleZoomData(props, childProps, domain) {
const { downsample } = props;
const rawData = get(childProps, "data");
// return undefined if downsample is not run, then default() will replace with child.props.data
if (!downsample || !rawData || !domain) { return undefined; }
// if data accessors are not used, skip calling expensive Data.formatData
const data = (childProps.x || childProps.y) ? Data.formatData(rawData, childProps) : rawData;
const maxPoints = (downsample === true) ? DEFAULT_DOWNSAMPLE : downsample;
const dimension = props.zoomDimension || "x";
// important: assumes data is ordered by dimension
// get the start and end of the data that is in the current visible domain
let startIndex = data.findIndex((d) => d[dimension] >= domain[dimension][0]);
let endIndex = data.findIndex((d) => d[dimension] > domain[dimension][1]);
// pick one more point (if available) at each end so that VictoryLine, VictoryArea connect
if (startIndex !== 0) { startIndex -= 1; }
if (endIndex !== -1) { endIndex += 1; }
const visibleData = data.slice(startIndex, endIndex);
return Data.downsample(visibleData, maxPoints, startIndex);
}
React.Children.toArray(children).map((child, index) => {
if (child.props) {
const { data: childData, ...childProps } = child.props;
const datum = Data.formatData([childData], childProps, ['x', 'y']); // Format child data independently of this component's props
const dynamicTheme =
childProps.theme ||
getDonutThresholdDynamicTheme(childProps.themeColor || themeColor, childProps.themeVariant || themeVariant);
return React.cloneElement(child, {
constrainToVisibleArea,
data: childData,
endAngle: 360 * (datum[0]._y ? datum[0]._y / 100 : 0),
height,
invert,
key: `pf-chart-donut-threshold-child-${index}`,
padding: defaultPadding,
radius: chartRadius - 14, // Donut utilization radius is threshold radius minus 14px spacing
showStatic: false,
standalone: false,
subTitlePosition: childProps.subTitlePosition || subTitlePosition,
const getData = (props) => {
const accessorTypes = ["x", "high", "low", "close", "open"];
return Data.formatData(props.data, props, accessorTypes);
};
const getData = (props) => {
const accessorTypes = ["x", "y", "errorX", "errorY"];
if (props.data) {
return Data.formatData(props.data, props, accessorTypes);
} else {
const generatedData = props.errorX || props.errorY ? Data.generateData(props) : [];
return Data.formatData(generatedData, props, accessorTypes);
}
};
const getData = () => {
const datum = [{ ...data }];
return Data.formatData(datum, { x, y, ...rest }, ['x', 'y']).sort((a: any, b: any) => a._y - b._y);
};
const getData = (props) => {
const accessorTypes = ["x", "y", "errorX", "errorY"];
if (props.data) {
return Data.formatData(props.data, props, accessorTypes);
} else {
const generatedData = props.errorX || props.errorY ? Data.generateData(props) : [];
return Data.formatData(generatedData, props, accessorTypes);
}
};