diff --git a/dist/columnHeatmap.min.js b/dist/columnHeatmap.min.js index 129ddbd..50a8456 100644 --- a/dist/columnHeatmap.min.js +++ b/dist/columnHeatmap.min.js @@ -1 +1 @@ -!function(t){t.columnHeatmap={name:"columnHeatmap",version:"1.0",release:"2020-06-15",author:"Paulo Kramer",site:"https://www.paulokramer.com",documentation:"https://github.com/PauloAK/jQuery-columnHeatMap"},t.fn.columnHeatmap=function(e){var n=t.extend({columns:[],contrast:!0,inverse:!1,animated:!0,animationSpeed:.1,fn_parseValue:null,colorStartPoint:0},e);try{if(!this.is("table"))throw"Selected element isn't a table";if(0==n.columns.length)throw"You need to specify the columns";if(n.colorStartPoint<0||n.colorStartPoint>360)throw`colorStartPoint need to be beetween 0 and 360, current: ${n.colorStartPoint}`;let e=this.find("tbody tr"),a=[];t.each(n.columns,(o,r)=>{e.each((e,o)=>{0==e&&(a[r.toString()]=new Array,a[r.toString()].values=new Array,a[r.toString()].tds=new Array);let l=t(o).find("td")[r];if(a[r.toString()].tds.push(l),"function"==typeof n.fn_parseValue){let e=fn_parseValue(t(l).text());if(void 0===e)throw"None value returned in fn_parseValue";a[r.toString()].values.push(e)}else{let e=t(l).text().match(/[\d|\-|.|,]+/)[0];a[r.toString()].values.push(parseFloat(e))}})}),a=a.filter(t=>t),t.each(a,(t,e)=>{e&&e.values&&(a[t].min=null,a[t].max=null,a[t].min=e.values.reduce(function(t,e){return Math.min(t,e)}),a[t].max=e.values.reduce(function(t,e){return Math.max(t,e)}))}),t.each(a,(e,a)=>{t.each(a.values,(e,o)=>{let r=function(t,e,a){var o=100*(t-e)/(a-e);n.inverse&&(o=100-o);return{color:"hsl("+(Math.abs(-1*(o-100))+n.colorStartPoint)+", 70%, 65%)",perc:o}}(o,a.min,a.max);n.animated&&t(a.tds[e]).css("transition",`background-color ${n.animationSpeed}s linear, color ${n.animationSpeed}s linear`),t(a.tds[e]).css("background-color",r.color),r.perc>70&&n.contrast&&t(a.tds[e]).css("color","#fff")})})}catch(e){return void console.error(`[${t.columnHeatmap.name}::Error] ${e}`)}}}(jQuery); +!function(t){t.columnHeatmap={name:"columnHeatmap",version:"1.0",release:"2020-06-15",author:"Paulo Kramer",site:"https://www.paulokramer.com",documentation:"https://github.com/PauloAK/jQuery-columnHeatMap"},t.fn.columnHeatmap=function(e){var n=t.extend({columns:[],contrast:!0,inverse:!1,animated:!0,animationSpeed:.1,fn_parseValue:null,colorStartPoint:0},e);try{if(!this.is("table"))throw"Selected element isn't a table";if(0==n.columns.length)throw"You need to specify the columns";if(n.colorStartPoint<0||n.colorStartPoint>360)throw`colorStartPoint need to be beetween 0 and 360, current: ${n.colorStartPoint}`;let e=this.find("tbody tr"),a=[];t.each(n.columns,(o,r)=>{e.each((e,o)=>{0==e&&(a[r.toString()]=new Array,a[r.toString()].values=new Array,a[r.toString()].tds=new Array);let l=t(o).find("td")[r];if(a[r.toString()].tds.push(l),"function"==typeof n.fn_parseValue){let e=n.fn_parseValue(t(l).text());if(void 0===e)throw"None value returned in fn_parseValue";a[r.toString()].values.push(e)}else{let e=t(l).text().match(/[\d|\-|.|,]+/)[0];a[r.toString()].values.push(parseFloat(e))}})}),a=a.filter(t=>t),t.each(a,(t,e)=>{e&&e.values&&(a[t].min=null,a[t].max=null,a[t].min=e.values.reduce(function(t,e){return Math.min(t,e)}),a[t].max=e.values.reduce(function(t,e){return Math.max(t,e)}))}),t.each(a,(e,a)=>{t.each(a.values,(e,o)=>{let r=function(t,e,a){var o=100*(t-e)/(a-e);n.inverse&&(o=100-o);return{color:"hsl("+(Math.abs(-1*(o-100))+n.colorStartPoint)+", 70%, 65%)",perc:o}}(o,a.min,a.max);n.animated&&t(a.tds[e]).css("transition",`background-color ${n.animationSpeed}s linear, color ${n.animationSpeed}s linear`),t(a.tds[e]).css("background-color",r.color),r.perc>70&&n.contrast&&t(a.tds[e]).css("color","#fff")})})}catch(e){return void console.error(`[${t.columnHeatmap.name}::Error] ${e}`)}}}(jQuery); diff --git a/src/columnHeatmap.js b/src/columnHeatmap.js index 9faf9a4..9540c58 100644 --- a/src/columnHeatmap.js +++ b/src/columnHeatmap.js @@ -47,7 +47,7 @@ if (typeof settings.fn_parseValue == "function") { - let value = fn_parseValue($(td).text()); + let value = settings.fn_parseValue($(td).text()); if (typeof value == "undefined") { throw 'None value returned in fn_parseValue'; } else { @@ -111,4 +111,4 @@ return; } }; -}(jQuery)); \ No newline at end of file +}(jQuery));