+
+
+
+
+
+
+ )
+}
+
+function createDataset() {
+ const colors = ['#f6cf65', '#FF9C97', '#6b93bd', '#95CFB7', '#D4838F', '#C9B180']
+ const iconsAndLabels = [
+ {
+ label: 'Pictogram_3x3-Basketball_Filled_Black_RGB',
+ icon: 'https://og-icons.ocsddna.net/icons/countries/large/BRA.png',
+ },
+ {
+ label: 'Pictogram_Gymnastics-Artistic_Outlined_White_RGB',
+ icon: 'https://og-icons.ocsddna.net/icons/countries/large/ITA.png',
+ },
+ {
+ label: 'Afghanistan',
+ icon: 'https://og-icons.ocsddna.net/icons/disciplines/VVO_filled_black.png',
+ },
+ {
+ label: 'Argentina',
+ icon: 'https://og-icons.ocsddna.net/icons/disciplines/TEN_filled_black.png',
+ },
+ {
+ label: 'Australia',
+ icon: 'https://og-icons.ocsddna.net/icons/disciplines/VVO_filled_black.png',
+ },
+ {
+ label: 'Italy',
+ icon: 'https://og-icons.ocsddna.net/icons/disciplines/VVO_filled_black.png',
+ },
+ ]
+
+ const casuallySortedColors = _.shuffle(colors)
+ const casuallySortedIconsAndLabels = _.shuffle(iconsAndLabels)
+
+ return colors.map((_colorHex, i) => {
+ const iconAndLabel = casuallySortedIconsAndLabels[i]
+ const color = casuallySortedColors[i]
+
+ return {
+ label: i.toString(),
+ icon: iconAndLabel.icon,
+ color,
+ value: _.random(0, 100),
+ } as Datum
+ })
+}
+
+function getIconHref(icon: string) {
+ return icon
+}
diff --git a/src/components/AnimatedDataset.js b/src/components/AnimatedDataset.js
index 6a615aa..379db2d 100644
--- a/src/components/AnimatedDataset.js
+++ b/src/components/AnimatedDataset.js
@@ -55,6 +55,7 @@ export function AnimatedDataset({
delay = 0,
tweens: unparsedTweens = {},
disableAnimation = false,
+ disableAnimationByAttr: unparseDisableAnimationByAttr = {},
easing = DEFAULT_EASE,
}) {
const ref = React.createRef()
@@ -67,6 +68,10 @@ export function AnimatedDataset({
const init = mapKeys(unparsedInit, parseAttributeName)
const events = mapKeys(unparsedEvents, parseEventName)
const tweens = mapKeys(unparsedTweens, parseAttributeName)
+ const disableAnimationByAttr = mapKeys(
+ unparseDisableAnimationByAttr,
+ parseAttributeName
+ )
const attrsList = Object.keys(attrs).filter((a) => a !== 'text')
const tweensList = Object.keys(tweens).filter((a) => a !== 'text')
@@ -79,8 +84,8 @@ export function AnimatedDataset({
.selectAll(tag)
.data(dataset, keyFn)
.join(
- (enter) =>
- enter
+ (enter) => {
+ return enter
.append(tag)
.text(attrs.text)
.call((sel) => {
@@ -94,26 +99,30 @@ export function AnimatedDataset({
})
})
.call((sel) => {
- const tran = disableAnimation
- ? sel
- : sel
- .transition()
- .ease(easing)
- .delay(delay)
- .duration(duration)
-
attrsList.forEach((a) => {
+ const shouldDisableAnimation =
+ disableAnimationByAttr.hasOwnProperty(a)
+ ? disableAnimationByAttr[a]
+ : disableAnimation
+
+ const tran = shouldDisableAnimation
+ ? sel
+ : sel
+ .transition(a)
+ .ease(easing)
+ .delay(delay)
+ .duration(duration)
+ .textTween(tweens.text)
tran.attr(a, attrs[a])
})
tweensList.forEach((a) => {
tran.attrTween(a, tweens[a])
})
-
- tran.textTween(tweens.text)
- }),
- (update) =>
- update
+ })
+ },
+ (update) => {
+ return update
.text(attrs.text)
.call((sel) => {
eventsList.forEach((event) => {
@@ -121,42 +130,51 @@ export function AnimatedDataset({
})
})
.call((sel) => {
- const tran = disableAnimation
- ? sel
- : sel
- .transition()
- .ease(easing)
- .delay(delay)
- .duration(duration)
-
attrsList.forEach((a) => {
+ const shouldDisableAnimation =
+ disableAnimationByAttr.hasOwnProperty(a)
+ ? disableAnimationByAttr[a]
+ : disableAnimation
+ const tran = shouldDisableAnimation
+ ? sel
+ : sel
+ .transition(a)
+ .ease(easing)
+ .delay(delay)
+ .duration(duration)
+ .textTween(tweens.text)
tran.attr(a, attrs[a])
})
tweensList.forEach((a) => {
tran.attrTween(a, tweens[a])
})
-
- tran.textTween(tweens.text)
- }),
- (exit) =>
- exit.call((sel) => {
- const tran = disableAnimation
- ? sel
- : sel.transition().ease(easing).delay(delay).duration(duration)
-
+ })
+ },
+ (exit) => {
+ return exit.call((sel) => {
oldAttrsList.forEach((a) => {
- tran.attr(a, fallback(init[a], oldAttrs[a]))
+ const shouldDisableAnimation =
+ disableAnimationByAttr.hasOwnProperty(a)
+ ? disableAnimationByAttr[a]
+ : disableAnimation
+ const tran = shouldDisableAnimation
+ ? sel
+ : sel
+ .transition(a)
+ .ease(easing)
+ .delay(delay)
+ .duration(duration)
+ .attr(a, fallback(init[a], oldAttrs[a]))
+ .textTween(tweens.text)
+ tran.remove()
})
tweensList.forEach((a) => {
tran.attrTween(a, tweens[a])
})
-
- tran.textTween(tweens.text)
-
- tran.remove()
})
+ }
)
refOldAttrs.current = attrs
}
diff --git a/src/components/Elements.tsx b/src/components/Elements.tsx
index 3179e82..6b41733 100644
--- a/src/components/Elements.tsx
+++ b/src/components/Elements.tsx
@@ -31,6 +31,8 @@ export interface ElementsProps