src/js/widgets/stackGraphWidget.js
branchpopcorn-port
changeset 675 82a5ebbedc83
parent 661 48c1beea7b1c
child 676 499d9693d066
equal deleted inserted replaced
662:5e10069c5c21 675:82a5ebbedc83
    26                 "description" : "question",
    26                 "description" : "question",
    27                 "color" : "#036AAE",
    27                 "color" : "#036AAE",
    28             },
    28             },
    29         ],
    29         ],
    30         _defaultDefColor = "#585858";
    30         _defaultDefColor = "#585858";
    31     this.height = (this._config.height ? this._config.height : 50);
    31     this.height =  this._config.height || 50;
    32     this.width = this.selector.width();
    32     this.width = this.selector.width();
    33     this.isStreamGraph = (this._config.streamgraph ? this._config.streamgraph : false);
    33     this.isStreamGraph = this._config.streamgraph || false;
    34     this.sliceCount = (this._config.slices ? this._config.slices : ~~(this.width/(this.isStreamGraph ? 20 : 5)));
    34     this.sliceCount = this._config.slices || ~~(this.width/(this.isStreamGraph ? 20 : 5));
    35     this.tagconf = (this._config.tags
    35     this.tagconf = (this._config.tags
    36         ? this._config.tags
    36         ? this._config.tags
    37         : _defaultTags);
    37         : _defaultTags);
    38     IriSP._(this.tagconf).each(function(_a) {
    38     IriSP._(this.tagconf).each(function(_a) {
    39         _a.regexp = new RegExp(_a.keywords.map(function(_k) {
    39         _a.regexp = new RegExp(_a.keywords.map(function(_k) {
    47     this.groups = [];
    47     this.groups = [];
    48     this.duration = this._serializer.currentMedia().meta["dc:duration"];
    48     this.duration = this._serializer.currentMedia().meta["dc:duration"];
    49     
    49     
    50     var _annotationType = this._serializer.getTweets(),
    50     var _annotationType = this._serializer.getTweets(),
    51         _sliceDuration = ~~ ( this.duration / this.sliceCount),
    51         _sliceDuration = ~~ ( this.duration / this.sliceCount),
    52         _annotations = IriSP._(this._serializer._data.annotations).filter(function(_a) {
    52         _annotations = this._serializer._data.annotations,
    53             return ( _a.meta && _a.meta["id-ref"] && ( _a.meta["id-ref"] == _annotationType ) );
    53         _groupedAnnotations = IriSP._.range(this.sliceCount).map(function(_i) {
    54         }),
    54             return _annotations.filter(function(_a){
    55         _groupedAnnotations = IriSP._(_annotations).groupBy(function(_a) {
    55                 return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration)
    56             return ~~ (_a.begin / _sliceDuration);
    56             });
    57         }),
    57         }),
    58         _max = IriSP._(_groupedAnnotations).max(function(_g) {
    58         _max = IriSP._(_groupedAnnotations).max(function(_g) {
    59             return _g.length
    59             return _g.length
    60         }).length,
    60         }).length,
    61         _scale = this.height / _max,
    61         _scale = this.height / _max,
    62         _width = this.width / this.sliceCount;
    62         _width = this.width / this.sliceCount
       
    63         _showTitle = !this._config.excludeTitle,
       
    64         _showDescription = !this._config.excludeDescription;
    63     
    65     
    64     
    66     
    65     var _paths = this.tagconf.map(function() {
    67     var _paths = this.tagconf.map(function() {
    66         return [];
    68         return [];
    67     });
    69     });
    72         if (_group) {
    74         if (_group) {
    73             var _vol = this.tagconf.map(function() {
    75             var _vol = this.tagconf.map(function() {
    74                 return 0;
    76                 return 0;
    75             });
    77             });
    76             for (var j = 0; j < _group.length; j++){
    78             for (var j = 0; j < _group.length; j++){
    77                 var _txt = _group[j].content.description;
    79            var _txt = (_showTitle ? _group[j].content.title : '') + ' ' + (_showDescription ? _group[j].content.description : '')
    78                 var _tags = this.tagconf.map(function(_tag) {
    80                 var _tags = this.tagconf.map(function(_tag) {
    79                         return (_txt.search(_tag.regexp) == -1 ? 0 : 1)
    81                         return (_txt.search(_tag.regexp) == -1 ? 0 : 1)
    80                     }),
    82                     }),
    81                     _nbtags = _tags.reduce(function(_a,_b) {
    83                     _nbtags = _tags.reduce(function(_a,_b) {
    82                         return _a + _b;
    84                         return _a + _b;