Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
withPropsOnChange(['label', 'labelFormat'], ({ label, labelFormat }) => ({
getLabel: getLabelGenerator(label, labelFormat),
})),
withPropsOnChange(['sort'], ({ sort }) => {
withPropsOnChange(['label', 'labelFormat'], ({ label, labelFormat }) => ({
getLabel: getLabelGenerator(label, labelFormat),
})),
withPropsOnChange(['borderColor', 'theme'], ({ borderColor, theme }) => ({
if (enableRadialLabels === true) {
const {
radialLabel,
radialLabelsSkipAngle,
radialLabelsLinkOffset,
radialLabelsLinkStrokeWidth,
radialLabelsLinkDiagonalLength,
radialLabelsLinkHorizontalLength,
radialLabelsTextXOffset,
radialLabelsTextColor,
radialLabelsLinkColor,
} = props
drawRadialLabels(this.ctx, arcs, {
radius,
getLabel: getLabelGenerator(radialLabel),
skipAngle: radialLabelsSkipAngle,
linkOffset: radialLabelsLinkOffset,
linkDiagonalLength: radialLabelsLinkDiagonalLength,
linkHorizontalLength: radialLabelsLinkHorizontalLength,
linkStrokeWidth: radialLabelsLinkStrokeWidth,
textXOffset: radialLabelsTextXOffset,
getTextColor: getInheritedColorGenerator(radialLabelsTextColor, theme),
getLinkColor: getInheritedColorGenerator(radialLabelsLinkColor, theme),
theme,
})
}
this.ctx.restore()
legends.forEach(legend => {
renderLegendToCanvas(this.ctx, {
symbol,
size,
color,
borderWidth,
borderColor,
enableLabel,
label,
labelFormat,
labelYOffset,
}) => {
const theme = useTheme()
const { animate, springConfig } = useMotionConfig()
const fillColor = getInheritedColorGenerator(color, theme)
const strokeColor = getInheritedColorGenerator(borderColor, theme)
const getLabel = getLabelGenerator(label, labelFormat)
const points = data.reduce((acc, datum, i) => {
const index = getIndex(datum)
keys.forEach(key => {
const pointData = {
index,
key,
value: datum[key],
color: colorByKey[key],
}
acc.push({
key: `${key}.${index}`,
label: enableLabel ? getLabel(pointData) : null,
style: {
fill: fillColor(pointData),
stroke: strokeColor(pointData),
this.ctx.beginPath()
this.ctx.fillStyle = arc.color
this.ctx.strokeStyle = getBorderColor({ ...arc.data, color: arc.color })
this.ctx.lineWidth = borderWidth
arcGenerator(arc)
this.ctx.fill()
if (borderWidth > 0) this.ctx.stroke()
})
if (enableSlicesLabels === true) {
const { sliceLabel, slicesLabelsSkipAngle, slicesLabelsTextColor } = props
drawSliceLabels(this.ctx, arcs, {
arcGenerator,
skipAngle: slicesLabelsSkipAngle,
getLabel: getLabelGenerator(sliceLabel),
getTextColor: getInheritedColorGenerator(slicesLabelsTextColor, theme),
theme,
})
}
if (enableRadialLabels === true) {
const {
radialLabel,
radialLabelsSkipAngle,
radialLabelsLinkOffset,
radialLabelsLinkStrokeWidth,
radialLabelsLinkDiagonalLength,
radialLabelsLinkHorizontalLength,
radialLabelsTextXOffset,
radialLabelsTextColor,
radialLabelsLinkColor,
withPropsOnChange(['sliceLabel'], ({ sliceLabel }) => ({
getSliceLabel: getLabelGenerator(sliceLabel),
})),
pure