Home Forums Report Bugs Undefined vars in "use strict" mode with webpack

Undefined vars in "use strict" mode with webpack

Viewing 5 posts - 1 through 5 (of 5 total)
  • #23763

    Hi,

    I try to test the react implementation and I get an error in the minify version of canvasjs library (canvasjs.min.js)

    
    Uncaught ReferenceError: i is not defined
        at q.getPercentAndTotal (canvasjs.min.js?37c9:9)
    

    Have any solution for this? I don´t remove the “use strict” from my code.

    #23770

    @tonichazigz,

    Thanks for reporting the issue. Declaring the variable ‘i’ in the getPercentAndTotal method should fix the issue in strict mode. We will fix the same in future releases.


    Vishwas R
    Team CanvasJS

    #23778

    The React example doesn´t work, and maybe all webpack compiled examples doesn´t works, because in webpack > 2.1.0-beta.7 “use strict” its append by default.

    #23791

    @tonichazigz,

    Apologies for the inconvenience caused. The issue seems to be due to the breaking changes in Webpack that was introduced in v2.2.0-rc.5 since when you can mix require and export whereas you can’t mix import and module.exports. Please take a look at this sample project that works fine with Webpack 2.4.1.
    column chart with webpack


    Vishwas R
    Team CanvasJS

    #23795

    That’s right, but if I change the type of chart to ‘funnel’ I get this error:

    
    ReferenceError: i is not defined
    q.getPercentAndTotal
    src/assets/js/canvasjs.min.js:513
      510 | function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();q.prototype.cancelRequestAnimFrame=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout;q.prototype.set=function(a,f,b){b="undefined"===
      511 | typeof b?!0:b;"options"===a?(this.options=f,b&&this.render()):q.base.set.call(this,a,f,b)};q.prototype.exportChart=function(a){a="undefined"===typeof a?{}:a;var f=a.format?a.format:"png",b=a.fileName?a.fileName:this.exportFileName;if(a.toDataURL)return this.canvas.toDataURL("image/"+f);s(this.canvas,f,b)};q.prototype.print=function(){var a=this.exportChart({toDataURL:!0}),f=document.createElement("iframe");f.setAttribute("class","canvasjs-chart-print-frame");f.setAttribute("style","position:absolute; width:100%; border: 0px; margin: 0px 0px 0px 0px; padding 0px 0px 0px 0px;");
      512 | f.style.height=this.height+"px";this._canvasJSContainer.appendChild(f);var b=this,c=f.contentWindow||f.contentDocument.document||f.contentDocument;c.document.open();c.document.write('<!DOCTYPE HTML>\n<html><body style="margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"><img src="'+a+'"/><body/></html>');c.document.close();setTimeout(function(){c.focus();c.print();setTimeout(function(){b._canvasJSContainer.removeChild(f)},1E3)},500)};q.prototype.getPercentAndTotal=function(a,f){var b=null,c=null,
    > 513 | e=null;if(0<=a.type.indexOf("stacked"))c=0,b=f.x.getTime?f.x.getTime():f.x,b in a.plotUnit.yTotals&&(c=a.plotUnit.yTotals[b],e=isNaN(f.y)?0:100*(f.y/c));else if("pie"===a.type||"doughnut"===a.type||"funnel"===a.type||"pyramid"===a.type){for(i=c=0;i<a.dataPoints.length;i++)isNaN(a.dataPoints[i].y)||(c+=a.dataPoints[i].y);e=isNaN(f.y)?0:100*(f.y/c)}return{percent:e,total:c}};q.prototype.replaceKeywordsWithValue=function(a,f,b,c,e){var g=this;e="undefined"===typeof e?0:e;if((0<=b.type.indexOf("stacked")||
      514 | "pie"===b.type||"doughnut"===b.type||"funnel"===b.type||"pyramid"===b.type)&&(0<=a.indexOf("#percent")||0<=a.indexOf("#total"))){var h="#percent",l="#total",t=this.getPercentAndTotal(b,f),l=isNaN(t.total)?l:t.total,h=isNaN(t.percent)?h:t.percent;do{t="";if(b.percentFormatString)t=b.percentFormatString;else{var t="#,##0.",k=Math.max(Math.ceil(Math.log(1/Math.abs(h))/Math.LN10),2);if(isNaN(k)||!isFinite(k))k=2;for(var r=0;r<k;r++)t+="#";b.percentFormatString=t}a=a.replace("#percent",V(h,t,g._cultureInfo));
      515 | a=a.replace("#total",V(l,b.yValueFormatString?b.yValueFormatString:"#,##0.########",g._cultureInfo))}while(0<=a.indexOf("#percent")||0<=a.indexOf("#total"))}return a.replace(/\{.*?\}|"[^"]*"|'[^']*'/g,function(a){if('"'===a[0]&&'"'===a[a.length-1]||"'"===a[0]&&"'"===a[a.length-1])return a.slice(1,a.length-1);a=Fa(a.slice(1,a.length-1));a=a.replace("#index",e);var h=null;try{var d=a.match(/(.*?)\s*\[\s*(.*?)\s*\]/);d&&0<d.length&&(h=Fa(d[2]),a=Fa(d[1]))}catch(k){}d=null;if("color"===a)return"waterfall"===
      516 | b.type?f.color?f.color:0<f.y?b.risingColor:b.fallingColor:"error"===b.type?b.color?b.color:b._colorSet[h%b._colorSet.length]:f.color?f.color:b.color?b.color:b._colorSet[c%b._colorSet.length];if(f.hasOwnProperty(a))d=f;else if(b.hasOwnProperty(a))d=b;else return"";d=d[a];null!==h&&(d=d[h]);if("x"===a)if("dateTime"===b.axisX.valueType||"dateTime"===b.xValueType||f.x&&f.x.getTime){if(g.plotInfo.plotTypes[0].plotUnits[0].axisX&&!g.plotInfo.plotTypes[0].plotUnits[0].axisX.logarithmic)return Aa(d,f.xValueFormatString?
    

    I am getting the data from this link: https://canvasjs.com/react-charts/funnel-chart/

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.