@plotdb/chart 3.7.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle.js CHANGED
@@ -85,7 +85,7 @@ if (typeof chart != 'undefined' && chart !== null) {
85
85
  }
86
86
  var module = {exports: {}};
87
87
  (function(){
88
- var svgns, _np, _nparse, _snum, _isNumeric, _alignDim, _parseSubset, _rgb, bindScope, parent, aniloop, visibilityObserver, resizeObserver, withDefault, defaultConfig, chart;
88
+ var svgns, _np, _nparse, _snum, _isNumeric, _alignDim, _parseSubset, _isDataframe, _isNum, _isDate, _frameList, _rgb, bindScope, parent, aniloop, visibilityObserver, resizeObserver, withDefault, defaultConfig, chart;
89
89
  svgns = "http://www.w3.org/2000/svg";
90
90
  _np = function(lc){
91
91
  var format, parts, numerals, index;
@@ -232,6 +232,75 @@ var module = {exports: {}};
232
232
  });
233
233
  }
234
234
  };
235
+ _isDataframe = function(o){
236
+ return !!(o && !Array.isArray(o) && Array.isArray(o.frames));
237
+ };
238
+ _isNum = function(v){
239
+ return typeof v === 'number' || (typeof v === 'string' && v.trim() && !isNaN(+v));
240
+ };
241
+ _isDate = function(v){
242
+ return v instanceof Date || (typeof v === 'string' && !isNaN(Date.parse(v)));
243
+ };
244
+ _frameList = function(df){
245
+ var list, order, hash, ret, ids, t;
246
+ df == null && (df = {});
247
+ list = (df.frames || []).map(function(f, i){
248
+ return {
249
+ id: f.id != null ? f.id : i,
250
+ raw: f.raw || []
251
+ };
252
+ });
253
+ order = df.frameOrder;
254
+ if (Array.isArray(order) && order.length) {
255
+ hash = {};
256
+ list.map(function(f){
257
+ return hash[f.id + ""] = f;
258
+ });
259
+ ret = order.map(function(it){
260
+ return hash[it + ""];
261
+ }).filter(function(it){
262
+ return it;
263
+ });
264
+ return ret.concat(list.filter(function(it){
265
+ return !in$(it, ret);
266
+ }));
267
+ }
268
+ ids = list.map(function(it){
269
+ return it.id;
270
+ });
271
+ if (ids.length && ids.every(_isNum)) {
272
+ return list.map(function(f, i){
273
+ return {
274
+ f: f,
275
+ i: i
276
+ };
277
+ }).sort(function(a, b){
278
+ return +a.f.id - +b.f.id || a.i - b.i;
279
+ }).map(function(it){
280
+ return it.f;
281
+ });
282
+ }
283
+ if (ids.length && ids.every(_isDate)) {
284
+ t = function(v){
285
+ if (v instanceof Date) {
286
+ return v.getTime();
287
+ } else {
288
+ return Date.parse(v);
289
+ }
290
+ };
291
+ return list.map(function(f, i){
292
+ return {
293
+ f: f,
294
+ i: i
295
+ };
296
+ }).sort(function(a, b){
297
+ return t(a.f.id) - t(b.f.id) || a.i - b.i;
298
+ }).map(function(it){
299
+ return it.f;
300
+ });
301
+ }
302
+ return list;
303
+ };
235
304
  _rgb = function(c){
236
305
  var m, x, v;
237
306
  if (typeof c !== 'string') {
@@ -492,7 +561,7 @@ var module = {exports: {}};
492
561
  return _(cfg);
493
562
  };
494
563
  chart = function(opt){
495
- var name, ref$, tbl, this$ = this;
564
+ var ref$, name, ref1$, tbl, this$ = this;
496
565
  opt == null && (opt = {});
497
566
  this.root = typeof opt.root === 'string'
498
567
  ? document.querySelector(opt.root)
@@ -521,8 +590,19 @@ var module = {exports: {}};
521
590
  this._normalizeBinding();
522
591
  this.evtHandler = {};
523
592
  this._subset = opt.subset || null;
524
- for (name in ref$ = chart.scopes) {
525
- tbl = ref$[name];
593
+ this._frames = null;
594
+ this._player = {
595
+ playing: false,
596
+ pos: 0,
597
+ origin: 0,
598
+ raf: null
599
+ };
600
+ if (_isDataframe(this.raw)) {
601
+ this._setFrames(this.raw);
602
+ this.raw = ((ref$ = this._frames.list[this._frames.index]) != null ? ref$.raw : void 8) || [];
603
+ }
604
+ for (name in ref1$ = chart.scopes) {
605
+ tbl = ref1$[name];
526
606
  if (this[name] != null) {
527
607
  throw new Error("[@plotdb/chart] scope name `" + name + "` is already taken.");
528
608
  }
@@ -535,6 +615,13 @@ var module = {exports: {}};
535
615
  if ((chart.utils || (chart.utils = {})).anim && !(this.anim != null)) {
536
616
  this.anim = new chart.utils.anim();
537
617
  }
618
+ if (this.anim) {
619
+ this.anim.on('step', function(){
620
+ if (this$._player.playing) {
621
+ return this$._playerTick();
622
+ }
623
+ });
624
+ }
538
625
  this.init = proxise.once(function(){
539
626
  return this$._init();
540
627
  });
@@ -708,15 +795,29 @@ var module = {exports: {}};
708
795
  this$.parse();
709
796
  this$.bind();
710
797
  this$.resize();
711
- return this$.render();
798
+ this$.render();
799
+ if (this$._frames) {
800
+ return this$._framesStart();
801
+ }
712
802
  });
713
803
  });
714
804
  },
715
805
  parse: function(){
806
+ this.data = this._parseRows(this.raw);
807
+ if (this._frames) {
808
+ this._frames.all = null;
809
+ }
810
+ _parseSubset.apply(this);
811
+ if (this.mod.parse) {
812
+ return this.mod.parse.apply(this);
813
+ }
814
+ },
815
+ _parseRows: function(rows){
716
816
  var dim, ref$, bind;
817
+ rows == null && (rows = []);
717
818
  dim = (ref$ = this.mod).dimension || (ref$.dimension = {});
718
819
  bind = this.binding;
719
- this.data = this.raw.map(function(r, i){
820
+ return rows.map(function(r, i){
720
821
  var ret, k, ref$, v, b;
721
822
  ret = {};
722
823
  for (k in ref$ = dim) {
@@ -748,10 +849,6 @@ var module = {exports: {}};
748
849
  return _nparse(it);
749
850
  }
750
851
  });
751
- _parseSubset.apply(this);
752
- if (this.mod.parse) {
753
- return this.mod.parse.apply(this);
754
- }
755
852
  },
756
853
  bind: function(){
757
854
  if (this.mod.bind) {
@@ -791,6 +888,7 @@ var module = {exports: {}};
791
888
  if (!this._inited) {
792
889
  return;
793
890
  }
891
+ this._syncAnim();
794
892
  if (this.mod.render) {
795
893
  return this.mod.render.apply(this);
796
894
  }
@@ -808,6 +906,7 @@ var module = {exports: {}};
808
906
  if (this$.layout) {
809
907
  this$.layout.destroy();
810
908
  }
909
+ this$.pause();
811
910
  this$.stop();
812
911
  if (this$.mod.destroy) {
813
912
  return this$.mod.destroy.apply(this$);
@@ -869,12 +968,23 @@ var module = {exports: {}};
869
968
  setRaw: function(raw, binding, reinit){
870
969
  var ref$;
871
970
  reinit == null && (reinit = false);
872
- if (!Array.isArray(raw)) {
873
- if (raw && 'subset' in raw) {
971
+ if (raw && !Array.isArray(raw) && !_isDataframe(raw)) {
972
+ if ('subset' in raw) {
874
973
  this._subset = raw.subset || null;
875
974
  }
876
975
  ref$ = raw, raw = ref$.raw, binding = ref$.binding, reinit = ref$.reinit;
877
976
  }
977
+ if (_isDataframe(raw)) {
978
+ this._setFrames(raw);
979
+ raw = ((ref$ = this._frames.list[this._frames.index]) != null ? ref$.raw : void 8) || [];
980
+ } else if (raw != null && this._frames) {
981
+ this.pause();
982
+ this._frames = null;
983
+ this._player.pos = 0;
984
+ if (this.anim) {
985
+ this.anim.resume();
986
+ }
987
+ }
878
988
  if (raw != null) {
879
989
  this.raw = raw;
880
990
  }
@@ -894,8 +1004,239 @@ var module = {exports: {}};
894
1004
  this.parse();
895
1005
  this.bind();
896
1006
  this.resize();
897
- return this.render();
1007
+ this.render();
1008
+ if (this._frames) {
1009
+ return this._framesStart();
1010
+ }
1011
+ }
1012
+ },
1013
+ _animCfg: function(){
1014
+ return ((this.cfg || {}).common || {}).animation || {};
1015
+ },
1016
+ _syncAnim: function(){
1017
+ var c;
1018
+ if (!this.anim) {
1019
+ return;
1020
+ }
1021
+ c = this._animCfg();
1022
+ if (c.transition != null) {
1023
+ this.anim.duration(c.transition);
898
1024
  }
1025
+ return this.anim.speed(c.speed != null ? c.speed : 1);
1026
+ },
1027
+ _setFrames: function(df){
1028
+ var list, ref$, ref1$;
1029
+ list = _frameList(df);
1030
+ this._frames = {
1031
+ list: list,
1032
+ index: 0,
1033
+ all: null
1034
+ };
1035
+ return this._frames.index = this._frameAt((ref$ = this._player.pos) < (ref1$ = this.duration()) ? ref$ : ref1$);
1036
+ },
1037
+ _interval: function(){
1038
+ return +this._animCfg().interval || 1000;
1039
+ },
1040
+ _clock: function(){
1041
+ if (this.anim) {
1042
+ return this.anim.time();
1043
+ } else {
1044
+ if (typeof performance != 'undefined' && performance !== null) {
1045
+ return performance.now();
1046
+ } else {
1047
+ return Date.now();
1048
+ }
1049
+ }
1050
+ },
1051
+ _frameAt: function(t){
1052
+ var n, ref$, ref1$, ref2$;
1053
+ n = this._frames ? this._frames.list.length : 0;
1054
+ if (!n) {
1055
+ return 0;
1056
+ }
1057
+ return (ref$ = (ref2$ = Math.floor(t / this._interval())) > 0 ? ref2$ : 0) < (ref1$ = n - 1) ? ref$ : ref1$;
1058
+ },
1059
+ _framesStart: function(){
1060
+ this.fire('frame', {
1061
+ index: this._frames.index,
1062
+ id: this.frame.id()
1063
+ });
1064
+ if (this._animCfg().autoplay && !this._player.playing) {
1065
+ return this.play();
1066
+ }
1067
+ },
1068
+ _goto: function(i, late){
1069
+ var f, ref$, ref1$, this$ = this;
1070
+ late == null && (late = 0);
1071
+ f = this._frames;
1072
+ if (!f || !f.list.length) {
1073
+ return;
1074
+ }
1075
+ i = (ref$ = i > 0 ? i : 0) < (ref1$ = f.list.length - 1) ? ref$ : ref1$;
1076
+ f.index = i;
1077
+ this.raw = f.list[i].raw;
1078
+ if (!this._inited) {
1079
+ return;
1080
+ }
1081
+ this.parse();
1082
+ this.bind();
1083
+ this.resize();
1084
+ if (this.anim && late > 0) {
1085
+ this.anim.ago(late, function(){
1086
+ return this$.render();
1087
+ });
1088
+ } else {
1089
+ this.render();
1090
+ }
1091
+ return this.fire('frame', {
1092
+ index: i,
1093
+ id: f.list[i].id
1094
+ });
1095
+ },
1096
+ duration: function(){
1097
+ if (this._frames) {
1098
+ return this._frames.list.length * this._interval();
1099
+ } else {
1100
+ return 0;
1101
+ }
1102
+ },
1103
+ position: function(){
1104
+ var p;
1105
+ p = this._player;
1106
+ if (p.playing) {
1107
+ return this._clock() - p.origin;
1108
+ } else {
1109
+ return p.pos;
1110
+ }
1111
+ },
1112
+ playing: function(){
1113
+ return this._player.playing;
1114
+ },
1115
+ play: function(){
1116
+ var p;
1117
+ p = this._player;
1118
+ if (!this._frames || p.playing || !this._frames.list.length) {
1119
+ return;
1120
+ }
1121
+ if (p.pos >= this.duration()) {
1122
+ p.pos = 0;
1123
+ }
1124
+ this._syncAnim();
1125
+ if (this.anim) {
1126
+ this.anim.resume();
1127
+ }
1128
+ p.origin = this._clock() - p.pos;
1129
+ p.playing = true;
1130
+ this.fire('play');
1131
+ return this._playerLoop();
1132
+ },
1133
+ pause: function(){
1134
+ var p;
1135
+ p = this._player;
1136
+ if (!p.playing) {
1137
+ return;
1138
+ }
1139
+ p.pos = this.position();
1140
+ p.playing = false;
1141
+ if (p.raf) {
1142
+ cancelAnimationFrame(p.raf);
1143
+ }
1144
+ p.raf = null;
1145
+ if (this.anim) {
1146
+ this.anim.pause();
1147
+ }
1148
+ return this.fire('pause');
1149
+ },
1150
+ seek: function(t){
1151
+ var iv, ref$, ref1$, ref2$, i, late, tr, p;
1152
+ if (!this._frames || !this._frames.list.length) {
1153
+ return;
1154
+ }
1155
+ iv = this._interval();
1156
+ if (t && typeof t === 'object') {
1157
+ t = ((t.frame || 0) + (t.progress || 0)) * iv;
1158
+ }
1159
+ t = (ref$ = (ref2$ = +t || 0) > 0 ? ref2$ : 0) < (ref1$ = this.duration()) ? ref$ : ref1$;
1160
+ i = this._frameAt(t);
1161
+ late = t - i * iv;
1162
+ tr = (ref$ = +this._animCfg().transition || 0) < iv ? ref$ : iv;
1163
+ if (i > 0 && late < tr) {
1164
+ this._goto(i - 1);
1165
+ if (this.anim) {
1166
+ this.anim.flush();
1167
+ }
1168
+ this._goto(i, late);
1169
+ } else {
1170
+ this._goto(i);
1171
+ if (this.anim) {
1172
+ this.anim.flush();
1173
+ }
1174
+ }
1175
+ p = this._player;
1176
+ p.pos = t;
1177
+ if (p.playing) {
1178
+ p.origin = this._clock() - t;
1179
+ }
1180
+ return this.fire('progress', {
1181
+ time: t,
1182
+ duration: this.duration(),
1183
+ index: i
1184
+ });
1185
+ },
1186
+ _playerLoop: function(){
1187
+ var p, step, this$ = this;
1188
+ p = this._player;
1189
+ if (p.raf || !(typeof requestAnimationFrame != 'undefined' && requestAnimationFrame !== null)) {
1190
+ return;
1191
+ }
1192
+ step = function(){
1193
+ p.raf = null;
1194
+ if (!p.playing) {
1195
+ return;
1196
+ }
1197
+ if (!(this$.anim && this$.anim.manual())) {
1198
+ this$._playerTick();
1199
+ }
1200
+ if (p.playing) {
1201
+ return p.raf = requestAnimationFrame(step);
1202
+ }
1203
+ };
1204
+ return p.raf = requestAnimationFrame(step);
1205
+ },
1206
+ _playerTick: function(){
1207
+ var p, f, dur, t, i;
1208
+ p = this._player;
1209
+ f = this._frames;
1210
+ if (!f || !f.list.length) {
1211
+ return;
1212
+ }
1213
+ dur = this.duration();
1214
+ t = this.position();
1215
+ if (t >= dur) {
1216
+ if (this._animCfg().loop) {
1217
+ t = t % dur;
1218
+ p.origin = this._clock() - t;
1219
+ } else {
1220
+ p.pos = dur;
1221
+ p.playing = false;
1222
+ this.fire('progress', {
1223
+ time: dur,
1224
+ duration: dur,
1225
+ index: f.index
1226
+ });
1227
+ this.fire('end');
1228
+ return;
1229
+ }
1230
+ }
1231
+ i = this._frameAt(t);
1232
+ if (i !== f.index) {
1233
+ this._goto(i, t - i * this._interval());
1234
+ }
1235
+ return this.fire('progress', {
1236
+ time: t,
1237
+ duration: dur,
1238
+ index: i
1239
+ });
899
1240
  },
900
1241
  on: function(n, cb){
901
1242
  var this$ = this;
@@ -985,6 +1326,37 @@ var module = {exports: {}};
985
1326
  });
986
1327
  chart.commonConfig = {
987
1328
  common: {
1329
+ animation: {
1330
+ transition: {
1331
+ type: 'number',
1332
+ 'default': 350,
1333
+ min: 0,
1334
+ max: 5000,
1335
+ step: 10
1336
+ },
1337
+ interval: {
1338
+ type: 'number',
1339
+ 'default': 1000,
1340
+ min: 100,
1341
+ max: 20000,
1342
+ step: 50
1343
+ },
1344
+ speed: {
1345
+ type: 'number',
1346
+ 'default': 1,
1347
+ min: 0.1,
1348
+ max: 10,
1349
+ step: 0.1
1350
+ },
1351
+ loop: {
1352
+ type: 'boolean',
1353
+ 'default': true
1354
+ },
1355
+ autoplay: {
1356
+ type: 'boolean',
1357
+ 'default': true
1358
+ }
1359
+ },
988
1360
  subset: {
989
1361
  mode: {
990
1362
  type: 'choice',
@@ -1009,6 +1381,53 @@ var module = {exports: {}};
1009
1381
  }
1010
1382
  };
1011
1383
  chart.scopes = {
1384
+ frame: {
1385
+ active: function(){
1386
+ return !!this._frames;
1387
+ },
1388
+ count: function(){
1389
+ if (this._frames) {
1390
+ return this._frames.list.length;
1391
+ } else {
1392
+ return 0;
1393
+ }
1394
+ },
1395
+ index: function(){
1396
+ if (this._frames) {
1397
+ return this._frames.index;
1398
+ } else {
1399
+ return -1;
1400
+ }
1401
+ },
1402
+ id: function(i){
1403
+ if (!this._frames) {
1404
+ return null;
1405
+ }
1406
+ return (this._frames.list[i != null
1407
+ ? i
1408
+ : this._frames.index] || {}).id;
1409
+ },
1410
+ ids: function(){
1411
+ if (this._frames) {
1412
+ return this._frames.list.map(function(it){
1413
+ return it.id;
1414
+ });
1415
+ } else {
1416
+ return [];
1417
+ }
1418
+ },
1419
+ all: function(){
1420
+ var ref$, ref1$;
1421
+ if (!this._frames) {
1422
+ return this._parseRows(this.raw);
1423
+ }
1424
+ return (ref1$ = (ref$ = this._frames).all) != null
1425
+ ? ref1$
1426
+ : ref$.all = this._parseRows([].concat.apply([], this._frames.list.map(function(it){
1427
+ return it.raw;
1428
+ })));
1429
+ }
1430
+ },
1012
1431
  subset: {
1013
1432
  set: function(raw){
1014
1433
  this._subset = raw || null;
@@ -1058,6 +1477,29 @@ var module = {exports: {}};
1058
1477
  }
1059
1478
  }
1060
1479
  };
1480
+ chart.dataframe = {
1481
+ is: _isDataframe,
1482
+ split: function(raw, key){
1483
+ var hash, frames;
1484
+ raw == null && (raw = []);
1485
+ hash = {};
1486
+ frames = [];
1487
+ raw.map(function(r){
1488
+ var k;
1489
+ k = r[key] + "";
1490
+ if (!hash[k]) {
1491
+ frames.push(hash[k] = {
1492
+ id: r[key],
1493
+ raw: []
1494
+ });
1495
+ }
1496
+ return hash[k].raw.push(r);
1497
+ });
1498
+ return {
1499
+ frames: frames
1500
+ };
1501
+ }
1502
+ };
1061
1503
  if (typeof module != 'undefined' && module !== null) {
1062
1504
  module.exports = chart;
1063
1505
  } else if (typeof window != 'undefined' && window !== null) {
@@ -1147,6 +1589,11 @@ var module = {exports: {}};
1147
1589
  return result;
1148
1590
  }
1149
1591
  }
1592
+ function in$(x, xs){
1593
+ var i = -1, l = xs.length >>> 0;
1594
+ while (++i < l) if (x === xs[i]) return true;
1595
+ return false;
1596
+ }
1150
1597
  function import$(obj, src){
1151
1598
  var own = {}.hasOwnProperty;
1152
1599
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];
@@ -2951,13 +3398,18 @@ var chart = module.exports;
2951
3398
  opt == null && (opt = {});
2952
3399
  this._manual = !!opt.manual;
2953
3400
  this._now = 0;
2954
- this._offset = 0;
3401
+ this._base = 0;
3402
+ this._since = now();
3403
+ this._speed = 1;
3404
+ this._frozen = false;
3405
+ this._dur = 350;
3406
+ this._back = 0;
2955
3407
  this._raf = null;
2956
3408
  this._list = new Map();
2957
3409
  this.evtHandler = {};
2958
3410
  this._tick = function(t){
2959
3411
  this$._raf = null;
2960
- if (this$._manual) {
3412
+ if (this$._manual || this$._frozen) {
2961
3413
  return;
2962
3414
  }
2963
3415
  this$._apply(this$.time());
@@ -2993,9 +3445,80 @@ var chart = module.exports;
2993
3445
  time: function(){
2994
3446
  if (this._manual) {
2995
3447
  return this._now;
3448
+ } else if (this._frozen) {
3449
+ return this._base;
2996
3450
  } else {
2997
- return now() - this._offset;
3451
+ return this._base + (now() - this._since) * this._speed;
3452
+ }
3453
+ },
3454
+ _rebase: function(){
3455
+ this._base = this.time();
3456
+ return this._since = now();
3457
+ },
3458
+ duration: function(v){
3459
+ if (!arguments.length) {
3460
+ return this._dur;
3461
+ }
3462
+ v = +v;
3463
+ this._dur = isNaN(v) || v < 0 ? 350 : v;
3464
+ return this;
3465
+ },
3466
+ speed: function(v){
3467
+ if (!arguments.length) {
3468
+ return this._speed;
2998
3469
  }
3470
+ v = +v;
3471
+ if (isNaN(v) || v <= 0) {
3472
+ v = 1;
3473
+ }
3474
+ if (v === this._speed) {
3475
+ return this;
3476
+ }
3477
+ if (!this._manual) {
3478
+ this._rebase();
3479
+ }
3480
+ this._speed = v;
3481
+ return this;
3482
+ },
3483
+ paused: function(){
3484
+ return this._frozen;
3485
+ },
3486
+ pause: function(){
3487
+ if (this._frozen) {
3488
+ return this;
3489
+ }
3490
+ if (!this._manual) {
3491
+ this._rebase();
3492
+ }
3493
+ this._frozen = true;
3494
+ if (this._raf) {
3495
+ cancelAnimationFrame(this._raf);
3496
+ }
3497
+ this._raf = null;
3498
+ return this;
3499
+ },
3500
+ resume: function(){
3501
+ if (!this._frozen) {
3502
+ return this;
3503
+ }
3504
+ this._since = now();
3505
+ this._frozen = false;
3506
+ if (this._list.size) {
3507
+ this._kick();
3508
+ }
3509
+ return this;
3510
+ },
3511
+ ago: function(ms, fn){
3512
+ this._back = ms || 0;
3513
+ try {
3514
+ fn();
3515
+ } finally {
3516
+ this._back = 0;
3517
+ }
3518
+ if (ms) {
3519
+ this._apply(this.time());
3520
+ }
3521
+ return this;
2999
3522
  },
3000
3523
  manual: function(v){
3001
3524
  if (!arguments.length) {
@@ -3013,7 +3536,8 @@ var chart = module.exports;
3013
3536
  }
3014
3537
  this._raf = null;
3015
3538
  } else {
3016
- this._offset = now() - this._now;
3539
+ this._base = this._now;
3540
+ this._since = now();
3017
3541
  this._manual = false;
3018
3542
  if (this._list.size) {
3019
3543
  this._kick();
@@ -3026,6 +3550,7 @@ var chart = module.exports;
3026
3550
  if (!this._manual) {
3027
3551
  this.manual(true);
3028
3552
  }
3553
+ dt = dt * this._speed;
3029
3554
  this._now += dt;
3030
3555
  this._apply(this._now);
3031
3556
  this.fire('step', this._now, dt);
@@ -3052,7 +3577,7 @@ var chart = module.exports;
3052
3577
  },
3053
3578
  _kick: function(){
3054
3579
  var this$ = this;
3055
- if (this._manual || this._raf) {
3580
+ if (this._manual || this._frozen || this._raf) {
3056
3581
  return;
3057
3582
  }
3058
3583
  if (!(typeof requestAnimationFrame != 'undefined' && requestAnimationFrame !== null)) {
@@ -3063,11 +3588,12 @@ var chart = module.exports;
3063
3588
  return this._raf = requestAnimationFrame(this._tick);
3064
3589
  },
3065
3590
  tween: function(node, attrs, opt){
3066
- var dur, delay, ez, immediate, item, start, k, v;
3591
+ var r, dur, delay, ez, immediate, item, start, k, v;
3067
3592
  attrs == null && (attrs = {});
3068
3593
  opt == null && (opt = {});
3069
- dur = opt.duration != null ? opt.duration : 350;
3070
- delay = opt.delay || 0;
3594
+ r = this._dur / 350;
3595
+ dur = (opt.duration != null ? opt.duration : 350) * r;
3596
+ delay = (opt.delay || 0) * r;
3071
3597
  ez = typeof opt.ease === 'function'
3072
3598
  ? opt.ease
3073
3599
  : ease[opt.ease || 'cubic-in-out'] || ease.cubicInOut;
@@ -3080,7 +3606,7 @@ var chart = module.exports;
3080
3606
  if (opt.end) {
3081
3607
  item.cb.push(opt.end);
3082
3608
  }
3083
- start = this.time() + delay;
3609
+ start = this.time() - this._back + delay;
3084
3610
  for (k in attrs) {
3085
3611
  v = attrs[k];
3086
3612
  if (!(v != null)) {