-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathpolychart2.js
12161 lines (10515 loc) · 336 KB
/
polychart2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Polychart.js
* Copyright (c) Polychart Inc
* All Rights Reserved
*/
window.polyjs = (function(polyjs) {
if (!polyjs) {
var poly = {};
// Generated by CoffeeScript 1.6.2
/*
Group an array of data items by the value of certain columns.
Input:
- `data`: an array of data items
- `group`: an array of column keys, to group by
Output:
- an associate array of key: array of data, with the appropriate grouping
the `key` is a string of format "columnKey:value;colunmKey2:value2;..."
*/
(function() {
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
poly.groupBy = function(data, group) {
return _.groupBy(data, poly.stringify(group));
};
poly.stringify = function(group) {
return function(item) {
var concat;
concat = function(memo, g) {
return "" + memo + g + ":" + item[g] + ";";
};
return _.reduce(group, concat, "");
};
};
poly.cross = function(keyVals, ignore) {
var arrs, i, item, items, next, todo, val, _i, _j, _len, _len1, _ref;
if (ignore == null) {
ignore = [];
}
todo = _.difference(_.keys(keyVals), ignore);
if (todo.length === 0) {
return [{}];
}
arrs = [];
next = todo[0];
items = poly.cross(keyVals, ignore.concat(next));
_ref = keyVals[next];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
val = _ref[_i];
for (_j = 0, _len1 = items.length; _j < _len1; _j++) {
item = items[_j];
i = _.clone(item);
i[next] = val;
arrs.push(i);
}
}
return arrs;
};
poly.filter = function(statData, key, val) {
var item, newData, _i, _len;
newData = [];
for (_i = 0, _len = statData.length; _i < _len; _i++) {
item = statData[_i];
if (item[key] === val) {
newData.push(item);
}
}
return newData;
};
/*
Intersets values when filter key is common to both objects, add all values otherwise.
TODO: handle the case when no intersection exist from a given common key
*/
poly.intersect = function(filter1, filter2) {
var intersectIneq, intersectList, key, newFilter, val;
intersectList = function(key) {
var elem, newList, _i, _len, _ref;
newList = [];
_ref = filter1[key]["in"];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
elem = _ref[_i];
if (__indexOf.call(filter2[key]["in"], elem) >= 0) {
newList.push(elem);
}
}
return {
"in": newList
};
};
intersectIneq = function(key) {
var addbound, getLowerBound, getUpperBound, lowers, newIneq, type, uppers, val, _ref, _ref1;
getUpperBound = function(filter) {
if (filter[key].lt) {
return {
type: "lt",
val: filter[key].lt
};
} else if (filter[key].le) {
return {
type: "le",
val: filter[key].le
};
} else {
return {
type: null,
val: null
};
}
};
getLowerBound = function(filter) {
if (filter[key].gt) {
return {
type: "gt",
val: filter[key].gt
};
} else if (filter[key].ge) {
return {
type: "ge",
val: filter[key].ge
};
} else {
return {
type: null,
val: null
};
}
};
addbound = function(bound) {
return newIneq[bound.type] = bound.val;
};
lowers = [getLowerBound(filter1), getLowerBound(filter2)];
uppers = [getUpperBound(filter1), getUpperBound(filter2)];
lowers.sort(function(a, b) {
return b.val - a.val;
});
uppers.sort(function(a, b) {
return a.val - b.val;
});
newIneq = {};
if (lowers[0].type && lowers[0].val) {
_ref = lowers[0], type = _ref.type, val = _ref.val;
if (lowers[0].val === lowers[1].val && lowers[0].type !== lowers[1].type) {
type = "lt";
}
newIneq[type] = val;
}
if (uppers[0].type && uppers[0].val) {
_ref1 = uppers[0], type = _ref1.type, val = _ref1.val;
if (uppers[0].val === uppers[1].val && uppers[0].type !== uppers[1].type) {
type = "lt";
}
newIneq[type] = val;
}
if (lowers[0].type && uppers[0].type) {
if (lowers[0].val > uppers[0].val || (lowers[0].val === uppers[0].val && (lowers[0].key === "lt" || uppers[0].key === "gt"))) {
throw "No intersection found!";
}
}
return newIneq;
};
newFilter = {};
for (key in filter1) {
val = filter1[key];
if (key in filter2) {
if ("in" in filter1[key]) {
newFilter[key] = intersectList(key);
} else {
newFilter[key] = intersectIneq(key);
}
} else {
newFilter[key] = val;
}
}
for (key in filter2) {
val = filter2[key];
if (!(key in newFilter)) {
newFilter[key] = val;
}
}
return newFilter;
};
/*
Produces a linear function that passes through two points.
Input:
- `x1`: x coordinate of the first point
- `y1`: y coordinate of the first point
- `x2`: x coordinate of the second point
- `y2`: y coordinate of the second point
Output:
- A function that, given the x-coord, returns the y-coord
*/
poly.linear = function(x1, y1, x2, y2) {
if (_.isFinite(x1) && _.isFinite(y1) && _.isFinite(x2) && _.isFinite(y2)) {
return function(x) {
return (y2 - y1) / (x2 - x1) * (x - x1) + y1;
};
} else {
throw poly.error.input("Attempting to create linear function from infinity");
}
};
/*
given a sorted list and a midpoint calculate the median
*/
poly.median = function(values, sorted) {
var mid;
if (sorted == null) {
sorted = false;
}
if (!sorted) {
values = _.sortBy(values, function(x) {
return x;
});
}
mid = values.length / 2;
if (mid % 1 !== 0) {
return values[Math.floor(mid)];
}
return (values[mid - 1] + values[mid]) / 2;
};
/*
Produces a function that counts how many times it has been called
*/
poly.counter = function() {
var i;
i = 0;
return function() {
return i++;
};
};
/*
Sample an associate array (object)
*/
poly.sample = function(assoc, num) {
return _.pick(assoc, _.shuffle(_.keys(assoc)).splice(0, num));
};
/*
Given an OLD array and NEW array, split the points in (OLD union NEW) into
three sets:
- deleted
- kept
- added
*/
poly.compare = function(oldarr, newarr) {
var added, deleted, kept, newElem, newIndex, oldElem, oldIndex, sortedNewarr, sortedOldarr;
sortedOldarr = _.sortBy(oldarr, function(x) {
return x;
});
sortedNewarr = _.sortBy(newarr, function(x) {
return x;
});
deleted = [];
kept = [];
added = [];
oldIndex = newIndex = 0;
while (oldIndex < sortedOldarr.length || newIndex < sortedNewarr.length) {
oldElem = sortedOldarr[oldIndex];
newElem = sortedNewarr[newIndex];
if (oldIndex >= sortedOldarr.length) {
added.push(newElem);
newIndex += 1;
} else if (newIndex >= sortedNewarr.length) {
deleted.push(oldElem);
oldIndex += 1;
} else if (oldElem < newElem) {
deleted.push(oldElem);
oldIndex += 1;
} else if (oldElem > newElem) {
added.push(newElem);
newIndex += 1;
} else if (oldElem === newElem) {
kept.push(oldElem);
oldIndex += 1;
newIndex += 1;
} else {
throw DataError("Unknown data encounted");
}
}
return {
deleted: deleted,
kept: kept,
added: added
};
};
/*
Given an aesthetic mapping in the "geom" object, flatten it and extract only
the values from it. This is so that even if a compound object is encoded in an
aestehtic, we have the correct set of values to calculate the min/max.
*/
poly.flatten = function(values) {
var flat, k, v, _i, _len;
flat = [];
if (values != null) {
if (_.isObject(values)) {
if (values.t === 'scalefn') {
if (values.f !== 'novalue') {
flat.push(values.v);
}
} else {
for (k in values) {
v = values[k];
flat = flat.concat(poly.flatten(v));
}
}
} else if (_.isArray(values)) {
for (_i = 0, _len = values.length; _i < _len; _i++) {
v = values[_i];
flat = flat.concat(poly.flatten(v));
}
} else {
flat.push(values);
}
}
return flat;
};
/*
GET LABEL
TODO: move somewhere else and allow overwrite by user
*/
poly.getLabel = function(layers, aes) {
return _.chain(layers).map(function(l) {
return l.mapping[aes];
}).without(null, void 0).uniq().value().join(' | ');
};
/*
Estimate the number of pixels rendering this string would take...?
*/
poly.strSize = function(str) {
var len;
len = (str + "").length;
if (len < 10) {
return len * 6;
} else {
return (len - 10) * 5 + 60;
}
};
/*
Sort Arrays: given a sorting function and some number of arrays, sort all the
arrays by the function applied to the first array. This is used for sorting
points for a line chart, i.e. poly.sortArrays(sortFn, [xs, ys])
This way, all the points are sorted by (sortFn(x) for x in xs)
*/
poly.sortArrays = function(fn, arrays) {
var zipped;
zipped = _.zip.apply(_, arrays);
zipped.sort(function(a, b) {
return fn(a[0], b[0]);
});
return _.zip.apply(_, zipped);
};
/*
Determine if a value is not null and not undefined.
*/
poly.isDefined = function(x) {
if (_.isObject(x)) {
if (x.t === 'scalefn' && x.f !== 'novalue') {
return poly.isDefined(x.v);
} else {
return true;
}
} else {
return x !== void 0 && x !== null && !(_.isNumber(x) && _.isNaN(x));
}
};
/*
Determine if a String is a valid URI
http://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-an-url
*/
poly.isURI = function(str) {
var pattern;
if (!_.isString(str)) {
return false;
} else {
pattern = new RegExp('^(https?:\\/\\/)?' + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + '((\\d{1,3}\\.){3}\\d{1,3}))' + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + '(\\?[;&a-z\\d%_.~+=-]*)?' + '(\\#[-a-z\\d_]*)?$', 'i');
return pattern.test(str);
}
};
}).call(this);
// Generated by CoffeeScript 1.6.2
/*
CONSTANTS
---------
These are constants that are referred to throughout the coebase
*/
(function() {
poly["const"] = {
aes: ['x', 'y', 'color', 'size', 'opacity', 'shape', 'id', 'text'],
pivot_aes: ['row', 'column', 'value'],
noDomain: ['id', 'text', 'tooltip'],
noLegend: ['x', 'y', 'id', 'text', 'tooltip'],
trans: {
'bin': ['key', 'binwidth'],
'lag': ['key', 'lag']
},
stat: {
'count': ['key'],
'unique': ['key'],
'sum': ['key'],
'mean': ['key'],
'box': ['key'],
'median': ['key']
},
timerange: ['second', 'minute', 'hour', 'day', 'week', 'month', 'twomonth', 'quarter', 'sixmonth', 'year', 'twoyear', 'fiveyear', 'decade'],
approxTimeInSeconds: {
second: 1,
minute: 60,
hour: 60 * 60,
day: 60 * 60 * 24,
week: 60 * 60 * 24 * 7,
month: 60 * 60 * 24 * 30,
twomonth: 60 * 60 * 24 * 30 * 2,
quarter: 60 * 60 * 24 * 30 * 4,
sixmonth: 60 * 60 * 24 * 30 * 6,
year: 60 * 60 * 24 * 365,
twoyear: 60 * 60 * 24 * 365 * 2,
fiveyear: 60 * 60 * 24 * 365 * 5 + 60 * 60 * 24
},
sort: {
key: null,
sort: null,
limit: null,
asc: false
},
scaleFns: {
novalue: function() {
return {
v: null,
f: 'novalue',
t: 'scalefn'
};
},
max: function(v) {
return {
v: v,
f: 'max',
t: 'scalefn'
};
},
min: function(v) {
return {
v: v,
f: 'min',
t: 'scalefn'
};
},
upper: function(v, n, m) {
return {
v: v,
n: n,
m: m,
f: 'upper',
t: 'scalefn'
};
},
lower: function(v, n, m) {
return {
v: v,
n: n,
m: m,
f: 'lower',
t: 'scalefn'
};
},
middle: function(v) {
return {
v: v,
f: 'middle',
t: 'scalefn'
};
},
jitter: function(v) {
return {
v: v,
f: 'jitter',
t: 'scalefn'
};
},
identity: function(v) {
return {
v: v,
f: 'identity',
t: 'scalefn'
};
}
},
epsilon: Math.pow(10, -7),
defaults: {
'x': {
v: null,
f: 'novalue',
t: 'scalefn'
},
'y': {
v: null,
f: 'novalue',
t: 'scalefn'
},
'color': 'steelblue',
'size': 2,
'opacity': 0.7
}
};
}).call(this);
// Generated by CoffeeScript 1.6.2
(function() {
var DataError, DefinitionError, DependencyError, MissingData, ModeError, NotImplemented, ScaleError, Type, UnknownInput,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
DefinitionError = (function(_super) {
__extends(DefinitionError, _super);
function DefinitionError(message) {
this.message = message;
this.name = "DefinitionError";
}
return DefinitionError;
})(Error);
DependencyError = (function(_super) {
__extends(DependencyError, _super);
function DependencyError(message) {
this.message = message;
this.name = "DependencyError";
}
return DependencyError;
})(Error);
ModeError = (function(_super) {
__extends(ModeError, _super);
function ModeError(message) {
this.message = message;
this.name = "ModeError";
}
return ModeError;
})(Error);
DataError = (function(_super) {
__extends(DataError, _super);
function DataError(message) {
this.message = message;
this.name = "DataError";
}
return DataError;
})(Error);
UnknownInput = (function(_super) {
__extends(UnknownInput, _super);
function UnknownInput(message) {
this.message = message;
this.name = "UnknownInput";
}
return UnknownInput;
})(Error);
NotImplemented = (function(_super) {
__extends(NotImplemented, _super);
function NotImplemented(message) {
this.message = message;
this.name = "ModeError";
}
return NotImplemented;
})(Error);
ScaleError = (function(_super) {
__extends(ScaleError, _super);
function ScaleError(message) {
this.message = message;
this.name = "ScaleError";
}
return ScaleError;
})(Error);
MissingData = (function(_super) {
__extends(MissingData, _super);
function MissingData(message) {
this.message = message;
this.name = "MissingData";
}
return MissingData;
})(Error);
Type = (function(_super) {
__extends(Type, _super);
function Type(message) {
this.message = message;
this.name = "Type";
}
return Type;
})(Error);
poly.error = function(msg) {
return new Error(msg);
};
poly.error.data = function(msg) {
return new DataError(msg);
};
poly.error.depn = function(msg) {
return new DependencyError(msg);
};
poly.error.defn = function(msg) {
return new DefinitionError(msg);
};
poly.error.mode = function(msg) {
return new ModeError(msg);
};
poly.error.impl = function(msg) {
return new NotImplemented(msg);
};
poly.error.input = function(msg) {
return new UnknownInput(msg);
};
poly.error.scale = function(msg) {
return new ScaleError(msg);
};
poly.error.missing = function(msg) {
return new MissingData(msg);
};
poly.error.type = function(msg) {
return new Type(msg);
};
}).call(this);
// Generated by CoffeeScript 1.6.2
/*
Abstract Classes
---------
Abstract classes, almost used like interfaces throughout the codebase
*/
(function() {
var Geometry, Guide, GuideSet, Renderable, _ref, _ref1,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Renderable = (function() {
function Renderable() {}
Renderable.prototype.render = function() {
return poly.error.impl();
};
Renderable.prototype.dispose = function() {
return poly.error.impl();
};
return Renderable;
})();
Guide = (function(_super) {
__extends(Guide, _super);
function Guide() {
_ref = Guide.__super__.constructor.apply(this, arguments);
return _ref;
}
Guide.prototype.getDimension = function() {
throw poly.error.impl();
};
return Guide;
})(Renderable);
GuideSet = (function(_super) {
__extends(GuideSet, _super);
function GuideSet() {
_ref1 = GuideSet.__super__.constructor.apply(this, arguments);
return _ref1;
}
GuideSet.prototype.getDimension = function() {
throw poly.error.impl();
};
GuideSet.prototype.make = function() {
throw poly.error.impl();
};
return GuideSet;
})(Renderable);
/*
This should probably be in its own class folder, and should technically
be named "Renderable", but whatever. It manages what is currently on the
screen, and what needs to be rendered.
@geoms : a key-value pair of an identifier to a group of objects to be
rendered. It should be of the following form:
@geoms = {
'id' : {
marks: {
# an assoc array of renderable "marks", acceptable by
# poly.render() function
},
evtData: {
# data bound to a click/mouseover/mouseout event
# on the marks plotted
},
tooltip: # tooltip text to show on mouseover
}
}
@pts : a key-value pair of identfier to a group of objects rendered.
the group of objects is also a key-value pair, corresponding
to the key-value pair provided by `marks` as above.
*/
Geometry = (function(_super) {
__extends(Geometry, _super);
function Geometry(type) {
this.type = type != null ? type : null;
this.dispose = __bind(this.dispose, this);
this.geoms = {};
this.pts = {};
}
Geometry.prototype.set = function(geoms) {
return this.geoms = geoms;
};
Geometry.prototype.render = function(renderer) {
var added, deleted, id, kept, newpts, _i, _j, _k, _len, _len1, _len2, _ref2;
newpts = {};
_ref2 = poly.compare(_.keys(this.pts), _.keys(this.geoms)), deleted = _ref2.deleted, kept = _ref2.kept, added = _ref2.added;
for (_i = 0, _len = deleted.length; _i < _len; _i++) {
id = deleted[_i];
this._delete(renderer, this.pts[id]);
}
for (_j = 0, _len1 = added.length; _j < _len1; _j++) {
id = added[_j];
newpts[id] = this._add(renderer, this.geoms[id]);
}
for (_k = 0, _len2 = kept.length; _k < _len2; _k++) {
id = kept[_k];
newpts[id] = this._modify(renderer, this.pts[id], this.geoms[id]);
}
return this.pts = newpts;
};
Geometry.prototype._delete = function(renderer, points) {
var id2, pt, _results;
_results = [];
for (id2 in points) {
pt = points[id2];
_results.push(renderer.remove(pt));
}
return _results;
};
Geometry.prototype._modify = function(renderer, points, geom) {
var error, id2, mark, objs, _ref2;
objs = {};
_ref2 = geom.marks;
for (id2 in _ref2) {
mark = _ref2[id2];
try {
objs[id2] = points[id2] ? points[id2].data('m').type === mark.type ? renderer.animate(points[id2], mark, geom.evtData, geom.tooltip) : (renderer.remove(points[id2]), renderer.add(mark, geom.evtData, geom.tooltip, this.type)) : renderer.add(mark, geom.evtData, geom.tooltip, this.type);
} catch (_error) {
error = _error;
if (error.name === 'MissingData') {
console.log(error.message);
} else {
throw error;
}
}
}
return objs;
};
Geometry.prototype._add = function(renderer, geom) {
var error, id2, mark, objs, _ref2;
objs = {};
_ref2 = geom.marks;
for (id2 in _ref2) {
mark = _ref2[id2];
try {
objs[id2] = renderer.add(mark, geom.evtData, geom.tooltip, this.type);
} catch (_error) {
error = _error;
if (error.name === 'MissingData') {
console.log(error.message);
} else {
throw error;
}
}
}
return objs;
};
Geometry.prototype.dispose = function(renderer) {
var id, pt, _ref2;
_ref2 = this.pts;
for (id in _ref2) {
pt = _ref2[id];
this._delete(renderer, pt);
}
return this.pts = {};
};
return Geometry;
})(Renderable);
poly.Renderable = Renderable;
poly.Guide = Guide;
poly.GuideSet = GuideSet;
poly.Geometry = Geometry;
}).call(this);
// Generated by CoffeeScript 1.6.2
(function() {
var PolyCanvas, PolyCanvasItem,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
PolyCanvas = (function() {
function PolyCanvas(dom, w, h) {
if (dom.getContext) {
this.context = dom.getContext('2d');
} else {
dom.polyGeom = this;
}
dom.width = w;
dom.height = h;
this.items = [];
this._counter = 0;
}
PolyCanvas.prototype._makeItem = function(type, args) {
var item;
item = new PolyCanvasItem(type, this._newId(), this, args);
this.items.unshift(item);
return item;
};
PolyCanvas.prototype._newId = function() {
return this._counter += 1;
};
PolyCanvas.prototype.rect = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return this._makeItem('rect', args);
};
PolyCanvas.prototype.circle = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return this._makeItem('circle', args);
};
PolyCanvas.prototype.path = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return this._makeItem('path', args);
};
PolyCanvas.prototype.text = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return this._makeItem('text', args);
};
PolyCanvas.prototype.remove = function(id) {
var i, item, _i, _len, _ref;
_ref = this.items;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
item = _ref[i];
if (item.id === id) {
return this.items.splice(i, 1);
}
}
};
PolyCanvas.prototype.toBack = function(id) {
var bg, item;
item = this.remove(id)[0];
bg = this.items.pop();
this.items.push(item);
return this.items.push(bg);
};
PolyCanvas.prototype.toFront = function(id) {