@plotdb/chart 3.6.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/CHANGELOG.md +30 -0
- package/bundle.js +1706 -81
- package/bundle.min.js +1 -1
- package/index.js +460 -13
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/utils/anim.js +152 -18
- package/utils/anim.min.js +1 -1
- package/utils/brush.js +4 -2
- package/utils/brush.min.js +1 -1
- package/utils/color.js +37 -0
- package/utils/color.min.js +1 -0
- package/utils/scale.js +235 -29
- package/utils/scale.min.js +1 -1
- package/utils/shape.js +799 -0
- package/utils/shape.min.js +1 -0
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,
|
|
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
|
-
|
|
525
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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);
|
|
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());
|
|
898
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];
|
|
@@ -1498,7 +1945,7 @@ var chart = module.exports;
|
|
|
1498
1945
|
}
|
|
1499
1946
|
}).call(this);
|
|
1500
1947
|
(function(){
|
|
1501
|
-
var e10, e5, e2, tickSpec, ticks, linear, band, scale;
|
|
1948
|
+
var e10, e5, e2, tickSpec, ticks, identity, interpNumber, interpValue, normalize, bisectRight, piecewise, continuous, linear, transformPow, transformSqrt, transformSquare, pow, sqrt, symlog, band, point, pointish, scale;
|
|
1502
1949
|
e10 = Math.sqrt(50);
|
|
1503
1950
|
e5 = Math.sqrt(10);
|
|
1504
1951
|
e2 = Math.sqrt(2);
|
|
@@ -1569,77 +2016,265 @@ var chart = module.exports;
|
|
|
1569
2016
|
}
|
|
1570
2017
|
return results$;
|
|
1571
2018
|
};
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
2019
|
+
identity = function(x){
|
|
2020
|
+
return x;
|
|
2021
|
+
};
|
|
2022
|
+
interpNumber = function(a, b){
|
|
2023
|
+
var ref$;
|
|
2024
|
+
ref$ = [+a, +b], a = ref$[0], b = ref$[1];
|
|
2025
|
+
return function(t){
|
|
2026
|
+
return a * (1 - t) + b * t;
|
|
2027
|
+
};
|
|
2028
|
+
};
|
|
2029
|
+
interpValue = function(a, b){
|
|
2030
|
+
if (typeof b === 'number') {
|
|
2031
|
+
return interpNumber(a, b);
|
|
2032
|
+
}
|
|
2033
|
+
if (!((typeof chart != 'undefined' && chart !== null) && chart.utils && chart.utils.anim)) {
|
|
2034
|
+
return function(){
|
|
2035
|
+
return b;
|
|
2036
|
+
};
|
|
2037
|
+
}
|
|
2038
|
+
return chart.utils.anim.interpolate(a, b);
|
|
2039
|
+
};
|
|
2040
|
+
normalize = function(a, b){
|
|
2041
|
+
a = +a;
|
|
2042
|
+
b = b - a;
|
|
2043
|
+
if (b) {
|
|
2044
|
+
return function(x){
|
|
2045
|
+
return (x - a) / b;
|
|
2046
|
+
};
|
|
2047
|
+
} else {
|
|
2048
|
+
if (isNaN(b)) {
|
|
2049
|
+
return function(){
|
|
2050
|
+
return NaN;
|
|
2051
|
+
};
|
|
2052
|
+
} else {
|
|
2053
|
+
return function(){
|
|
2054
|
+
return 0.5;
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
};
|
|
2059
|
+
bisectRight = function(a, x, lo, hi){
|
|
2060
|
+
var mid;
|
|
2061
|
+
while (lo < hi) {
|
|
2062
|
+
mid = lo + hi >>> 1;
|
|
2063
|
+
if (x < a[mid]) {
|
|
2064
|
+
hi = mid;
|
|
2065
|
+
} else {
|
|
2066
|
+
lo = mid + 1;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
return lo;
|
|
2070
|
+
};
|
|
2071
|
+
piecewise = function(dm, rg, ip){
|
|
2072
|
+
var j, ref$, d0, d1, r0, r1, n, i, ns, res$, i$, ips;
|
|
2073
|
+
j = Math.min(dm.length, rg.length) - 1;
|
|
2074
|
+
if (j <= 1) {
|
|
2075
|
+
ref$ = [dm[0], dm[1], rg[0], rg[1]], d0 = ref$[0], d1 = ref$[1], r0 = ref$[2], r1 = ref$[3];
|
|
2076
|
+
ref$ = d1 < d0
|
|
2077
|
+
? [normalize(d1, d0), ip(r1, r0)]
|
|
2078
|
+
: [normalize(d0, d1), ip(r0, r1)], n = ref$[0], i = ref$[1];
|
|
2079
|
+
return function(x){
|
|
2080
|
+
return i(n(x));
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
if (dm[j] < dm[0]) {
|
|
2084
|
+
dm = dm.slice().reverse();
|
|
2085
|
+
rg = rg.slice().reverse();
|
|
2086
|
+
}
|
|
2087
|
+
res$ = [];
|
|
2088
|
+
for (i$ = 0; i$ < j; ++i$) {
|
|
2089
|
+
i = i$;
|
|
2090
|
+
res$.push(normalize(dm[i], dm[i + 1]));
|
|
2091
|
+
}
|
|
2092
|
+
ns = res$;
|
|
2093
|
+
res$ = [];
|
|
2094
|
+
for (i$ = 0; i$ < j; ++i$) {
|
|
2095
|
+
i = i$;
|
|
2096
|
+
res$.push(ip(rg[i], rg[i + 1]));
|
|
2097
|
+
}
|
|
2098
|
+
ips = res$;
|
|
2099
|
+
return function(x){
|
|
2100
|
+
var i;
|
|
2101
|
+
i = bisectRight(dm, x, 1, j) - 1;
|
|
2102
|
+
return ips[i](ns[i](x));
|
|
2103
|
+
};
|
|
2104
|
+
};
|
|
2105
|
+
continuous = function(tf, utf){
|
|
2106
|
+
var ref$, dm, rg, clamp, out, inp, clamper, rescale, s;
|
|
2107
|
+
tf == null && (tf = identity);
|
|
2108
|
+
utf == null && (utf = identity);
|
|
2109
|
+
ref$ = [[0, 1], [0, 1], false], dm = ref$[0], rg = ref$[1], clamp = ref$[2];
|
|
2110
|
+
ref$ = [null, null], out = ref$[0], inp = ref$[1];
|
|
2111
|
+
clamper = function(x){
|
|
2112
|
+
var ref$, a, b;
|
|
2113
|
+
if (!clamp) {
|
|
2114
|
+
return x;
|
|
2115
|
+
}
|
|
2116
|
+
ref$ = [dm[0], dm[Math.min(dm.length, rg.length) - 1]], a = ref$[0], b = ref$[1];
|
|
2117
|
+
if (a > b) {
|
|
2118
|
+
ref$ = [b, a], a = ref$[0], b = ref$[1];
|
|
2119
|
+
}
|
|
2120
|
+
return Math.max(a, Math.min(b, x));
|
|
2121
|
+
};
|
|
2122
|
+
rescale = function(){
|
|
2123
|
+
out = null;
|
|
2124
|
+
inp = null;
|
|
2125
|
+
return s;
|
|
2126
|
+
};
|
|
1575
2127
|
s = function(x){
|
|
1576
|
-
var d0, d1, r0, r1, ref$, t, b;
|
|
1577
2128
|
if (!(x != null) || isNaN(x = +x)) {
|
|
1578
2129
|
return undefined;
|
|
1579
2130
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
2131
|
+
if (!out) {
|
|
2132
|
+
out = piecewise(dm.map(tf), rg, interpValue);
|
|
2133
|
+
}
|
|
2134
|
+
return out(tf(clamper(x)));
|
|
2135
|
+
};
|
|
2136
|
+
s.invert = function(y){
|
|
2137
|
+
if (!inp) {
|
|
2138
|
+
inp = piecewise(rg, dm.map(tf), interpNumber);
|
|
1584
2139
|
}
|
|
1585
|
-
|
|
1586
|
-
? (x - d0) / b
|
|
1587
|
-
: isNaN(b) ? NaN : 0.5;
|
|
1588
|
-
return r0 * (1 - t) + r1 * t;
|
|
2140
|
+
return clamper(utf(inp(y)));
|
|
1589
2141
|
};
|
|
1590
2142
|
s.domain = function(it){
|
|
1591
2143
|
if (!arguments.length) {
|
|
1592
|
-
return
|
|
2144
|
+
return dm.slice();
|
|
1593
2145
|
}
|
|
1594
|
-
|
|
2146
|
+
dm = Array.from(it, function(v){
|
|
1595
2147
|
return +v;
|
|
1596
2148
|
});
|
|
1597
|
-
return
|
|
2149
|
+
return rescale();
|
|
1598
2150
|
};
|
|
1599
2151
|
s.range = function(it){
|
|
1600
2152
|
if (!arguments.length) {
|
|
1601
|
-
return
|
|
2153
|
+
return rg.slice();
|
|
1602
2154
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
});
|
|
1606
|
-
return s;
|
|
2155
|
+
rg = Array.from(it);
|
|
2156
|
+
return rescale();
|
|
1607
2157
|
};
|
|
1608
|
-
s.
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
return
|
|
2158
|
+
s.clamp = function(it){
|
|
2159
|
+
if (!arguments.length) {
|
|
2160
|
+
return clamp;
|
|
2161
|
+
}
|
|
2162
|
+
clamp = !!it;
|
|
2163
|
+
return rescale();
|
|
1614
2164
|
};
|
|
1615
2165
|
s.ticks = function(count){
|
|
1616
2166
|
count == null && (count = 10);
|
|
1617
|
-
return ticks(
|
|
2167
|
+
return ticks(dm[0], dm[dm.length - 1], count);
|
|
2168
|
+
};
|
|
2169
|
+
s._transform = function(t, u){
|
|
2170
|
+
tf = t;
|
|
2171
|
+
utf = u;
|
|
2172
|
+
return rescale();
|
|
2173
|
+
};
|
|
2174
|
+
s._copy = function(c){
|
|
2175
|
+
return c.domain(dm).range(rg).clamp(clamp);
|
|
1618
2176
|
};
|
|
1619
2177
|
s.copy = function(){
|
|
1620
|
-
return
|
|
2178
|
+
return s._copy(continuous(tf, utf));
|
|
1621
2179
|
};
|
|
1622
2180
|
return s;
|
|
1623
2181
|
};
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
2182
|
+
linear = function(){
|
|
2183
|
+
return continuous();
|
|
2184
|
+
};
|
|
2185
|
+
transformPow = function(e){
|
|
2186
|
+
return function(x){
|
|
2187
|
+
if (x < 0) {
|
|
2188
|
+
return -Math.pow(-x, e);
|
|
2189
|
+
} else {
|
|
2190
|
+
return Math.pow(x, e);
|
|
2191
|
+
}
|
|
2192
|
+
};
|
|
2193
|
+
};
|
|
2194
|
+
transformSqrt = function(x){
|
|
2195
|
+
if (x < 0) {
|
|
2196
|
+
return -Math.sqrt(-x);
|
|
2197
|
+
} else {
|
|
2198
|
+
return Math.sqrt(x);
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
transformSquare = function(x){
|
|
2202
|
+
if (x < 0) {
|
|
2203
|
+
return -x * x;
|
|
2204
|
+
} else {
|
|
2205
|
+
return x * x;
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
pow = function(){
|
|
2209
|
+
var s, e, update;
|
|
2210
|
+
s = continuous();
|
|
2211
|
+
e = 1;
|
|
2212
|
+
update = function(){
|
|
2213
|
+
if (e === 1) {
|
|
2214
|
+
return s._transform(identity, identity);
|
|
2215
|
+
} else if (e === 0.5) {
|
|
2216
|
+
return s._transform(transformSqrt, transformSquare);
|
|
2217
|
+
} else {
|
|
2218
|
+
return s._transform(transformPow(e), transformPow(1 / e));
|
|
2219
|
+
}
|
|
2220
|
+
};
|
|
2221
|
+
s.exponent = function(it){
|
|
2222
|
+
if (!arguments.length) {
|
|
2223
|
+
return e;
|
|
2224
|
+
}
|
|
2225
|
+
e = +it;
|
|
2226
|
+
return update();
|
|
2227
|
+
};
|
|
2228
|
+
s.copy = function(){
|
|
2229
|
+
return s._copy(pow().exponent(e));
|
|
2230
|
+
};
|
|
2231
|
+
return s;
|
|
2232
|
+
};
|
|
2233
|
+
sqrt = function(){
|
|
2234
|
+
return pow().exponent(0.5);
|
|
2235
|
+
};
|
|
2236
|
+
symlog = function(){
|
|
2237
|
+
var s, c, update;
|
|
2238
|
+
s = continuous();
|
|
2239
|
+
c = 1;
|
|
2240
|
+
update = function(){
|
|
2241
|
+
return s._transform(function(x){
|
|
2242
|
+
return Math.sign(x) * Math.log1p(Math.abs(x / c));
|
|
2243
|
+
}, function(x){
|
|
2244
|
+
return Math.sign(x) * Math.expm1(Math.abs(x)) * c;
|
|
2245
|
+
});
|
|
2246
|
+
};
|
|
2247
|
+
s.constant = function(it){
|
|
2248
|
+
if (!arguments.length) {
|
|
2249
|
+
return c;
|
|
2250
|
+
}
|
|
2251
|
+
c = +it;
|
|
2252
|
+
return update();
|
|
2253
|
+
};
|
|
2254
|
+
s.copy = function(){
|
|
2255
|
+
return s._copy(symlog().constant(c));
|
|
2256
|
+
};
|
|
2257
|
+
return update();
|
|
2258
|
+
};
|
|
2259
|
+
band = function(){
|
|
2260
|
+
var ref$, dm, idx, r, pi, po, al, step, bw, vals, rescale, s;
|
|
2261
|
+
ref$ = [[], new Map(), [0, 1], 0, 0, 0.5], dm = ref$[0], idx = ref$[1], r = ref$[2], pi = ref$[3], po = ref$[4], al = ref$[5];
|
|
2262
|
+
ref$ = [0, 0, []], step = ref$[0], bw = ref$[1], vals = ref$[2];
|
|
2263
|
+
rescale = function(){
|
|
2264
|
+
var n, r0, r1, reverse, ref$, start, stop, res$, i$, i;
|
|
2265
|
+
n = dm.length;
|
|
2266
|
+
r0 = r[0], r1 = r[1];
|
|
2267
|
+
reverse = r1 < r0;
|
|
2268
|
+
ref$ = reverse
|
|
2269
|
+
? [r1, r0]
|
|
2270
|
+
: [r0, r1], start = ref$[0], stop = ref$[1];
|
|
2271
|
+
step = (stop - start) / Math.max(1, n - pi + po * 2);
|
|
2272
|
+
start = start + (stop - start - step * (n - pi)) * al;
|
|
2273
|
+
bw = step * (1 - pi);
|
|
2274
|
+
res$ = [];
|
|
2275
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
2276
|
+
i = i$;
|
|
2277
|
+
res$.push(start + step * i);
|
|
1643
2278
|
}
|
|
1644
2279
|
vals = res$;
|
|
1645
2280
|
if (reverse) {
|
|
@@ -1716,9 +2351,27 @@ var chart = module.exports;
|
|
|
1716
2351
|
};
|
|
1717
2352
|
return rescale();
|
|
1718
2353
|
};
|
|
2354
|
+
point = function(){
|
|
2355
|
+
return pointish(band().paddingInner(1));
|
|
2356
|
+
};
|
|
2357
|
+
pointish = function(s){
|
|
2358
|
+
var copy;
|
|
2359
|
+
copy = s.copy;
|
|
2360
|
+
s.padding = s.paddingOuter;
|
|
2361
|
+
delete s.paddingInner;
|
|
2362
|
+
delete s.paddingOuter;
|
|
2363
|
+
s.copy = function(){
|
|
2364
|
+
return pointish(copy());
|
|
2365
|
+
};
|
|
2366
|
+
return s;
|
|
2367
|
+
};
|
|
1719
2368
|
scale = {
|
|
1720
2369
|
linear: linear,
|
|
2370
|
+
pow: pow,
|
|
2371
|
+
sqrt: sqrt,
|
|
2372
|
+
symlog: symlog,
|
|
1721
2373
|
band: band,
|
|
2374
|
+
point: point,
|
|
1722
2375
|
ticks: ticks
|
|
1723
2376
|
};
|
|
1724
2377
|
if (typeof chart != 'undefined' && chart !== null) {
|
|
@@ -1726,7 +2379,843 @@ var chart = module.exports;
|
|
|
1726
2379
|
}
|
|
1727
2380
|
}).call(this);
|
|
1728
2381
|
(function(){
|
|
1729
|
-
var
|
|
2382
|
+
var abs, atan2, cos, sin, sqrt, min, max, pi, halfPi, tau, eps, pEps, tauEps, acos, asin, constant, accessor, Path, intersect, cornerTangents, arc, Linear, curveLinear, cardinalPoint, Cardinal, catmullPoint, CatmullRom, catmullRom, custom, curve, asArray, line, area, shape;
|
|
2383
|
+
abs = Math.abs, atan2 = Math.atan2, cos = Math.cos, sin = Math.sin, sqrt = Math.sqrt, min = Math.min, max = Math.max;
|
|
2384
|
+
pi = Math.PI;
|
|
2385
|
+
halfPi = pi / 2;
|
|
2386
|
+
tau = 2 * pi;
|
|
2387
|
+
eps = 1e-12;
|
|
2388
|
+
pEps = 1e-6;
|
|
2389
|
+
tauEps = tau - pEps;
|
|
2390
|
+
acos = function(x){
|
|
2391
|
+
if (x > 1) {
|
|
2392
|
+
return 0;
|
|
2393
|
+
} else if (x < -1) {
|
|
2394
|
+
return pi;
|
|
2395
|
+
} else {
|
|
2396
|
+
return Math.acos(x);
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
asin = function(x){
|
|
2400
|
+
if (x >= 1) {
|
|
2401
|
+
return halfPi;
|
|
2402
|
+
} else if (x <= -1) {
|
|
2403
|
+
return -halfPi;
|
|
2404
|
+
} else {
|
|
2405
|
+
return Math.asin(x);
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
constant = function(x){
|
|
2409
|
+
return function(){
|
|
2410
|
+
return x;
|
|
2411
|
+
};
|
|
2412
|
+
};
|
|
2413
|
+
accessor = function(v){
|
|
2414
|
+
if (typeof v === 'function') {
|
|
2415
|
+
return v;
|
|
2416
|
+
} else {
|
|
2417
|
+
return constant(+v);
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
Path = function(digits){
|
|
2421
|
+
this._x0 = this._y0 = this._x1 = this._y1 = null;
|
|
2422
|
+
this._ = '';
|
|
2423
|
+
this._k = digits != null && Math.floor(digits) <= 15 ? Math.pow(10, Math.floor(digits)) : null;
|
|
2424
|
+
return this;
|
|
2425
|
+
};
|
|
2426
|
+
Path.prototype = {
|
|
2427
|
+
_a: function(cmd){
|
|
2428
|
+
var vs, res$, i$, to$, k;
|
|
2429
|
+
res$ = [];
|
|
2430
|
+
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
|
|
2431
|
+
res$.push(arguments[i$]);
|
|
2432
|
+
}
|
|
2433
|
+
vs = res$;
|
|
2434
|
+
k = this._k;
|
|
2435
|
+
return this._ += cmd + (k != null ? vs.map(function(it){
|
|
2436
|
+
return Math.round(it * k) / k;
|
|
2437
|
+
}) : vs).join(',');
|
|
2438
|
+
},
|
|
2439
|
+
moveTo: function(x, y){
|
|
2440
|
+
this._x0 = this._x1 = +x;
|
|
2441
|
+
this._y0 = this._y1 = +y;
|
|
2442
|
+
return this._a('M', this._x0, this._y0);
|
|
2443
|
+
},
|
|
2444
|
+
closePath: function(){
|
|
2445
|
+
if (this._x1 !== null) {
|
|
2446
|
+
this._x1 = this._x0;
|
|
2447
|
+
this._y1 = this._y0;
|
|
2448
|
+
return this._ += 'Z';
|
|
2449
|
+
}
|
|
2450
|
+
},
|
|
2451
|
+
lineTo: function(x, y){
|
|
2452
|
+
this._x1 = +x;
|
|
2453
|
+
this._y1 = +y;
|
|
2454
|
+
return this._a('L', this._x1, this._y1);
|
|
2455
|
+
},
|
|
2456
|
+
bezierCurveTo: function(x1, y1, x2, y2, x, y){
|
|
2457
|
+
this._x1 = +x;
|
|
2458
|
+
this._y1 = +y;
|
|
2459
|
+
return this._a('C', +x1, +y1, +x2, +y2, this._x1, this._y1);
|
|
2460
|
+
},
|
|
2461
|
+
arc: function(x, y, r, a0, a1, ccw){
|
|
2462
|
+
var ref$, dx, dy, x0, y0, cw, da;
|
|
2463
|
+
ref$ = [+x, +y, +r, !!ccw], x = ref$[0], y = ref$[1], r = ref$[2], ccw = ref$[3];
|
|
2464
|
+
if (r < 0) {
|
|
2465
|
+
throw new Error("negative radius: " + r);
|
|
2466
|
+
}
|
|
2467
|
+
dx = r * cos(a0);
|
|
2468
|
+
dy = r * sin(a0);
|
|
2469
|
+
x0 = x + dx;
|
|
2470
|
+
y0 = y + dy;
|
|
2471
|
+
cw = ccw ? 0 : 1;
|
|
2472
|
+
da = ccw
|
|
2473
|
+
? a0 - a1
|
|
2474
|
+
: a1 - a0;
|
|
2475
|
+
if (this._x1 === null) {
|
|
2476
|
+
this._a('M', x0, y0);
|
|
2477
|
+
} else if (abs(this._x1 - x0) > pEps || abs(this._y1 - y0) > pEps) {
|
|
2478
|
+
this._a('L', x0, y0);
|
|
2479
|
+
}
|
|
2480
|
+
if (!r) {
|
|
2481
|
+
return;
|
|
2482
|
+
}
|
|
2483
|
+
if (da < 0) {
|
|
2484
|
+
da = da % tau + tau;
|
|
2485
|
+
}
|
|
2486
|
+
if (da > tauEps) {
|
|
2487
|
+
this._a('A', r, r, 0, 1, cw, x - dx, y - dy);
|
|
2488
|
+
this._x1 = x0;
|
|
2489
|
+
this._y1 = y0;
|
|
2490
|
+
return this._a('A', r, r, 0, 1, cw, this._x1, this._y1);
|
|
2491
|
+
} else if (da > pEps) {
|
|
2492
|
+
this._x1 = x + r * cos(a1);
|
|
2493
|
+
this._y1 = y + r * sin(a1);
|
|
2494
|
+
return this._a('A', r, r, 0, da >= pi ? 1 : 0, cw, this._x1, this._y1);
|
|
2495
|
+
}
|
|
2496
|
+
},
|
|
2497
|
+
toString: function(){
|
|
2498
|
+
return this._;
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
intersect = function(x0, y0, x1, y1, x2, y2, x3, y3){
|
|
2502
|
+
var ref$, x10, y10, x32, y32, t;
|
|
2503
|
+
ref$ = [x1 - x0, y1 - y0, x3 - x2, y3 - y2], x10 = ref$[0], y10 = ref$[1], x32 = ref$[2], y32 = ref$[3];
|
|
2504
|
+
t = y32 * x10 - x32 * y10;
|
|
2505
|
+
if (t * t < eps) {
|
|
2506
|
+
return;
|
|
2507
|
+
}
|
|
2508
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
2509
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
2510
|
+
};
|
|
2511
|
+
cornerTangents = function(x0, y0, x1, y1, r1, rc, cw){
|
|
2512
|
+
var x01, y01, lo, ox, oy, x11, y11, x10, y10, x00, y00, dx, dy, d2, r, D, d, cx0, cy0, cx1, cy1, dx0, dy0, dx1, dy1;
|
|
2513
|
+
x01 = x0 - x1;
|
|
2514
|
+
y01 = y0 - y1;
|
|
2515
|
+
lo = (cw
|
|
2516
|
+
? rc
|
|
2517
|
+
: -rc) / sqrt(x01 * x01 + y01 * y01);
|
|
2518
|
+
ox = lo * y01;
|
|
2519
|
+
oy = -lo * x01;
|
|
2520
|
+
x11 = x0 + ox;
|
|
2521
|
+
y11 = y0 + oy;
|
|
2522
|
+
x10 = x1 + ox;
|
|
2523
|
+
y10 = y1 + oy;
|
|
2524
|
+
x00 = (x11 + x10) / 2;
|
|
2525
|
+
y00 = (y11 + y10) / 2;
|
|
2526
|
+
dx = x10 - x11;
|
|
2527
|
+
dy = y10 - y11;
|
|
2528
|
+
d2 = dx * dx + dy * dy;
|
|
2529
|
+
r = r1 - rc;
|
|
2530
|
+
D = x11 * y10 - x10 * y11;
|
|
2531
|
+
d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D));
|
|
2532
|
+
cx0 = (D * dy - dx * d) / d2;
|
|
2533
|
+
cy0 = (-D * dx - dy * d) / d2;
|
|
2534
|
+
cx1 = (D * dy + dx * d) / d2;
|
|
2535
|
+
cy1 = (-D * dx + dy * d) / d2;
|
|
2536
|
+
dx0 = cx0 - x00;
|
|
2537
|
+
dy0 = cy0 - y00;
|
|
2538
|
+
dx1 = cx1 - x00;
|
|
2539
|
+
dy1 = cy1 - y00;
|
|
2540
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) {
|
|
2541
|
+
cx0 = cx1;
|
|
2542
|
+
cy0 = cy1;
|
|
2543
|
+
}
|
|
2544
|
+
return {
|
|
2545
|
+
cx: cx0,
|
|
2546
|
+
cy: cy0,
|
|
2547
|
+
x01: -ox,
|
|
2548
|
+
y01: -oy,
|
|
2549
|
+
x11: cx0 * (r1 / r - 1),
|
|
2550
|
+
y11: cy0 * (r1 / r - 1)
|
|
2551
|
+
};
|
|
2552
|
+
};
|
|
2553
|
+
arc = function(){
|
|
2554
|
+
var inner, outer, corner, padRadius, start, end, pad, digits, shape;
|
|
2555
|
+
inner = function(d){
|
|
2556
|
+
return d.innerRadius;
|
|
2557
|
+
};
|
|
2558
|
+
outer = function(d){
|
|
2559
|
+
return d.outerRadius;
|
|
2560
|
+
};
|
|
2561
|
+
corner = constant(0);
|
|
2562
|
+
padRadius = null;
|
|
2563
|
+
start = function(d){
|
|
2564
|
+
return d.startAngle;
|
|
2565
|
+
};
|
|
2566
|
+
end = function(d){
|
|
2567
|
+
return d.endAngle;
|
|
2568
|
+
};
|
|
2569
|
+
pad = function(d){
|
|
2570
|
+
return d && d.padAngle;
|
|
2571
|
+
};
|
|
2572
|
+
digits = 3;
|
|
2573
|
+
shape = function(){
|
|
2574
|
+
var args, ctx, r0, r1, a0, a1, da, cw, ref$, a01, a11, a00, a10, da0, da1, ap, rp, rc, rc0, rc1, p0, p1, x01, y01, x10, y10, x11, y11, x00, y00, oc, ax, ay, bx, by, kc, lc, t0, t1;
|
|
2575
|
+
args = arguments;
|
|
2576
|
+
ctx = new Path(digits);
|
|
2577
|
+
r0 = +inner.apply(this, args);
|
|
2578
|
+
r1 = +outer.apply(this, args);
|
|
2579
|
+
a0 = start.apply(this, args) - halfPi;
|
|
2580
|
+
a1 = end.apply(this, args) - halfPi;
|
|
2581
|
+
da = abs(a1 - a0);
|
|
2582
|
+
cw = a1 > a0;
|
|
2583
|
+
if (r1 < r0) {
|
|
2584
|
+
ref$ = [r1, r0], r0 = ref$[0], r1 = ref$[1];
|
|
2585
|
+
}
|
|
2586
|
+
if (!(r1 > eps)) {
|
|
2587
|
+
ctx.moveTo(0, 0);
|
|
2588
|
+
} else if (da > tau - eps) {
|
|
2589
|
+
ctx.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
2590
|
+
ctx.arc(0, 0, r1, a0, a1, !cw);
|
|
2591
|
+
if (r0 > eps) {
|
|
2592
|
+
ctx.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
2593
|
+
ctx.arc(0, 0, r0, a1, a0, cw);
|
|
2594
|
+
}
|
|
2595
|
+
} else {
|
|
2596
|
+
ref$ = [a0, a1, a0, a1, da, da], a01 = ref$[0], a11 = ref$[1], a00 = ref$[2], a10 = ref$[3], da0 = ref$[4], da1 = ref$[5];
|
|
2597
|
+
ap = pad.apply(this, args) / 2;
|
|
2598
|
+
rp = ap > eps && (padRadius
|
|
2599
|
+
? +padRadius.apply(this, args)
|
|
2600
|
+
: sqrt(r0 * r0 + r1 * r1));
|
|
2601
|
+
rc = min(abs(r1 - r0) / 2, +corner.apply(this, args));
|
|
2602
|
+
rc0 = rc;
|
|
2603
|
+
rc1 = rc;
|
|
2604
|
+
if (rp > eps) {
|
|
2605
|
+
p0 = asin(rp / r0 * sin(ap));
|
|
2606
|
+
p1 = asin(rp / r1 * sin(ap));
|
|
2607
|
+
if ((da0 -= p0 * 2) > eps) {
|
|
2608
|
+
p0 *= cw
|
|
2609
|
+
? 1
|
|
2610
|
+
: -1;
|
|
2611
|
+
a00 += p0;
|
|
2612
|
+
a10 -= p0;
|
|
2613
|
+
} else {
|
|
2614
|
+
da0 = 0;
|
|
2615
|
+
a00 = a10 = (a0 + a1) / 2;
|
|
2616
|
+
}
|
|
2617
|
+
if ((da1 -= p1 * 2) > eps) {
|
|
2618
|
+
p1 *= cw
|
|
2619
|
+
? 1
|
|
2620
|
+
: -1;
|
|
2621
|
+
a01 += p1;
|
|
2622
|
+
a11 -= p1;
|
|
2623
|
+
} else {
|
|
2624
|
+
da1 = 0;
|
|
2625
|
+
a01 = a11 = (a0 + a1) / 2;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
x01 = r1 * cos(a01);
|
|
2629
|
+
y01 = r1 * sin(a01);
|
|
2630
|
+
x10 = r0 * cos(a10);
|
|
2631
|
+
y10 = r0 * sin(a10);
|
|
2632
|
+
if (rc > eps) {
|
|
2633
|
+
x11 = r1 * cos(a11);
|
|
2634
|
+
y11 = r1 * sin(a11);
|
|
2635
|
+
x00 = r0 * cos(a00);
|
|
2636
|
+
y00 = r0 * sin(a00);
|
|
2637
|
+
if (da < pi) {
|
|
2638
|
+
if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) {
|
|
2639
|
+
ax = x01 - oc[0];
|
|
2640
|
+
ay = y01 - oc[1];
|
|
2641
|
+
bx = x11 - oc[0];
|
|
2642
|
+
by = y11 - oc[1];
|
|
2643
|
+
kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2);
|
|
2644
|
+
lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
2645
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
2646
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
2647
|
+
} else {
|
|
2648
|
+
rc0 = rc1 = 0;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
if (!(da1 > eps)) {
|
|
2653
|
+
ctx.moveTo(x01, y01);
|
|
2654
|
+
} else if (rc1 > eps) {
|
|
2655
|
+
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
2656
|
+
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
2657
|
+
ctx.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
2658
|
+
if (rc1 < rc) {
|
|
2659
|
+
ctx.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
2660
|
+
} else {
|
|
2661
|
+
ctx.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
2662
|
+
ctx.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
2663
|
+
ctx.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
2664
|
+
}
|
|
2665
|
+
} else {
|
|
2666
|
+
ctx.moveTo(x01, y01);
|
|
2667
|
+
ctx.arc(0, 0, r1, a01, a11, !cw);
|
|
2668
|
+
}
|
|
2669
|
+
if (!(r0 > eps) || !(da0 > eps)) {
|
|
2670
|
+
ctx.lineTo(x10, y10);
|
|
2671
|
+
} else if (rc0 > eps) {
|
|
2672
|
+
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
2673
|
+
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
2674
|
+
ctx.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
2675
|
+
if (rc0 < rc) {
|
|
2676
|
+
ctx.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
2677
|
+
} else {
|
|
2678
|
+
ctx.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
2679
|
+
ctx.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
2680
|
+
ctx.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
2681
|
+
}
|
|
2682
|
+
} else {
|
|
2683
|
+
ctx.arc(0, 0, r0, a10, a00, cw);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
ctx.closePath();
|
|
2687
|
+
return ctx.toString() || null;
|
|
2688
|
+
};
|
|
2689
|
+
shape.centroid = function(){
|
|
2690
|
+
var r, a;
|
|
2691
|
+
r = (+inner.apply(this, arguments) + +outer.apply(this, arguments)) / 2;
|
|
2692
|
+
a = (+start.apply(this, arguments) + +end.apply(this, arguments)) / 2 - pi / 2;
|
|
2693
|
+
return [cos(a) * r, sin(a) * r];
|
|
2694
|
+
};
|
|
2695
|
+
shape.innerRadius = function(it){
|
|
2696
|
+
if (!arguments.length) {
|
|
2697
|
+
return inner;
|
|
2698
|
+
}
|
|
2699
|
+
inner = accessor(it);
|
|
2700
|
+
return shape;
|
|
2701
|
+
};
|
|
2702
|
+
shape.outerRadius = function(it){
|
|
2703
|
+
if (!arguments.length) {
|
|
2704
|
+
return outer;
|
|
2705
|
+
}
|
|
2706
|
+
outer = accessor(it);
|
|
2707
|
+
return shape;
|
|
2708
|
+
};
|
|
2709
|
+
shape.cornerRadius = function(it){
|
|
2710
|
+
if (!arguments.length) {
|
|
2711
|
+
return corner;
|
|
2712
|
+
}
|
|
2713
|
+
corner = accessor(it);
|
|
2714
|
+
return shape;
|
|
2715
|
+
};
|
|
2716
|
+
shape.padRadius = function(it){
|
|
2717
|
+
if (!arguments.length) {
|
|
2718
|
+
return padRadius;
|
|
2719
|
+
}
|
|
2720
|
+
padRadius = it != null ? accessor(it) : null;
|
|
2721
|
+
return shape;
|
|
2722
|
+
};
|
|
2723
|
+
shape.startAngle = function(it){
|
|
2724
|
+
if (!arguments.length) {
|
|
2725
|
+
return start;
|
|
2726
|
+
}
|
|
2727
|
+
start = accessor(it);
|
|
2728
|
+
return shape;
|
|
2729
|
+
};
|
|
2730
|
+
shape.endAngle = function(it){
|
|
2731
|
+
if (!arguments.length) {
|
|
2732
|
+
return end;
|
|
2733
|
+
}
|
|
2734
|
+
end = accessor(it);
|
|
2735
|
+
return shape;
|
|
2736
|
+
};
|
|
2737
|
+
shape.padAngle = function(it){
|
|
2738
|
+
if (!arguments.length) {
|
|
2739
|
+
return pad;
|
|
2740
|
+
}
|
|
2741
|
+
pad = accessor(it);
|
|
2742
|
+
return shape;
|
|
2743
|
+
};
|
|
2744
|
+
shape.digits = function(it){
|
|
2745
|
+
if (!arguments.length) {
|
|
2746
|
+
return digits;
|
|
2747
|
+
}
|
|
2748
|
+
digits = it != null ? Math.floor(it) : null;
|
|
2749
|
+
return shape;
|
|
2750
|
+
};
|
|
2751
|
+
return shape;
|
|
2752
|
+
};
|
|
2753
|
+
Linear = function(ctx){
|
|
2754
|
+
this._context = ctx;
|
|
2755
|
+
return this;
|
|
2756
|
+
};
|
|
2757
|
+
Linear.prototype = {
|
|
2758
|
+
areaStart: function(){
|
|
2759
|
+
return this._line = 0;
|
|
2760
|
+
},
|
|
2761
|
+
areaEnd: function(){
|
|
2762
|
+
return this._line = NaN;
|
|
2763
|
+
},
|
|
2764
|
+
lineStart: function(){
|
|
2765
|
+
return this._point = 0;
|
|
2766
|
+
},
|
|
2767
|
+
lineEnd: function(){
|
|
2768
|
+
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
2769
|
+
this._context.closePath();
|
|
2770
|
+
}
|
|
2771
|
+
return this._line = 1 - this._line;
|
|
2772
|
+
},
|
|
2773
|
+
point: function(x, y){
|
|
2774
|
+
var ref$;
|
|
2775
|
+
ref$ = [+x, +y], x = ref$[0], y = ref$[1];
|
|
2776
|
+
if (this._point === 0) {
|
|
2777
|
+
this._point = 1;
|
|
2778
|
+
if (this._line) {
|
|
2779
|
+
return this._context.lineTo(x, y);
|
|
2780
|
+
} else {
|
|
2781
|
+
return this._context.moveTo(x, y);
|
|
2782
|
+
}
|
|
2783
|
+
} else {
|
|
2784
|
+
this._point = 2;
|
|
2785
|
+
return this._context.lineTo(x, y);
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
};
|
|
2789
|
+
curveLinear = function(ctx){
|
|
2790
|
+
return new Linear(ctx);
|
|
2791
|
+
};
|
|
2792
|
+
cardinalPoint = function(o, x, y){
|
|
2793
|
+
var k;
|
|
2794
|
+
k = o._k;
|
|
2795
|
+
return o._context.bezierCurveTo(o._x1 + k * (o._x2 - o._x0), o._y1 + k * (o._y2 - o._y0), o._x2 + k * (o._x1 - x), o._y2 + k * (o._y1 - y), o._x2, o._y2);
|
|
2796
|
+
};
|
|
2797
|
+
Cardinal = function(ctx, tension){
|
|
2798
|
+
this._context = ctx;
|
|
2799
|
+
this._k = (1 - tension) / 6;
|
|
2800
|
+
return this;
|
|
2801
|
+
};
|
|
2802
|
+
Cardinal.prototype = {
|
|
2803
|
+
areaStart: function(){
|
|
2804
|
+
return this._line = 0;
|
|
2805
|
+
},
|
|
2806
|
+
areaEnd: function(){
|
|
2807
|
+
return this._line = NaN;
|
|
2808
|
+
},
|
|
2809
|
+
lineStart: function(){
|
|
2810
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
2811
|
+
return this._point = 0;
|
|
2812
|
+
},
|
|
2813
|
+
lineEnd: function(){
|
|
2814
|
+
if (this._point === 2) {
|
|
2815
|
+
this._context.lineTo(this._x2, this._y2);
|
|
2816
|
+
} else if (this._point === 3) {
|
|
2817
|
+
cardinalPoint(this, this._x1, this._y1);
|
|
2818
|
+
}
|
|
2819
|
+
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
2820
|
+
this._context.closePath();
|
|
2821
|
+
}
|
|
2822
|
+
return this._line = 1 - this._line;
|
|
2823
|
+
},
|
|
2824
|
+
point: function(x, y){
|
|
2825
|
+
var ref$;
|
|
2826
|
+
ref$ = [+x, +y], x = ref$[0], y = ref$[1];
|
|
2827
|
+
if (this._point === 0) {
|
|
2828
|
+
this._point = 1;
|
|
2829
|
+
if (this._line) {
|
|
2830
|
+
this._context.lineTo(x, y);
|
|
2831
|
+
} else {
|
|
2832
|
+
this._context.moveTo(x, y);
|
|
2833
|
+
}
|
|
2834
|
+
} else if (this._point === 1) {
|
|
2835
|
+
this._point = 2;
|
|
2836
|
+
this._x1 = x;
|
|
2837
|
+
this._y1 = y;
|
|
2838
|
+
} else {
|
|
2839
|
+
this._point = 3;
|
|
2840
|
+
cardinalPoint(this, x, y);
|
|
2841
|
+
}
|
|
2842
|
+
ref$ = [this._x1, this._x2, x], this._x0 = ref$[0], this._x1 = ref$[1], this._x2 = ref$[2];
|
|
2843
|
+
return ref$ = [this._y1, this._y2, y], this._y0 = ref$[0], this._y1 = ref$[1], this._y2 = ref$[2], ref$;
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2846
|
+
catmullPoint = function(o, x, y){
|
|
2847
|
+
var ref$, x1, y1, x2, y2, a, n, b, m;
|
|
2848
|
+
ref$ = [o._x1, o._y1, o._x2, o._y2], x1 = ref$[0], y1 = ref$[1], x2 = ref$[2], y2 = ref$[3];
|
|
2849
|
+
if (o._l01_a > eps) {
|
|
2850
|
+
a = 2 * o._l01_2a + 3 * o._l01_a * o._l12_a + o._l12_2a;
|
|
2851
|
+
n = 3 * o._l01_a * (o._l01_a + o._l12_a);
|
|
2852
|
+
x1 = (x1 * a - o._x0 * o._l12_2a + o._x2 * o._l01_2a) / n;
|
|
2853
|
+
y1 = (y1 * a - o._y0 * o._l12_2a + o._y2 * o._l01_2a) / n;
|
|
2854
|
+
}
|
|
2855
|
+
if (o._l23_a > eps) {
|
|
2856
|
+
b = 2 * o._l23_2a + 3 * o._l23_a * o._l12_a + o._l12_2a;
|
|
2857
|
+
m = 3 * o._l23_a * (o._l23_a + o._l12_a);
|
|
2858
|
+
x2 = (x2 * b + o._x1 * o._l23_2a - x * o._l12_2a) / m;
|
|
2859
|
+
y2 = (y2 * b + o._y1 * o._l23_2a - y * o._l12_2a) / m;
|
|
2860
|
+
}
|
|
2861
|
+
return o._context.bezierCurveTo(x1, y1, x2, y2, o._x2, o._y2);
|
|
2862
|
+
};
|
|
2863
|
+
CatmullRom = function(ctx, alpha){
|
|
2864
|
+
this._context = ctx;
|
|
2865
|
+
this._alpha = alpha;
|
|
2866
|
+
return this;
|
|
2867
|
+
};
|
|
2868
|
+
CatmullRom.prototype = {
|
|
2869
|
+
areaStart: function(){
|
|
2870
|
+
return this._line = 0;
|
|
2871
|
+
},
|
|
2872
|
+
areaEnd: function(){
|
|
2873
|
+
return this._line = NaN;
|
|
2874
|
+
},
|
|
2875
|
+
lineStart: function(){
|
|
2876
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
2877
|
+
return this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
2878
|
+
},
|
|
2879
|
+
lineEnd: function(){
|
|
2880
|
+
if (this._point === 2) {
|
|
2881
|
+
this._context.lineTo(this._x2, this._y2);
|
|
2882
|
+
} else if (this._point === 3) {
|
|
2883
|
+
this.point(this._x2, this._y2);
|
|
2884
|
+
}
|
|
2885
|
+
if (this._line || (this._line !== 0 && this._point === 1)) {
|
|
2886
|
+
this._context.closePath();
|
|
2887
|
+
}
|
|
2888
|
+
return this._line = 1 - this._line;
|
|
2889
|
+
},
|
|
2890
|
+
point: function(x, y){
|
|
2891
|
+
var ref$, x23, y23;
|
|
2892
|
+
ref$ = [+x, +y], x = ref$[0], y = ref$[1];
|
|
2893
|
+
if (this._point) {
|
|
2894
|
+
x23 = this._x2 - x;
|
|
2895
|
+
y23 = this._y2 - y;
|
|
2896
|
+
this._l23_a = sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
2897
|
+
}
|
|
2898
|
+
if (this._point === 0) {
|
|
2899
|
+
this._point = 1;
|
|
2900
|
+
if (this._line) {
|
|
2901
|
+
this._context.lineTo(x, y);
|
|
2902
|
+
} else {
|
|
2903
|
+
this._context.moveTo(x, y);
|
|
2904
|
+
}
|
|
2905
|
+
} else if (this._point === 1) {
|
|
2906
|
+
this._point = 2;
|
|
2907
|
+
} else {
|
|
2908
|
+
this._point = 3;
|
|
2909
|
+
catmullPoint(this, x, y);
|
|
2910
|
+
}
|
|
2911
|
+
ref$ = [this._l12_a, this._l23_a], this._l01_a = ref$[0], this._l12_a = ref$[1];
|
|
2912
|
+
ref$ = [this._l12_2a, this._l23_2a], this._l01_2a = ref$[0], this._l12_2a = ref$[1];
|
|
2913
|
+
ref$ = [this._x1, this._x2, x], this._x0 = ref$[0], this._x1 = ref$[1], this._x2 = ref$[2];
|
|
2914
|
+
return ref$ = [this._y1, this._y2, y], this._y0 = ref$[0], this._y1 = ref$[1], this._y2 = ref$[2], ref$;
|
|
2915
|
+
}
|
|
2916
|
+
};
|
|
2917
|
+
catmullRom = (custom = function(alpha){
|
|
2918
|
+
var f;
|
|
2919
|
+
f = function(ctx){
|
|
2920
|
+
if (alpha) {
|
|
2921
|
+
return new CatmullRom(ctx, alpha);
|
|
2922
|
+
} else {
|
|
2923
|
+
return new Cardinal(ctx, 0);
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
f.alpha = function(a){
|
|
2927
|
+
return custom(+a);
|
|
2928
|
+
};
|
|
2929
|
+
return f;
|
|
2930
|
+
}, custom(0.5));
|
|
2931
|
+
curve = {
|
|
2932
|
+
linear: curveLinear,
|
|
2933
|
+
catmullRom: catmullRom
|
|
2934
|
+
};
|
|
2935
|
+
asArray = function(x){
|
|
2936
|
+
if (typeof x === 'object' && 'length' in x) {
|
|
2937
|
+
return x;
|
|
2938
|
+
} else {
|
|
2939
|
+
return Array.from(x);
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
line = function(x, y){
|
|
2943
|
+
var defined, cv, digits, fx, fy, shape;
|
|
2944
|
+
defined = constant(true);
|
|
2945
|
+
cv = curveLinear;
|
|
2946
|
+
digits = 3;
|
|
2947
|
+
fx = typeof x === 'function'
|
|
2948
|
+
? x
|
|
2949
|
+
: x === undefined
|
|
2950
|
+
? function(p){
|
|
2951
|
+
return p[0];
|
|
2952
|
+
}
|
|
2953
|
+
: constant(x);
|
|
2954
|
+
fy = typeof y === 'function'
|
|
2955
|
+
? y
|
|
2956
|
+
: y === undefined
|
|
2957
|
+
? function(p){
|
|
2958
|
+
return p[1];
|
|
2959
|
+
}
|
|
2960
|
+
: constant(y);
|
|
2961
|
+
shape = function(data){
|
|
2962
|
+
var n, defined0, out, buf, i$, i, ok, d;
|
|
2963
|
+
data = asArray(data);
|
|
2964
|
+
n = data.length;
|
|
2965
|
+
defined0 = false;
|
|
2966
|
+
out = cv(buf = new Path(digits));
|
|
2967
|
+
for (i$ = 0; i$ <= n; ++i$) {
|
|
2968
|
+
i = i$;
|
|
2969
|
+
ok = false;
|
|
2970
|
+
if (i < n) {
|
|
2971
|
+
d = data[i];
|
|
2972
|
+
ok = !!defined(d, i, data);
|
|
2973
|
+
}
|
|
2974
|
+
if (!ok === defined0) {
|
|
2975
|
+
defined0 = !defined0;
|
|
2976
|
+
if (defined0) {
|
|
2977
|
+
out.lineStart();
|
|
2978
|
+
} else {
|
|
2979
|
+
out.lineEnd();
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
if (defined0) {
|
|
2983
|
+
out.point(+fx(d, i, data), +fy(d, i, data));
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
return buf.toString() || null;
|
|
2987
|
+
};
|
|
2988
|
+
shape.x = function(it){
|
|
2989
|
+
if (!arguments.length) {
|
|
2990
|
+
return fx;
|
|
2991
|
+
}
|
|
2992
|
+
fx = accessor(it);
|
|
2993
|
+
return shape;
|
|
2994
|
+
};
|
|
2995
|
+
shape.y = function(it){
|
|
2996
|
+
if (!arguments.length) {
|
|
2997
|
+
return fy;
|
|
2998
|
+
}
|
|
2999
|
+
fy = accessor(it);
|
|
3000
|
+
return shape;
|
|
3001
|
+
};
|
|
3002
|
+
shape.defined = function(it){
|
|
3003
|
+
if (!arguments.length) {
|
|
3004
|
+
return defined;
|
|
3005
|
+
}
|
|
3006
|
+
defined = typeof it === 'function'
|
|
3007
|
+
? it
|
|
3008
|
+
: constant(!!it);
|
|
3009
|
+
return shape;
|
|
3010
|
+
};
|
|
3011
|
+
shape.curve = function(it){
|
|
3012
|
+
if (!arguments.length) {
|
|
3013
|
+
return cv;
|
|
3014
|
+
}
|
|
3015
|
+
cv = it;
|
|
3016
|
+
return shape;
|
|
3017
|
+
};
|
|
3018
|
+
shape.digits = function(it){
|
|
3019
|
+
if (!arguments.length) {
|
|
3020
|
+
return digits;
|
|
3021
|
+
}
|
|
3022
|
+
digits = it != null ? Math.floor(it) : null;
|
|
3023
|
+
return shape;
|
|
3024
|
+
};
|
|
3025
|
+
return shape;
|
|
3026
|
+
};
|
|
3027
|
+
area = function(x0, y0, y1){
|
|
3028
|
+
var x1, defined, cv, digits, shape;
|
|
3029
|
+
x1 = null;
|
|
3030
|
+
defined = constant(true);
|
|
3031
|
+
cv = curveLinear;
|
|
3032
|
+
digits = 3;
|
|
3033
|
+
x0 = typeof x0 === 'function'
|
|
3034
|
+
? x0
|
|
3035
|
+
: x0 === undefined
|
|
3036
|
+
? function(p){
|
|
3037
|
+
return p[0];
|
|
3038
|
+
}
|
|
3039
|
+
: constant(+x0);
|
|
3040
|
+
y0 = typeof y0 === 'function'
|
|
3041
|
+
? y0
|
|
3042
|
+
: y0 === undefined
|
|
3043
|
+
? constant(0)
|
|
3044
|
+
: constant(+y0);
|
|
3045
|
+
y1 = typeof y1 === 'function'
|
|
3046
|
+
? y1
|
|
3047
|
+
: y1 === undefined
|
|
3048
|
+
? function(p){
|
|
3049
|
+
return p[1];
|
|
3050
|
+
}
|
|
3051
|
+
: constant(+y1);
|
|
3052
|
+
shape = function(data){
|
|
3053
|
+
var n, defined0, x0z, y0z, j, out, buf, i$, i, ok, d, k;
|
|
3054
|
+
data = asArray(data);
|
|
3055
|
+
n = data.length;
|
|
3056
|
+
defined0 = false;
|
|
3057
|
+
x0z = new Array(n);
|
|
3058
|
+
y0z = new Array(n);
|
|
3059
|
+
j = 0;
|
|
3060
|
+
out = cv(buf = new Path(digits));
|
|
3061
|
+
for (i$ = 0; i$ <= n; ++i$) {
|
|
3062
|
+
i = i$;
|
|
3063
|
+
ok = false;
|
|
3064
|
+
if (i < n) {
|
|
3065
|
+
d = data[i];
|
|
3066
|
+
ok = !!defined(d, i, data);
|
|
3067
|
+
}
|
|
3068
|
+
if (!ok === defined0) {
|
|
3069
|
+
defined0 = !defined0;
|
|
3070
|
+
if (defined0) {
|
|
3071
|
+
j = i;
|
|
3072
|
+
out.areaStart();
|
|
3073
|
+
out.lineStart();
|
|
3074
|
+
} else {
|
|
3075
|
+
out.lineEnd();
|
|
3076
|
+
out.lineStart();
|
|
3077
|
+
k = i - 1;
|
|
3078
|
+
while (k >= j) {
|
|
3079
|
+
out.point(x0z[k], y0z[k]);
|
|
3080
|
+
k--;
|
|
3081
|
+
}
|
|
3082
|
+
out.lineEnd();
|
|
3083
|
+
out.areaEnd();
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
if (defined0) {
|
|
3087
|
+
x0z[i] = +x0(d, i, data);
|
|
3088
|
+
y0z[i] = +y0(d, i, data);
|
|
3089
|
+
out.point(x1
|
|
3090
|
+
? +x1(d, i, data)
|
|
3091
|
+
: x0z[i], y1
|
|
3092
|
+
? +y1(d, i, data)
|
|
3093
|
+
: y0z[i]);
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
return buf.toString() || null;
|
|
3097
|
+
};
|
|
3098
|
+
shape.x = function(it){
|
|
3099
|
+
if (!arguments.length) {
|
|
3100
|
+
return x0;
|
|
3101
|
+
}
|
|
3102
|
+
x0 = accessor(it);
|
|
3103
|
+
x1 = null;
|
|
3104
|
+
return shape;
|
|
3105
|
+
};
|
|
3106
|
+
shape.x0 = function(it){
|
|
3107
|
+
if (!arguments.length) {
|
|
3108
|
+
return x0;
|
|
3109
|
+
}
|
|
3110
|
+
x0 = accessor(it);
|
|
3111
|
+
return shape;
|
|
3112
|
+
};
|
|
3113
|
+
shape.x1 = function(it){
|
|
3114
|
+
if (!arguments.length) {
|
|
3115
|
+
return x1;
|
|
3116
|
+
}
|
|
3117
|
+
x1 = it != null ? accessor(it) : null;
|
|
3118
|
+
return shape;
|
|
3119
|
+
};
|
|
3120
|
+
shape.y = function(it){
|
|
3121
|
+
if (!arguments.length) {
|
|
3122
|
+
return y0;
|
|
3123
|
+
}
|
|
3124
|
+
y0 = accessor(it);
|
|
3125
|
+
y1 = null;
|
|
3126
|
+
return shape;
|
|
3127
|
+
};
|
|
3128
|
+
shape.y0 = function(it){
|
|
3129
|
+
if (!arguments.length) {
|
|
3130
|
+
return y0;
|
|
3131
|
+
}
|
|
3132
|
+
y0 = accessor(it);
|
|
3133
|
+
return shape;
|
|
3134
|
+
};
|
|
3135
|
+
shape.y1 = function(it){
|
|
3136
|
+
if (!arguments.length) {
|
|
3137
|
+
return y1;
|
|
3138
|
+
}
|
|
3139
|
+
y1 = it != null ? accessor(it) : null;
|
|
3140
|
+
return shape;
|
|
3141
|
+
};
|
|
3142
|
+
shape.defined = function(it){
|
|
3143
|
+
if (!arguments.length) {
|
|
3144
|
+
return defined;
|
|
3145
|
+
}
|
|
3146
|
+
defined = typeof it === 'function'
|
|
3147
|
+
? it
|
|
3148
|
+
: constant(!!it);
|
|
3149
|
+
return shape;
|
|
3150
|
+
};
|
|
3151
|
+
shape.curve = function(it){
|
|
3152
|
+
if (!arguments.length) {
|
|
3153
|
+
return cv;
|
|
3154
|
+
}
|
|
3155
|
+
cv = it;
|
|
3156
|
+
return shape;
|
|
3157
|
+
};
|
|
3158
|
+
shape.digits = function(it){
|
|
3159
|
+
if (!arguments.length) {
|
|
3160
|
+
return digits;
|
|
3161
|
+
}
|
|
3162
|
+
digits = it != null ? Math.floor(it) : null;
|
|
3163
|
+
return shape;
|
|
3164
|
+
};
|
|
3165
|
+
return shape;
|
|
3166
|
+
};
|
|
3167
|
+
shape = {
|
|
3168
|
+
arc: arc,
|
|
3169
|
+
line: line,
|
|
3170
|
+
area: area,
|
|
3171
|
+
curve: curve,
|
|
3172
|
+
path: function(digits){
|
|
3173
|
+
return new Path(digits);
|
|
3174
|
+
}
|
|
3175
|
+
};
|
|
3176
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
3177
|
+
(chart.utils || (chart.utils = {})).shape = shape;
|
|
3178
|
+
}
|
|
3179
|
+
}).call(this);
|
|
3180
|
+
(function(){
|
|
3181
|
+
var clamp, turbo, discrete, quantize, color;
|
|
3182
|
+
clamp = function(v){
|
|
3183
|
+
return Math.max(0, Math.min(255, Math.round(v)));
|
|
3184
|
+
};
|
|
3185
|
+
turbo = function(t){
|
|
3186
|
+
var r, g, b;
|
|
3187
|
+
t = Math.max(0, Math.min(1, t));
|
|
3188
|
+
r = clamp(34.61 + t * (1172.33 - t * (10793.56 - t * (33300.12 - t * (38394.49 - t * 14825.05)))));
|
|
3189
|
+
g = clamp(23.31 + t * (557.33 + t * (1225.33 - t * (3574.96 - t * (1073.77 + t * 707.56)))));
|
|
3190
|
+
b = clamp(27.2 + t * (3211.1 - t * (15327.97 - t * (27814 - t * (22569.18 - t * 6838.66)))));
|
|
3191
|
+
return "rgb(" + r + ", " + g + ", " + b + ")";
|
|
3192
|
+
};
|
|
3193
|
+
discrete = function(range){
|
|
3194
|
+
var n;
|
|
3195
|
+
n = range.length;
|
|
3196
|
+
return function(t){
|
|
3197
|
+
return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
|
|
3198
|
+
};
|
|
3199
|
+
};
|
|
3200
|
+
quantize = function(interpolator, n){
|
|
3201
|
+
var i$, i, results$ = [];
|
|
3202
|
+
for (i$ = 0; i$ < n; ++i$) {
|
|
3203
|
+
i = i$;
|
|
3204
|
+
results$.push(interpolator(i / (n - 1)));
|
|
3205
|
+
}
|
|
3206
|
+
return results$;
|
|
3207
|
+
};
|
|
3208
|
+
color = {
|
|
3209
|
+
turbo: turbo,
|
|
3210
|
+
discrete: discrete,
|
|
3211
|
+
quantize: quantize
|
|
3212
|
+
};
|
|
3213
|
+
if (typeof chart != 'undefined' && chart !== null) {
|
|
3214
|
+
(chart.utils || (chart.utils = {})).color = color;
|
|
3215
|
+
}
|
|
3216
|
+
}).call(this);
|
|
3217
|
+
(function(){
|
|
3218
|
+
var svgns, now, ease, reNum, color, interpColor, interpString, interpolate, getV, setV, rmV, anim, join;
|
|
1730
3219
|
svgns = "http://www.w3.org/2000/svg";
|
|
1731
3220
|
now = function(){
|
|
1732
3221
|
if (typeof performance != 'undefined' && performance !== null) {
|
|
@@ -1803,7 +3292,10 @@ var chart = module.exports;
|
|
|
1803
3292
|
var ref$, ref1$;
|
|
1804
3293
|
return (ref$ = (ref1$ = Math.round(it)) > 0 ? ref1$ : 0) < 255 ? ref$ : 255;
|
|
1805
3294
|
}), r = ref$[0], g = ref$[1], bl = ref$[2];
|
|
1806
|
-
|
|
3295
|
+
al = isNaN(al)
|
|
3296
|
+
? 1
|
|
3297
|
+
: (ref$ = al > 0 ? al : 0) < 1 ? ref$ : 1;
|
|
3298
|
+
if (al === 1) {
|
|
1807
3299
|
return "rgb(" + r + ", " + g + ", " + bl + ")";
|
|
1808
3300
|
} else {
|
|
1809
3301
|
return "rgba(" + r + ", " + g + ", " + bl + ", " + al + ")";
|
|
@@ -1880,18 +3372,44 @@ var chart = module.exports;
|
|
|
1880
3372
|
}
|
|
1881
3373
|
return interpString(a, b);
|
|
1882
3374
|
};
|
|
3375
|
+
getV = function(node, k){
|
|
3376
|
+
if (k.startsWith('style:')) {
|
|
3377
|
+
return node.style.getPropertyValue(k.slice(6));
|
|
3378
|
+
} else {
|
|
3379
|
+
return node.getAttribute(k);
|
|
3380
|
+
}
|
|
3381
|
+
};
|
|
3382
|
+
setV = function(node, k, v){
|
|
3383
|
+
if (k.startsWith('style:')) {
|
|
3384
|
+
return node.style.setProperty(k.slice(6), v);
|
|
3385
|
+
} else {
|
|
3386
|
+
return node.setAttribute(k, v);
|
|
3387
|
+
}
|
|
3388
|
+
};
|
|
3389
|
+
rmV = function(node, k){
|
|
3390
|
+
if (k.startsWith('style:')) {
|
|
3391
|
+
return node.style.removeProperty(k.slice(6));
|
|
3392
|
+
} else {
|
|
3393
|
+
return node.removeAttribute(k);
|
|
3394
|
+
}
|
|
3395
|
+
};
|
|
1883
3396
|
anim = function(opt){
|
|
1884
3397
|
var this$ = this;
|
|
1885
3398
|
opt == null && (opt = {});
|
|
1886
3399
|
this._manual = !!opt.manual;
|
|
1887
3400
|
this._now = 0;
|
|
1888
|
-
this.
|
|
3401
|
+
this._base = 0;
|
|
3402
|
+
this._since = now();
|
|
3403
|
+
this._speed = 1;
|
|
3404
|
+
this._frozen = false;
|
|
3405
|
+
this._dur = 350;
|
|
3406
|
+
this._back = 0;
|
|
1889
3407
|
this._raf = null;
|
|
1890
3408
|
this._list = new Map();
|
|
1891
3409
|
this.evtHandler = {};
|
|
1892
3410
|
this._tick = function(t){
|
|
1893
3411
|
this$._raf = null;
|
|
1894
|
-
if (this$._manual) {
|
|
3412
|
+
if (this$._manual || this$._frozen) {
|
|
1895
3413
|
return;
|
|
1896
3414
|
}
|
|
1897
3415
|
this$._apply(this$.time());
|
|
@@ -1927,9 +3445,80 @@ var chart = module.exports;
|
|
|
1927
3445
|
time: function(){
|
|
1928
3446
|
if (this._manual) {
|
|
1929
3447
|
return this._now;
|
|
3448
|
+
} else if (this._frozen) {
|
|
3449
|
+
return this._base;
|
|
1930
3450
|
} else {
|
|
1931
|
-
return now() - this.
|
|
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;
|
|
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;
|
|
1932
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;
|
|
1933
3522
|
},
|
|
1934
3523
|
manual: function(v){
|
|
1935
3524
|
if (!arguments.length) {
|
|
@@ -1947,7 +3536,8 @@ var chart = module.exports;
|
|
|
1947
3536
|
}
|
|
1948
3537
|
this._raf = null;
|
|
1949
3538
|
} else {
|
|
1950
|
-
this.
|
|
3539
|
+
this._base = this._now;
|
|
3540
|
+
this._since = now();
|
|
1951
3541
|
this._manual = false;
|
|
1952
3542
|
if (this._list.size) {
|
|
1953
3543
|
this._kick();
|
|
@@ -1960,6 +3550,7 @@ var chart = module.exports;
|
|
|
1960
3550
|
if (!this._manual) {
|
|
1961
3551
|
this.manual(true);
|
|
1962
3552
|
}
|
|
3553
|
+
dt = dt * this._speed;
|
|
1963
3554
|
this._now += dt;
|
|
1964
3555
|
this._apply(this._now);
|
|
1965
3556
|
this.fire('step', this._now, dt);
|
|
@@ -1986,7 +3577,7 @@ var chart = module.exports;
|
|
|
1986
3577
|
},
|
|
1987
3578
|
_kick: function(){
|
|
1988
3579
|
var this$ = this;
|
|
1989
|
-
if (this._manual || this._raf) {
|
|
3580
|
+
if (this._manual || this._frozen || this._raf) {
|
|
1990
3581
|
return;
|
|
1991
3582
|
}
|
|
1992
3583
|
if (!(typeof requestAnimationFrame != 'undefined' && requestAnimationFrame !== null)) {
|
|
@@ -1997,11 +3588,12 @@ var chart = module.exports;
|
|
|
1997
3588
|
return this._raf = requestAnimationFrame(this._tick);
|
|
1998
3589
|
},
|
|
1999
3590
|
tween: function(node, attrs, opt){
|
|
2000
|
-
var dur, delay, ez, immediate, item, start, k, v;
|
|
3591
|
+
var r, dur, delay, ez, immediate, item, start, k, v;
|
|
2001
3592
|
attrs == null && (attrs = {});
|
|
2002
3593
|
opt == null && (opt = {});
|
|
2003
|
-
|
|
2004
|
-
|
|
3594
|
+
r = this._dur / 350;
|
|
3595
|
+
dur = (opt.duration != null ? opt.duration : 350) * r;
|
|
3596
|
+
delay = (opt.delay || 0) * r;
|
|
2005
3597
|
ez = typeof opt.ease === 'function'
|
|
2006
3598
|
? opt.ease
|
|
2007
3599
|
: ease[opt.ease || 'cubic-in-out'] || ease.cubicInOut;
|
|
@@ -2014,17 +3606,26 @@ var chart = module.exports;
|
|
|
2014
3606
|
if (opt.end) {
|
|
2015
3607
|
item.cb.push(opt.end);
|
|
2016
3608
|
}
|
|
2017
|
-
start = this.time() + delay;
|
|
3609
|
+
start = this.time() - this._back + delay;
|
|
2018
3610
|
for (k in attrs) {
|
|
2019
3611
|
v = attrs[k];
|
|
2020
3612
|
if (!(v != null)) {
|
|
2021
|
-
node
|
|
3613
|
+
rmV(node, k);
|
|
2022
3614
|
delete item.attr[k];
|
|
2023
3615
|
continue;
|
|
2024
3616
|
}
|
|
2025
3617
|
if (immediate) {
|
|
2026
|
-
node
|
|
3618
|
+
setV(node, k, typeof v === 'function' ? v(1) : v);
|
|
2027
3619
|
delete item.attr[k];
|
|
3620
|
+
} else if (k.startsWith('style:') && !node.style.getPropertyValue(k.slice(6)) && window.getComputedStyle(node).getPropertyValue(k.slice(6)) === v + "") {
|
|
3621
|
+
delete item.attr[k];
|
|
3622
|
+
} else if (typeof v === 'function') {
|
|
3623
|
+
item.attr[k] = {
|
|
3624
|
+
fn: v,
|
|
3625
|
+
start: start,
|
|
3626
|
+
dur: dur > 0 ? dur : 0,
|
|
3627
|
+
ease: ez
|
|
3628
|
+
};
|
|
2028
3629
|
} else {
|
|
2029
3630
|
item.attr[k] = {
|
|
2030
3631
|
to: v,
|
|
@@ -2069,15 +3670,25 @@ var chart = module.exports;
|
|
|
2069
3670
|
if (t < a.start) {
|
|
2070
3671
|
continue;
|
|
2071
3672
|
}
|
|
3673
|
+
if (a.fn) {
|
|
3674
|
+
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
3675
|
+
setV(node, k, a.fn(p >= 1
|
|
3676
|
+
? 1
|
|
3677
|
+
: a.ease(p)));
|
|
3678
|
+
if (p >= 1) {
|
|
3679
|
+
delete item.attr[k];
|
|
3680
|
+
}
|
|
3681
|
+
continue;
|
|
3682
|
+
}
|
|
2072
3683
|
if (!a.interp) {
|
|
2073
|
-
a.interp = interpolate(node
|
|
3684
|
+
a.interp = interpolate(getV(node, k), a.to);
|
|
2074
3685
|
}
|
|
2075
3686
|
p = a.dur ? (ref2$ = (t - a.start) / a.dur) < 1 ? ref2$ : 1 : 1;
|
|
2076
3687
|
if (p >= 1) {
|
|
2077
|
-
node
|
|
3688
|
+
setV(node, k, a.to);
|
|
2078
3689
|
delete item.attr[k];
|
|
2079
3690
|
} else {
|
|
2080
|
-
node
|
|
3691
|
+
setV(node, k, a.interp(a.ease(p)));
|
|
2081
3692
|
}
|
|
2082
3693
|
}
|
|
2083
3694
|
if (!(fn$()).length) {
|
|
@@ -2095,7 +3706,7 @@ var chart = module.exports;
|
|
|
2095
3706
|
}
|
|
2096
3707
|
});
|
|
2097
3708
|
join = function(arg$){
|
|
2098
|
-
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit;
|
|
3709
|
+
var root, tag, ref$, cls, data, key, olds, map, enter, update, nodes, exit, nx, i$, i, n;
|
|
2099
3710
|
root = arg$.root, tag = (ref$ = arg$.tag) != null ? ref$ : 'g', cls = arg$.cls, data = (ref$ = arg$.data) != null
|
|
2100
3711
|
? ref$
|
|
2101
3712
|
: [], key = arg$.key;
|
|
@@ -2127,12 +3738,24 @@ var chart = module.exports;
|
|
|
2127
3738
|
if (cls) {
|
|
2128
3739
|
n.setAttribute('class', cls);
|
|
2129
3740
|
}
|
|
2130
|
-
|
|
3741
|
+
n._entering = true;
|
|
2131
3742
|
enter.push(n);
|
|
2132
3743
|
}
|
|
2133
3744
|
n.__data__ = d;
|
|
2134
3745
|
return nodes.push(n);
|
|
2135
3746
|
});
|
|
3747
|
+
nx = null;
|
|
3748
|
+
for (i$ = nodes.length - 1; i$ >= 0; --i$) {
|
|
3749
|
+
i = i$;
|
|
3750
|
+
n = nodes[i];
|
|
3751
|
+
if (!n._entering) {
|
|
3752
|
+
nx = n;
|
|
3753
|
+
continue;
|
|
3754
|
+
}
|
|
3755
|
+
delete n._entering;
|
|
3756
|
+
root.insertBefore(n, nx);
|
|
3757
|
+
nx = n;
|
|
3758
|
+
}
|
|
2136
3759
|
exit = exit.concat(Array.from(map.values()));
|
|
2137
3760
|
return {
|
|
2138
3761
|
enter: enter,
|
|
@@ -2245,8 +3868,10 @@ var chart = module.exports;
|
|
|
2245
3868
|
this._g = g;
|
|
2246
3869
|
g.setAttribute('fill', 'none');
|
|
2247
3870
|
g.setAttribute('pointer-events', 'all');
|
|
2248
|
-
|
|
2249
|
-
|
|
3871
|
+
if (((typeof navigator != 'undefined' && navigator !== null) && navigator.maxTouchPoints) || 'ontouchstart' in g) {
|
|
3872
|
+
g.style.touchAction = 'none';
|
|
3873
|
+
g.style.setProperty('-webkit-tap-highlight-color', "rgba(0,0,0,0)");
|
|
3874
|
+
}
|
|
2250
3875
|
mk = function(cls, type, attrs){
|
|
2251
3876
|
var n, k, v;
|
|
2252
3877
|
attrs == null && (attrs = {});
|