Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: packages/charted/examples/selection/transitions_demo.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://developers.google.com/open-source/licenses/bsd
7 */
8 library charted.demos.transitions;
9
10 import 'package:charted/charted.dart';
11
12 void main() {
13 SelectionScope scope = new SelectionScope.selector('.wrapper');
14
15
16 Selection svg = scope.append('svg:svg')
17 ..style('width', '4000px')
18 ..style('height', '4000px');
19
20 Selection g1 = svg.append('g');
21 g1.attr('transform', 'translate(30, 30)');
22
23 SvgLine line = new SvgLine();
24
25 List lineData = [
26 [ [0, 10], [400, 10] ],
27 [ [0, 50], [400, 50] ],
28 [ [0, 90], [400, 90] ],
29 [ [0, 130], [400, 130] ]
30 ];
31 DataSelection lines = g1.selectAll('.line').data(lineData);
32
33 lines.enter.append('path');
34 lines
35 ..attrWithCallback('d', (d, i, e) => line.path(d, i, e))
36 ..classed('line');
37 lines.exit.remove();
38
39
40 var text1 = g1.append('text');
41 text1..attr('x', 0)
42 ..attr('y', 0)
43 ..text('Transition cubic-in-out');
44 var text2 = g1.append('text');
45 text2..attr('x', 0)
46 ..attr('y', 40)
47 ..text('Transition cubic-in');
48 var text3 = g1.append('text');
49 text3..attr('x', 0)
50 ..attr('y', 80)
51 ..text('Transition cubic-out');
52 var text4 = g1.append('text');
53 text4..attr('x', 0)
54 ..attr('y', 120)
55 ..text('Transition cubic-out-in');
56
57 var circle = g1.append('circle');
58 circle
59 ..attr('cx', 0)
60 ..attr('cy', 10)
61 ..attr('r', 4)
62 ..classed('circle');
63
64 // Doing transition for first circle with sub transition selection.
65 Transition t1 = new Transition(g1);
66 t1.duration(4000);
67 t1.select('.circle').attr('cx', 400);
68
69 var circle2 = g1.append('circle');
70 circle2
71 ..attr('cx', 0)
72 ..attr('cy', 50)
73 ..attr('r', 4);
74
75 Transition t2 = new Transition(circle2);
76 t2
77 ..ease = clampEasingFn(identityFunction(easeCubic()))
78 ..attr('cx', 400)
79 ..duration(4000);
80
81 var circle3 = g1.append('circle');
82 circle3
83 ..attr('cx', 0)
84 ..attr('cy', 90)
85 ..attr('r', 4);
86
87 Transition t3 = new Transition(circle3);
88 t3
89 ..ease = clampEasingFn(reverseEasingFn(easeCubic()))
90 ..attr('cx', 400)
91 ..duration(4000);
92
93 var circle4 = g1.append('circle');
94 circle4
95 ..attr('cx', 0)
96 ..attr('cy', 130)
97 ..attr('r', 4);
98
99 Transition t4 = new Transition(circle4);
100 t4
101 ..ease = clampEasingFn(reflectReverseEasingFn(easeCubic()))
102 ..attr('cx', 400)
103 ..duration(4000);
104
105
106 Color dotColor1 = new Color.fromRgba(10, 255, 0, 1.0);
107 Color dotColor2 = new Color.fromRgba(40, 0, 255, 1.0);
108 String shape1 = 'M50 100 L50 200 L100 200 Z';
109 String shape2 = 'M900 0 L750 200 L900 200 Z';
110
111 Selection g2 = svg.append('g');
112
113 var text5 = g2.append('text');
114 text5..attr('x', 0)
115 ..attr('y', 0)
116 ..text('Transition shape and color');
117
118 g2.attr('transform', 'translate(30, 200)');
119 g2.attr('width', '1000');
120 g2.attr('height', '400');
121 Selection shape = g2.append('path');
122 shape
123 ..attr('d', shape1)
124 ..attr('fill', dotColor1);
125
126 Transition t5 = new Transition(shape);
127 t5.duration(4000);
128 t5.attr('d', shape2);
129 t5.attr('fill', dotColor2);
130
131 Selection g3 = svg.append('g');
132 var text6 = g3.append('text');
133 text6..attr('x', 0)
134 ..attr('y', 0)
135 ..text('Transition delay');
136
137 g3.attr('transform', 'translate(30, 450)');
138 g3.attr('width', '1000');
139 g3.attr('height', '1000');
140
141 Selection rect = g3.append('rect');
142 rect
143 ..attr('x', 0)
144 ..attr('y', 10)
145 ..attr('width', 40)
146 ..attr('height', 40)
147 ..attr('fill', '#FF0000');
148
149 Transition t6 = new Transition(rect);
150 t6.duration(4000);
151 t6.delay(4000);
152 t6.attr('x', 400);
153 t6.attr('fill', '#00FF00');
154
155 var t7 = t6.transition();
156 t7.attr('y', 400);
157 t7.attr('fill', '#0000FF');
158
159 var t8 = t7.transition();
160 t8.attr('x', 0);
161 t8.attr('fill', '#FF00FF');
162
163 var t9 = t8.transition();
164 t9.attr('y', 10);
165 t9.attr('fill', '#FF0000');
166
167 Selection g4 = svg.append('g');
168 DataSelection bars =
169 g4.selectAll('bar').data([120, 160, 210, 260]);
170 g4.attr('transform', 'translate(30, 850)');
171 bars.enter.append('rect');
172 bars
173 ..attrWithCallback('x', (d,i,e) => i * 150)
174 ..attr('y', 350)
175 ..attr('width', 100)
176 ..attr('height', 0)
177 ..style('fill', '#6699FF');
178 bars.exit.remove();
179
180 var t = bars.transition();
181 t.duration(1000);
182 t.delayWithCallback((d, i, c) => i * 200);
183 t.attrTween('y', (d, i, attr) => createStringInterpolator(
184 attr, (350 - d).toString()));
185 t.attrTween('height', (d, i, attr) => createStringInterpolator(attr, d.toStrin g()));
186
187 var color = t.transition();
188 color.delayWithCallback((d, i, c) => i * 200);
189 color.styleTween('fill',
190 (d, i, style) => createStringInterpolator(style, '#CC0088'));
191
192 Color hslColor1 = new Color.fromRgba(10, 255, 0, 1.0);
193 Color hslColor2 = new Color.fromRgba(40, 0, 255, 1.0);
194 Selection g5 = svg.append('g');
195 var text7 = g5.append('text');
196 text7..attr('x', 0)
197 ..attr('y', 0)
198 ..text('HSL Color Transition with Transform');
199
200 g5.attr('transform', 'translate(30, 1300)');
201
202 Selection rect2 = g5.append('rect');
203 rect2
204 ..attr('x', 0)
205 ..attr('y', 10)
206 ..attr('width', 200)
207 ..attr('height', 60);
208 rect2.transition()
209 ..attrTween('fill', (d, i, e) {
210 return createHslColorInterpolator(hslColor1, hslColor2);})
211 ..duration(2000);
212
213 rect2.transition()
214 ..attrTween('transform', (d, i, e) => createTransformInterpolator(
215 "translate(10,10)rotate(30)skewX(0.5)scale(1,1)",
216 "translate(100,100)rotate(360)skewX(45)scale(3,3)"))
217 ..duration(5000);
218 }
219
OLDNEW
« no previous file with comments | « packages/charted/examples/layout/treemap_demo.html ('k') | packages/charted/examples/selection/transitions_demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698