Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const evaluateProps = (props) => {
// Potential evaluated props are 1) `style`, 2) `candleWidth`
const style = Helpers.evaluateStyle(assign({ stroke: "black" }, props.style), props);
const candleWidth = getCandleWidth(props.candleWidth, assign({}, props, { style }));
return assign({}, props, { style, candleWidth });
};
? baseLabelStyle.map((s) => Helpers.evaluateStyle(s, props))
: Helpers.evaluateStyle(baseLabelStyle, props);
const getLabelProps = (text, dataProps, calculatedValues) => {
const { index, datum, data, slice } = dataProps;
const { style, defaultRadius, origin, width, height } = calculatedValues;
const labelRadius = Helpers.evaluateProp(
calculatedValues.labelRadius,
assign({ text }, dataProps)
);
const labelPosition = Helpers.evaluateProp(
calculatedValues.labelPosition,
assign({ text }, dataProps)
);
const labelStyle = assign({ padding: 0 }, style.labels);
const evaluatedStyle = Helpers.evaluateStyle(
labelStyle,
assign({ labelRadius, text }, dataProps)
);
const labelArc = getLabelArc(defaultRadius, labelRadius, evaluatedStyle);
const position = getLabelPosition(labelArc, slice, labelPosition);
const orientation = getLabelOrientation(slice);
return {
width,
height,
index,
datum,
data,
slice,
orientation,
text,
style: labelStyle,
renderVictoryLabel(props) {
const style = Helpers.evaluateStyle(defaults({}, props.style), props.data, {padding: 0});
const events = Helpers.getPartialEvents(this.props.events, 0, this.props);
return (
);
}
renderLabelComponent(props) {
const component = props.label;
const baseStyle = defaults({}, component.props.style, props.style, {padding: 0});
const style = Helpers.evaluateStyle(baseStyle, props.data);
const baseEvents = component && component.props.events ?
defaults({}, component.props.events, props.events) : props.events;
const events = Helpers.getPartialEvents(baseEvents, 0, props);
const newProps = {
x: component.props.x || props.position.x + style.padding,
y: component.props.y || props.position.y - style.padding,
data: props.data,
text: component.props.text,
textAnchor: component.props.textAnchor || "start",
verticalAnchor: component.props.verticalAnchor || "middle",
style,
events
};
return React.cloneElement(component, newProps);
}
active,
role,
shapeRendering,
className,
events,
x,
y,
transform,
pathComponent,
clipPathComponent,
groupComponent,
circleComponent,
id
} = this.props;
const voronoiPath = this.getVoronoiPath(this.props);
const style = Helpers.evaluateStyle(this.props.style, datum, active);
const size = Helpers.evaluateProp(this.props.size, datum, active);
if (size) {
const circle = React.cloneElement(circleComponent, {
key: `${id}-circle-clip`,
style,
className,
role,
shapeRendering,
events,
clipPath: `url(#${this.clipId})`,
cx: x,
cy: y,
r: size
});
const voronoiClipPath = React.cloneElement(
renderHandles(props) {
const { handleComponent, handleStyle, id, brushDomain, datum = {}, activeBrushes = {} } = props;
if (!brushDomain) {
return null;
}
const handleDimensions = this.getHandleDimensions(props);
const style = assign({}, fallbackProps.handleStyle, handleStyle);
const minDatum = assign({ handleValue: Collection.getMinValue(brushDomain) }, datum);
const maxDatum = assign({ handleValue: Collection.getMaxValue(brushDomain) }, datum);
const minHandleProps = assign(
{
key: `${id}-min`,
style: Helpers.evaluateStyle(style, minDatum, activeBrushes.minHandle)
},
handleDimensions.min
);
const maxHandleProps = assign(
{
key: `${id}-max`,
style: Helpers.evaluateStyle(style, maxDatum, activeBrushes.maxHandle)
},
handleDimensions.max
);
return [
React.cloneElement(handleComponent, minHandleProps),
React.cloneElement(handleComponent, maxHandleProps)
];
}
renderLabel(props) {
if (props.showLabels === false || !props.datum.label) {
return undefined;
}
const component = props.labelComponent;
const componentStyle = component && component.props.style || {};
const baseStyle = defaults({}, componentStyle, props.style);
const labelStyle = Helpers.evaluateStyle(baseStyle, props.datum);
const labelText = component && component.props.text || props.datum.label;
const baseEvents = component && component.props.events ?
defaults({}, component.props.events, props.events) : props.events;
const events = Helpers.getPartialEvents(baseEvents, props.index, props);
const labelProps = {
x: component && component.props.x || props.position.x,
y: component && component.props.y || props.position.y - labelStyle.padding,
dy: component && component.props.dy,
datum: props.datum,
text: labelText,
textAnchor: component && component.props.textAnchor || labelStyle.textAnchor,
verticalAnchor: component && component.props.verticalAnchor || "end",
style: labelStyle,
events
};
getStyles(props) {
const theme = props.theme || VictoryTheme.grayscale;
const defaultLabelStyles =
theme && theme.tooltip && theme.tooltip.style ? theme.tooltip.style : {};
const baseLabelStyle = Array.isArray(props.style)
? props.style.map((s) => defaults({}, s, defaultLabelStyles))
: defaults({}, props.style, defaultLabelStyles);
const defaultFlyoutStyles =
theme && theme.tooltip && theme.tooltip.flyoutStyle ? theme.tooltip.flyoutStyle : {};
const baseFlyoutStyle = props.flyoutStyle
? defaults({}, props.flyoutStyle, defaultFlyoutStyles)
: defaultFlyoutStyles;
const style = Array.isArray(baseLabelStyle)
? baseLabelStyle.map((s) => Helpers.evaluateStyle(s, props))
: Helpers.evaluateStyle(baseLabelStyle, props);
const flyoutStyle = Helpers.evaluateStyle(baseFlyoutStyle, assign({}, props, { style }));
return { style, flyoutStyle };
}