/* Widget: chart (beta) - updated 10/31/2015 (v2.24.0) */ /* * Requires tablesorter v2.8+ and jQuery 1.7+ */ /*jshint browser:true, jquery:true, unused:false */ /*global jQuery: false */ !function(a){"use strict";var b=a.tablesorter, // temp variables c=[],d=[], // google charts e=[],f=[], // highcharts g=[],h=[], // fusioncharts i=[],j=[],k=b.chart={ // regex used to strip out non-digit values before sending // the string to the $.tablesorter.formatFloat function nonDigit:/[^\d,.\-()]/g,init:function(a,b){a.$table.off(b.chart_event).on(b.chart_event,function(){if(this.hasInitialized){ // refresh 'c' variable in case options are updated dynamically var a=this.config;k.getCols(a,a.widgetOptions),k.getData(a,a.widgetOptions)}})},getCols:function(d,e){var f;for(c=[],h=[],j=[],f=0;f=0?j.push(e[f]):(g=i[f].getAttribute(c.textAttribute)||i[f].textContent||i.eq(f).text(),j.push(a.trim(g)));l.push(j)}}),l.sort(function(a,c){return 1===d.chart_sort[0][1]?b.sortNatural(c[d.chart_sort[0][0]],a[d.chart_sort[0][0]]):b.sortNatural(a[d.chart_sort[0][0]],c[d.chart_sort[0][0]])}),a.each(l,function(f,l){var m,n=0,o=[],p=l[d.chart_labelCol];o.push(""+p),a.each(l,function(e,f){var l;return e===d.chart_labelCol?(g.push(f),i.push({label:f}),!0):(m=!1,d.chart_useSelector&&b.hasWidget(c.table,"columnSelector")&&!c.selector.auto?c.selector.states[e]&&a.inArray(e,d.chart_ignoreColumns)<0&&(m=""+f):a.inArray(e,d.chart_ignoreColumns)<0&&(m=""+f),void(m!==!1&&(/s/i.test(""+d.chart_layout[e])?(o.push(m),h[n].data.push(m),j[n].data.push(m)):(l=b.formatFloat(m.replace(k.nonDigit,""),c.table),l=isNaN(l)?m:l,o.push(l),h[n].data.push(l),j[n].data.push({value:l})),n++)))}),e.push(o)})},remove:function(a,b){a.$table.off(b.chart_event)}};b.addWidget({id:"chart",options:{ // (a)ll, (v)isible or (f)iltered - only the first letter is needed chart_incRows:"filtered", // prefer columnSelector for ignoreColumns chart_useSelector:!1, // columns to ignore [0, 1,... ] (zero-based index) chart_ignoreColumns:[], // Use parsed data instead of cell.text() chart_parsed:[], // data output layout, float is default chart_layout:{ // first element is a string, all others will be float 0:"string"}, // Set the label column chart_labelCol:0, // data sort, should always be first row, might want [[0,1]] chart_sort:[[0,0]], // event to trigger get updated data chart_event:"chartData"},init:function(a,b,c,d){k.init(c,d)},remove:function(a,b,c){k.remove(b,c)}})}(jQuery);