UNPKG

react-native-chart-kit

Version:

Beautiful React Native charts for dashboards, reports, and data-rich mobile apps.

27 lines (26 loc) 1.18 kB
export const resolvePieChartActiveSliceConfig = ({ activeSlice, backgroundColor }) => ({ activeOpacity: activeSlice?.activeOpacity ?? 1, inactiveOpacity: activeSlice?.inactiveOpacity ?? 0.62, activeOffset: activeSlice?.activeOffset ?? 5, activeScale: activeSlice?.activeScale ?? 1.025, strokeColor: activeSlice?.strokeColor ?? backgroundColor, strokeWidth: activeSlice?.strokeWidth ?? 0 }); const hasTapInteraction = (interaction) => { if (interaction === "tap") { return true; } if (!interaction || interaction === "none") { return false; } return interaction.mode === undefined || interaction.mode === "tap"; }; export const shouldReservePieChartActiveSliceGutter = ({ props, selectedIndex }) => props.activeSlice !== undefined || selectedIndex !== undefined || props.defaultSelectedIndex !== undefined || props.selectedIndex !== undefined || hasTapInteraction(props.interaction); export const getPieChartActiveSliceGutter = ({ activeSlice, radius }) => Math.ceil(activeSlice.activeOffset + radius * Math.max(0, activeSlice.activeScale - 1) + Math.max(0, activeSlice.strokeWidth) / 2 + 2);