-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Geoffrey Hendrey
committed
Nov 16, 2023
1 parent
f1e3243
commit bd564d5
Showing
3 changed files
with
97 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
svgson: "${$fetch('https://raw.githubusercontent.com/geoffhendrey/jsonataplay/main/animateLines.json').json()}" | ||
data: { | ||
bandwidth: { | ||
data:{ | ||
replica1: 2000, | ||
replica2: 500 | ||
} | ||
} | ||
} | ||
computeDurationOfAnimation: "${function($bandwidth){$string(1000/$bandwidth) & 's' }}" #produces '2s' for instance | ||
setLineAnimationDuration: | | ||
${ | ||
function($svg, $lineId, $duration ){ | ||
$svg ~> |$.[children[name='line' | ||
and | ||
attributes[id=$lineId]] | ||
.children[name='animate']] | ||
.attributes | ||
|{'dur':$duration}| /*sets the svg animate tag's 'dur' attribute like dur="0.5s"*/ | ||
} | ||
} | ||
setBandwidthBoxText: | | ||
${ | ||
function($svg, $id, $bw ){ | ||
$svg ~> |$.children[name='text' and attributes[id=$id]] | ||
.children[type='text'].attributes|{'value':$string($bw)&' Mbps'}| /*sets the text inside the box to like 1000 Mps'*/ | ||
} | ||
} | ||
dur1: "${ computeDurationOfAnimation($$.data.bandwidth.data.replica1)}" | ||
dur2: "${ computeDurationOfAnimation($$.data.bandwidth.data.replica2)}" | ||
content: | | ||
${ | ||
svgson | ||
~> setLineAnimationDuration('line1', $$.dur1) | ||
~> setLineAnimationDuration('line2', $$.dur2) | ||
~> setBandwidthBoxText('text1', $$.data.bandwidth.data.replica1) | ||
~> setBandwidthBoxText('text2', $$.data.bandwidth.data.replica2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters