-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial.html
1172 lines (1090 loc) · 48.7 KB
/
tutorial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<title>Canis</title>
<meta charset="utf-8">
<link rel='icon' href='logo.ico' type='image/x-icon' />
<script type='text/javascript' src='js/jquery-3.3.1.min.js'></script>
<link rel="stylesheet" type="text/css" href="style/main.css" />
<link rel="stylesheet" type="text/css" href="style/page-style/tutorial.css" />
</head>
<body>
<div id='backTop' class='back-top' onclick='toTop()'>
<i></i>
</div>
<header>
<img class='logo' src='./img/logo.png' />
<div class='menu-container'>
<ul class='menu'>
<li><a href='index.html'>HOME</a></li>
<li><a href='gallery.html'>GALLERY</a></li>
<li class='active-item'><a href='#'>DOCUMENTATION</a></li>
<li><a href='about.html'>ABOUT</a></li>
</ul>
</div>
</header>
<div class='container'>
<div class='center-page'>
<aside class='sidebar-container'>
<ul class='sidebar-nav'>
<li class='sidebar-nav-item'>
<a id='overviewLink' href='#'>Overview</a>
</li>
<li class='sidebar-nav-item'>
<a id='anichartLink' href='#'>Canis</a>
</li>
<li class='sidebar-nav-item'>
<a id='chartLevelLink' href='#'>Chart-Level Spec</a>
</li>
<ul class='sub-nav'>
<li class='sidebar-nav-item sub-nav-item'>
<a id='chartLink' href='#'>Chart</a>
</li>
<li class='sidebar-nav-item sub-nav-item'>
<a id='facetLink' href='#'>Facet</a>
</li>
<li class='sidebar-nav-item sub-nav-item'>
<a id='animationLink' href='#'>Animation</a>
</li>
</ul>
<li class='sidebar-nav-item'>
<a id='markLevelLink' href='#'>Mark-Level Spec</a>
</li>
<ul class='sub-nav'>
<li class='sidebar-nav-item sub-nav-item'>
<a id='selectionLink' href='#'>Selection</a>
</li>
<li class='sidebar-nav-item sub-nav-item'>
<a id='groupingLink' href='#'>Grouping</a>
</li>
<li class='sidebar-nav-item sub-nav-item'>
<a id='actionLink' href='#'>Action</a>
</li>
</ul>
<li class='sidebar-nav-item'>
<a id='webAppLink' href='#'>Web Application</a>
</li>
<li class='sidebar-nav-item'>
<a href='./marker/index.html'>data-enriched SVG</a>
</li>
</ul>
</aside>
<section class='main-content'>
<!-- Overview -->
<h1 id='overview'>Overview</h1>
<p>Canis is a high-level grammar for animations. It provides an easy-understanding JSON syntax, and
generates multi-view animations of the given visualization charts to support storytelling or
analysis. Canis can describe and create animations in a declarative format. To use Canis, our
compiler compiles the specification into a corresponding relation between time and visual attributes
of the graphical marks in charts. Then it generates Lottie JSON file to enable rendering natively on
iOS, Windows, and Web.</p>
<p>This document describes the syntax of Canis and how to use it in web applications.</p>
<!-- Canis -->
<h1 id='anichart'>Canis</h1>
<p>Canis specification is a JSON object that describes a diverse range of animations of the given
visualization charts.</p>
<p>The specification has three parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>charts</td>
<td>Array</td>
<td>
<p><em>Required</em>. An array of <a id='chartLink1' href='#'>chart</a> objects that
describes the input
visualization charts
used to
generate animations..
</p>
</td>
</tr>
<tr>
<td>facet</td>
<td>Object</td>
<td>
<p>An <a id='facetLink1' href='#'>facet</a> object to create multiple animation views
and
describes charts belong
to
each view.
</p>
</td>
</tr>
<tr>
<td>animations</td>
<td>Array</td>
<td>
<p>An array of <a id='animationLink1' href='#'>animation</a> objects
</p>
</td>
</tr>
</tbody>
</table>
<pre>
<code>
<span class='hl-comment'>//Top-level View Specification</span>
{
<span class='hl-str'>"charts"</span> : [...],
<span class='hl-str'>"facet"</span> : ...,
<span class='hl-str'>"animations"</span> : [...]
}</code>
</pre>
<!-- Charts -->
<h1 id='chart-level'>Chart-Level Spec</h1>
<p>Specificaitons that describe the sources, grouping according to facet views, and animations of the
input visualization charts.</p>
<h2 id='chart'>Chart Object</h2>
<p>A <code>chart</code> object describes one input
visualization chart used to
generate animations.</p>
<p>For example, import a line chart.</p>
<pre>
<code>
{
<span class='hl-str'>"source"</span> : "./lineChart.dsvg"
}</code>
</pre>
<p>A <code>chart</code> object can contain the following properties:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>String</td>
<td>
<p>Pick an id for the visualization chart given by <code>source</code> property.
</p>
</td>
</tr>
<tr>
<td>source</td>
<td>String</td>
<td>
<p><em>Required</em>. Fetches the visualization chart file at the specified input
URL
</p>
</td>
</tr>
<tr>
<td>start</td>
<td>Number</td>
<td>
<p>Start index of the input files</p>
</td>
</tr>
<tr>
<td>end</td>
<td>Number</td>
<td>
<p>End index of the input files</p>
</td>
</tr>
</tbody>
</table>
<p>For example, we can pick an id for the chart (form lineChart0.dsvg to lineChart10.dsvg).</p>
<pre>
<code>
{
<span class='hl-str'>"id"</span> : "lineChart",
<span class='hl-str'>"source"</span> : "./lineChart.dsvg"
}</code>
</pre>
<p>Or, we can import a series of charts.</p>
<pre>
<code>
{
<span class='hl-str'>"source"</span> : "./lineChart",
<span class='hl-str'>"start"</span> : 0,
<span class='hl-str'>"end"</span> : 10
}</code>
</pre>
<pre>
<code>
<span class='hl-comment'>//Top-level View Specification</span>
{
<span class='hl-str'>"charts"</span> : [
{...},
...
],
...
}</code>
</pre>
<!-- Facet -->
<h2 id='facet'>Facet Object</h2>
<p>The <code>facet</code> object facets views for multi-view animation. We can then specify
charts
for each view to generate animations.</p>
<div class='example'>
<div class='example-image'>
<img src='img/facet-exmp.png' />
</div>
<pre class='example-code'>
<code>
{
<span class='hl-str'>"charts"</span> : [
{
<span class='hl-str'>"id"</span> : "lineChart1",
<span class='hl-str'>"source"</span> : "./lineChart1.dsvg"
},
{
<span class='hl-str'>"id"</span> : "lineChart2",
<span class='hl-str'>"source"</span> : "./lineChart2.dsvg"
}
],
<span class='hl-str'>"facet"</span> : {
<span class='hl-str'>"type"</span> : "column",
<span class='hl-str'>"views"</span> : [
{"frames": ["lineChart1"]},
{"frames":["lineChart2"]}
]
},
...
}
</code>
</pre>
</div>
<p>A <code>facet</code> object can contain the following properties:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td>String</td>
<td>
<p>How to layout the views. One of <code>row</code> or <code>column</code>.
</p>
<p><strong>Default</strong> value is <code>column</code>.</p>
</td>
</tr>
<tr>
<td>views</td>
<td>Array</td>
<td>
<p>An array of view objects specifying which charts belong to each view. Each object can
have either of the following attributes: <code>frames</code> or <code>range</code>,
<code>frames</code> is an array of chart ids and <code>range</code> is a pair of
chart indexs.
</p>
</td>
</tr>
</tbody>
</table>
<pre>
<code>
<span class='hl-comment'>//Top-level View Specification</span>
{
<span class='hl-str'>"charts"</span> : [...],
<span class='hl-str'>"facet"</span> : {...},
...
}</code>
</pre>
<!-- Animation -->
<h2 id='animation'>Animation Object</h2>
<p>An <code>Animation</code> object describes the animations of charts. It selects marks from the chart
by <code>selection</code>, animations described by this animation object will be bind to those
marks. <code>grouping</code> decides the minimum unit during animaiton (marks that animate
together), and their timing relations. And <code>actions</code> specify animation parameters like
type of animation, duration of the animation of each unit, and so on.</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>offset</td>
<td>Number or Object</td>
<td>
<p>The offset time before this animation. One of: 1) number indicates time in <i>ms</i>
or
2) <a id='offsetLink2' href='#'>offset</a> object.</p>
</td>
</tr>
<tr>
<td>reference</td>
<td>String</td>
<td>
<p>Specify the order of this animation. One of
<code>start with previous</code> or <code>start after previous</code>.</p>
<p><strong>Default</strong> value is <code>start with previous</code>.</p>
</td>
</tr>
<tr>
<td>selection</td>
<td>String</td>
<td>
<p><em>Required</em>. Selectors to select marks from the chart.
</p>
</td>
</tr>
<tr>
<td>grouping</td>
<td>Object</td>
<td>
<p>A <a id='groupingLink2' href='#'>grouping</a> object that decides the minimum unit
during
animtion.
</p>
</td>
</tr>
<tr>
<td>actions</td>
<td>Array</td>
<td>
<p>An array of <a id='actionLink1' href='#'>action</a> objects that sepcifies animations
parameters like
type of animation, duration of the animation of each unit, and so on.
</p>
</td>
</tr>
</tbody>
</table>
<pre>
<code>
<span class='hl-comment'>//Top-level View Specification</span>
{
<span class='hl-str'>"charts"</span> : [...],
<span class='hl-str'>"facet"</span> : {...},
<span class='hl-str'>"animations"</span> : [
{...},
...
]
}</code>
</pre>
<h1 id='mark-level'>Mark-Level Spec</h1>
<p>These are the parameters of the <code>animation</code> object.</p>
<!-- selection -->
<h2 id='selection'>Selection</h2>
<p>Borrowing form CSS 1-3, Canis provides a set of tools for matching marks in given charts. The W3C
CSS specification contains the <a
href='https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier'>complete set of rules
regarding valid CSS selectors</a>.</p>
<pre class='example-code'>
<code>
{
<span class='hl-str'>"selection"</span> : ".dot",<span class='hl-comment'>//select marks with the class name as "dot".</span>
...
}</code>
</pre>
<p>Here we list some of the commonly used selectors:</p>
<ul>
<li>
<p class='hl-selector'>Class Selector (".class")</p>
<p>Select all marks which have the given class name.</p>
</li>
<li>
<p class='hl-selector'>ID Selector ("#id")</p>
<p>Select the mark the given id.</p>
</li>
<li>
<p class='hl-selector'>All Selector ("*")</p>
<p>Select all the marks.</p>
</li>
<li>
<p class='hl-selector'>Element Selector ("tag")</p>
<p>Select all marks which have the given tag name.</p>
</li>
<li>
<p class='hl-selector'>Attribute Equals Selector ([name="value"])</p>
<p>Select all marks whose values of the given attribute are equal to a certain given value.</p>
</li>
<li>
<p class='hl-selector'>Multiple Selector ("selector1, selector2, selectorN")</p>
<p>Select all marks with all the specified selectors.</p>
</li>
</ul>
<!-- grouping -->
<h2 id='grouping'>Grouping Object</h2>
<p>A <code>grouping</code> object groups the selected marks by attributes of the data they encoded in a
hierarchical manner. Each group is a minimum animation unit, and marks within the same unit will be
animated together. The timing relationships between units like animation order, delay are also
specified.</p>
<div class='example'>
<div class='example-image'>
<img src='img/grouping-exmp.png' />
</div>
<pre class='example-code'>
<code>
{
<span class='hl-str'>"selection"</span> : ".dot",<span class='hl-comment'>//all marks are selected.</span>
<span class='hl-comment'>//the following code groups dots into cells as shown in the figure.</span>
<span class='hl-str'>"grouping"</span> : {
<span class='hl-str'>"groupBy"</span> : "Odor",<span class='hl-comment'>//all dots will be grouped into columns.</span>
<span class='hl-str'>"reference"</span> : "previousEnd",<span class='hl-comment'>//animate column after column.</span>
<span class='hl-str'>"grouping"</span> : {
<span class='hl-str'>"groupBy"</span> : "Surface",<span class='hl-comment'>//dots in each column are further grouped into rows.</span>
<span class='hl-str'>"reference"</span> : "previousEnd",<span class='hl-comment'>//animate row after row.</span>
}
},
...
}
</code>
</pre>
</div>
<p>A <code>grouping</code> object can contain the following parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>groupBy</td>
<td>String</td>
<td>
<p>Categorical data attributes or <code>id</code>.</p>
<p><strong>Default</strong> value is <code>id</code>.</p>
</p>
</td>
</tr>
<tr>
<td>reference</td>
<td>String</td>
<td>
<p>Specify the aniamtion order of the resulted groups. One of
<code>start with previous</code> or <code>start after previous</code>.</p>
<p><strong>Default</strong> value is <code>start with previous</code>.</p>
</td>
</tr>
<tr>
<td>delay</td>
<td>Number</td>
<td>
<p>Time delays between groups.</p>
</td>
</tr>
<tr>
<td>sort</td>
<td>Object</td>
<td>
<p>A <a id='sortLink' href='#'>sort</a> object that specifies the animation order of the
resulted
groups.
</p>
</td>
</tr>
<tr>
<td>grouping</td>
<td>Object</td>
<td>
<p>A nested <a id='groupingLink1' href='#'>grouping</a> object that specifies the
further grouping of the
resulted groups.</p>
</td>
</tr>
</tbody>
</table>
<pre>
<code>
<span class='hl-comment'>//Top-level View Specification</span>
{
<span class='hl-str'>"charts"</span> : [...],
<span class='hl-str'>"facet"</span> : {...},
<span class='hl-str'>"animations"</span> : [
{
<span class='hl-str'>"selection"</span> : ...,
<span class='hl-str'>"grouping"</span> : {...},
...
},
...
]
}</code>
</pre>
<h3 id='sort'>Sort Object</h3>
<p>A <code>sort</code> object specifies the animation order of the mark groups.</p>
<pre>
<code>
<span class='hl-comment'>//groups will be animated with their value of "attr" in ascending order</span>
{
<span class='hl-str'>"field"</span> : "attr",
<span class='hl-str'>"order"</span> : "ascending"
}</code>
</pre>
<p>A <code>sort</code> object can contian the following parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>String</td>
<td>
<p>Data attributes or <code>id</code></p>
</td>
</tr>
<tr>
<td>order</td>
<td>String or Array</td>
<td>
<p>Specify the order of the values of the attribute selected in <code>field</code>. One
of: 1) <code>ascending</code>, 2) <code>descending</code>, or 3) an array of the
values of this attribute.</p>
<p><strong>Default</strong> value is <code>ascending</code>.</p>
</td>
</tr>
</tbody>
</table>
<h2 id='action'>Action Object</h2>
<p>An <code>animation</code> can have multiple actions. For example the marks can wipe in from bottom
while they wipe
in from left. An <code>action</code> object describe parameters of one action, including type,
easing, duration, order, and timing offset of the action.</p>
<pre>
<code>
{
<span class='hl-str'>"type"</span> : "fade",
<span class='hl-str'>"easing"</span> : "easeOutBounce",
<span class='hl-str'>"duration"</span> : 1000<span class='hl-comment'>//ms</span>
}</code>
</pre>
<p>An <code>action</code> can contain the following parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td>String</td>
<td>
<p><em>Required</em>. Type of the action. One of <code>appear</code>, <code>fade</code>,
<code>wipe bottom</code>, <code>wipe top</code>, <code>wipe left</code>,
<code>wipe right</code>, <code>wheel</code>, <code>circle</code>, <code>grow</code>,
<code>custom</code>, <code>fade out</code>, <code>wipe out from left</code>,
<code>wipe out from top</code>, <code>wipe out from right</code>,
<code>wipe out from bottom</code>, <code>wheel out</code>, <code>circle out</code>,
<code>degrow</code>, <code>magic move</code>.</p>
</td>
</tr>
<tr>
<td>offset</td>
<td>Number or Object</td>
<td>
<p>The offset time before this action. One of: 1) number indicates time in <i>ms</i> or
2) <a id='offsetLink1' href='#'>offset</a> object.</p>
</td>
</tr>
<tr>
<td>reference</td>
<td>String</td>
<td>
<p>Specify the order of this action. One of
<code>start with previous</code> or <code>start after previous</code>.</p>
<p><strong>Default</strong> value is <code>start with previous</code>.</p>
</td>
</tr>
<tr>
<td>easing</td>
<td>String</td>
<td>
<p>Specify the easing function. One of <code>easeLinear</code>, <code>easeInQuad</code>,
<code>easeOutQuad</code>, <code>easeInOutQuad</code>, <code>easeInCubic</code>,
<code>easeOutCubic</code>, <code>easeInOutCubic</code>, <code>easeOutBounce</code>.
</p>
<p><strong>Default</strong> value is <code>easeLinear</code>.</p>
</td>
</tr>
<tr>
<td>duration</td>
<td>Number or Object</td>
<td>
<p>The duration time of this action. One of: 1) number indicates time in <i>ms</i> or 2)
<a id='durationLink' href='#'>duration</a>
object.</p>
</td>
</tr>
<tr>
<td>attribute</td>
<td>Object</td>
<td>
<p>When choosing <code>custom</code> type, we can select a specific visual attribute and
specify its status changing to create custom animations with an
<a id='attributeLink' href='#'>attribute</a> object.</p>
</td>
</tr>
</tbody>
</table>
<p>For example we can animate marks with the same duration:</p>
<div class='example'>
<div class='example-image'>
<img style='height:155px;' src='img/sameDuration-exmp.gif' />
</div>
<pre>
<code>
{
<span class='hl-str'>"selection"</span> : ".Shape2",
<span class='hl-str'>"actions"</span> : [
{
<span class='hl-str'>"type"</span> : "wipe bottom",
<span class='hl-str'>"duration"</span> : 1000
}
]
}</code>
</pre>
</div>
<p>Or we can control the animation speed by defining the minimum duration time with <a
id='durationLink1' href='#'>duration</a> object:</p>
<div class='example'>
<div class='example-image'>
<img style='height:197px;' src='img/sameSpeed-exmp.gif' />
</div>
<pre>
<code>
{
<span class='hl-str'>"selection"</span> : ".Shape2",
<span class='hl-str'>"actions"</span> : [
{
<span class='hl-str'>"type"</span> : "wipe bottom",
<span class='hl-str'>"duration"</span> : {
<span class='hl-str'>"field"</span> : "percentage",
<span class='hl-str'>"minDuration"</span> : 300
}
}
]
}</code>
</pre>
</div>
<pre>
<code>
<span class='hl-comment'>//Top-level View Specification</span>
{
<span class='hl-str'>"charts"</span> : [...],
<span class='hl-str'>"facet"</span> : {...},
<span class='hl-str'>"animations"</span> : [
{
<span class='hl-str'>"selection"</span> : ...,
<span class='hl-str'>"grouping"</span> : {...},
<span class='hl-str'>"actions"</span> : [
{...},
...
]
},
...
]
}</code>
</pre>
<!-- offset object -->
<h3 id='offset'>Offset Object</h3>
<p>An <code>offset</code> object defines the offset time of marks according to the values of one of
their data attributes.</p>
<p>For example, marks selected have a data attribute called "attr" with its values ranging from 10 to
100, we define the minimum offset time as 200ms, then the offset time of the mark whose "attr" value
is 10
will be 200ms, and the one whose "attr" value is 100 will be 2,000ms. The example code is shown
below:</p>
<pre>
<code>
{
<span class='hl-str'>"field"</span> : "attr",
<span class='hl-str'>"minOffset"</span> : 200
}</code>
</pre>
<p>An <code>offset</code> object can contian the following parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>String</td>
<td>
<p><em>Required</em>. Data attribute.</p>
</td>
</tr>
<tr>
<td>minOffset</td>
<td>Number</td>
<td>
<p>The offset time of the mark with minimum value of the specified data attribute.</p>
</td>
</tr>
</tbody>
</table>
<!-- duration object -->
<h3 id='duration'>Duration Object</h3>
<p>A <code>duration</code> object defines the duration time of marks according to the values of one of
their data
attributes.</p>
<p>For example, marks selected have a data attribute called "attr" with its values ranging from 10 to
100, we define the
minimum duration as 200ms, then the duration of the mark whose "attr" value is 10 will be 200ms, and
the one whose
"attr" value is 100 will be 2,000ms. The example code is shown below:</p>
<pre>
<code>
{
<span class='hl-str'>"field"</span> : "attr",
<span class='hl-str'>"minDuration"</span> : 200
}</code>
</pre>
<p>A <code>duration</code> object can contian the following parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>field</td>
<td>String</td>
<td>
<p><em>Required</em>. Data attribute.</p>
</td>
</tr>
<tr>
<td>minDuration</td>
<td>Number</td>
<td>
<p>The duration of the mark with minimum value of the specified data attribute.</p>
</td>
</tr>
</tbody>
</table>
<!-- attribute object -->
<h3 id='attribute'>Attribute Object</h3>
<p>An <code>attribute</code> object picks one of the visual parameters and defines the start and end
value of this parameter using percentages.</p>
<pre>
<code>
{
<span class='hl-str'>"attrName"</span> : "attr",
<span class='hl-str'>"from"</span> : 0,
<span class='hl-str'>"to"</span> : 1
}</code>
</pre>
<p>An <code>attribute</code> object can contian the following parameters:</p>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>attrName</td>
<td>String</td>
<td>
<p><em>Required</em>. Data attribute.</p>
</td>
</tr>
<tr>
<td>from</td>
<td>Number</td>
<td>
<p>The start value of the specified data attribute using percentages. Ranging from 0 to
1.</p>
</td>
</tr>
<tr>
<td>to</td>
<td>Number</td>
<td>
<p>The end value of the specified data attribute using percentages. Ranging from 0 to 1.
</p>
</td>
</tr>
</tbody>
</table>
<!-- web Application -->
<h1 id='webapp'>Web Application</h1>
<p>We can use the following snippet to link to the latest release:</p>
<pre>
<code>
<<span class='hl-str'>script</span> src="http://www.njvis.net/CanisWeb/anichart.min.js"></<span class='hl-str'>script</span>>"</code>
</pre>
<p>We can create an animated visualization on the web page using the following code:</p>
<pre>
<code>
<div id='chartContainer'></div>
<div id='videoContainer'></div>
<script>
aniChart.<span class='hl-str'>loadSpec</span>('./specs/line2.ac', (spec) => {
aniChart.<span class='hl-str'>renderSpec</span>(spec);
aniChart.<span class='hl-str'>play</span>();
})
</script></code>
</pre>
<p>Canis provides the following variables and functions to create or customize animations.</p>
<h3>aniChart.loadSpec()</h3>
<p>This function fetches the AC format spec file at the specified input URL and returns the spec as a
JSON object.</p>
<pre>
<code>
aniChart.<span class='hl-str'>loadSpec</span>('./spec.ac', (spec) => {
console.log(spec);
})</code>
</pre>
<h3>aniChart.renderSpec(spec)</h3>
<p>This function renders the animation using the input spec.</p>
<h3>aniChart.play()</h3>
<p>Call this function to play the rendered animation.</p>
<br />
<p>The following functions and variables can be used to create a customized animation player:</p>
<h3>aniChart.frameRate</h3>
<p>This is the frame rate of the animation.</p>
<pre>
<code>
console.log(aniChart.<span class='hl-str'>frameRate</span>);<span class='hl-comment'>//25</span></code>
</pre>
<h3>aniChart.duration()</h3>
<p>This is the duration time of the entire animation.</p>
<pre>
<code>
console.log(aniChart.<span class='hl-str'>duration</span>());<span class='hl-comment'>//1000</span></code>
</pre>
<h3>aniChart.renderFrame(time)</h3>
<p>This returns the visual effects of all the marks at a specific time point.</p>
<pre>
<code>
aniChart.<span class='hl-str'>renderFrame</span>(300);<span class='hl-comment'>//render the frame at 300ms</span></code>
</pre>
<h3>aniChart.reset()</h3>
<p>Reset all status.</p>
<!-- <h1>Charts</h1>
<p>The <code>charts</code> property imports the visualization charts to generate animations.</p>
<h2>test2</h2>
<pre>
<code>
{
<span class='hl-str'>"data"</span>: ... ,
"transform": [
...
],
"mark": ... ,
"encoding": ... ,
...
}
</code>
</pre>
<div class='example'>
<div class='example-image'>
<img src='img/logo.png' />
</div>
<pre class='example-code'>
<code>
{
<span class='hl-str'>"data"</span>: ... ,
"transform": [
...
],
"mark": ... ,
"encoding": ... ,
...
}
</code>
</pre>
</div>
<table class="doc-table">
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
</tr>