toorshia/justgage

uncaught TypeError: Object has no method 'toFixed' when using refreshmax

jgentes opened this issue · 13 comments

I'm seeing this error crop up when I use the .refresh method: http://prntscr.com/x0kuo

Any ideas? I could be doing something very wrong on my end.

Thanks,

-James

I suspect it has something to do with me adding decimals feature, I might have missed something. Will investigate.

Hey James, can you send me example with issue? I am having trouble reproducing it...

Thanks, you should be able to access this page - you can see the error when
you try to click the links at the top to change the month. I recently tried
setting it up using Jquery, just to see if that would help, but it didn't
make a difference.

http://analytics-staging.thesocialbusiness.com/admin/the-social-business

-James

On Sat, Mar 23, 2013 at 6:04 AM, Bojan Djuricic notifications@github.comwrote:

Hey James, can you send me example with issue? I am having trouble
reproducing it...


Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-15336764
.

I get empty Facebook page, and an "Error" dialog... ?

Sorry, the system depends on FB authentication. I thought I bypassed it for
that page, but apparently not. I could do a join.me screenshare session, or
I will need to look into it again. Or if you have a FB page that you manage
(I couldn't access the other one) then it would be easy for me to setup for
that page. You could just create a fake one.

On Mon, Mar 25, 2013 at 8:19 AM, Bojan Djuricic notifications@github.comwrote:

I get empty Facebook page, and an "Error" dialog... ?


Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-15399322
.

Can you give me just the part with gauge setup? Because we first need to determine if it's gauge setup related issue, and then look further if needed.

I'm going to try to setup on jsfiddle.

On Mon, Mar 25, 2013 at 8:29 AM, James Gentes
james@thesocialbusiness.comwrote:

Sure, here's the snippit for the actual gauge setup:

<script src="/static/js/base.js" type="text/javascript" defer></script> <script src="/static/js/raphael.2.1.0.min.js" type="text/javascript"></script> <script src="

/static/js/justgage.1.0.1.min.jshttp://analytics-staging.thesocialbusiness.com/static/js/justgage.1.0.1.min.js"
type="text/javascript"></script> <script src="/static/js/charts.min.js" type="text/javascript"></script> <script language="javascript" type=" text/javascript"> function emailReport() {var business_id =
"247687900935";
$.post("/emailreport", {id: business_id});
};var valuelinechart = new Charts.LineChart('ValueLineChart', { show_grid:
false,show_y_labels: false,show_x_labels: true, label_max: true,label_min:
true,x_padding: 45,y_padding: 40, label_format: "%m/%Y",font_family:
"Open Sans, HelveticaNeue, Helvetica Neue, Helvetica, Arial, sans-serif"
});date30 = new Date(2013, 01, 01);date60 = new Date(2012, 12, 01);date90
= new Date(2012, 11, 01); date120 = new Date(2012, 10, 01);value120 = 119;value90
= value120 + 207; value60 = value90 + 268;value30 = value60 + 132;
valuelinechart.add_line({ data: [[date120, value120, {tooltip: "$" +
value120}], [date90, value90, {tooltip: "$" + value90}], [date60, value60,
{tooltip: "$" + value60}],[date30, value30, {tooltip: "$" + value30}]], options:
{line_color: "#84A800",dot_color: "#84A800", area_color: "#84A800",area_opacity:
0.2}}); valuelinechart.draw();sparkline_options = {show_x_labels: false,show_y_labels:
false, show_grid: false,smoothing: 0.4,line_width: 1, label_min: false,label_max:
false,dot_size: 1,dot_stroke_size: 0, x_padding: 10,y_padding: 5};storiesspark
= new Charts.LineChart('StoriesSpark', sparkline_options); audiencespark
= new Charts.LineChart('AudienceSpark', sparkline_options);engagementspark
= new Charts.LineChart('EngagementSpark', sparkline_options); reachspark
= new Charts.LineChart('ReachSpark', sparkline_options);
storiesspark.add_line({ data: [[1, 18],[2, 25],[3, 25],[4, 11]],options: {line_color:
"#6996BD",dot_color: "#6996BD", area_color: "#6996BD",area_opacity: 0.2,}});
audiencespark.add_line({data: [[1, 1],[2, 5],[3, 10],[4, 9]],options: { line_color:
"#6996BD",dot_color: "#6996BD",area_color: "#6996BD", area_opacity: 0.2,}
});engagementspark.add_line({ data: [[1, 9],[2, 21],[3, 35],[4, 12]],options:
{line_color: "#6996BD", dot_color: "#6996BD",area_color: "#6996BD",area_opacity:
0.2, }});reachspark.add_line({data: [[1, 427],[2, 1018],[3, 1206],[4,
520]], options: {line_color: "#6996BD",dot_color: "#6996BD", area_color:
"#6996BD",area_opacity: 0.2,}}); storiesspark.draw();audiencespark.draw();
engagementspark.draw(); reachspark.draw();var idMonth = 0;var
UpdatesNumber = ('[11L, 25L, 25L, 18L, 55, 125, 125, 90,
79L]').replace(/[[]L']+/g,'').split(","); var FansNumber = ('[9, 10, 5,
1, 45, 50, 25, 5, 25]').replace(/[[]L']+/g,'').split(",")var
ReactionsNumber = ('[12L, 35L, 21L, 9L, 30, 87, 52, 22,
77L]').replace(/[[]L']+/g,'').split(",") var ViralNumber = ('[0.6, 0.4,
0.2, 0.2, 1.4]').replace(/[[]L']+/g,'').split(",")var ReachNumber =
('[520L, 1206L, 1018L, 427L, 2, 6, 5, 2,
3171L]').replace(/[[]L']+/g,'').split(",") var TotalValue = (['132',
'268', '207', '119'])var Month = (['February, 2013', 'January, 2013',
'December, 2012', 'November, 2012']) var UpdatesRating = (['Good', 'Above
Average', 'Above Average', 'Good', 'Good'])var FansRating =
(['Excellent', 'Excellent', 'Excellent', 'Excellent', 'Excellent']) var
ReactionsRating = (['Excellent', 'Excellent', 'Excellent', 'Excellent',
'Excellent'])var ViralRating = (['Good', 'Good', 'Below Average', 'Below
Average', 'Above Average']) var ReachRating = (['Excellent', 'Excellent',
'Excellent', 'Excellent', 'Excellent'])var UpdatesGoal = (['28', '31',
'31', '30']) var FansGoal = (['1.0', '2.0', '1.0', '1.0'])var
ReactionsGoal = (['11.0', '24.0', '18.0', '8.0']) var ViralGoal =
(['1.5', '1.5', '1.5', '1.5'])var ReachGoal = (['77.0', '88.0', '47.0',
'12.0']) var UpdatesChart = new JustGage({id: "updateschart",value:
UpdatesNumber[idMonth], min: 0,max: UpdatesGoal[idMonth],label: "Updates
Posted", title: " ",shadowOpacity: 2,shadowSize: 2,shadowVerticalOffset:
1, showMinMax: false,levelColors: ["#FF0000", "#F9C800","#A7D500",
"#A7D500","#A7D500", "#84A800"]});var AudienceChart = new JustGage({ id:
"audiencechart",value: FansNumber[idMonth],min: 0, max: FansGoal[idMonth],label:
"New Fans",title: " ", shadowOpacity: 2,shadowSize: 2,shadowVerticalOffset:
1,showMinMax: false, levelColors: ["#FF0000","#F9C800","#A7D500",
"#A7D500","#A7D500","#84A800" ]});var EngagementChart = new JustGage({id:
"engagementchart", value: ReactionsNumber[idMonth],min: 0,max:
ReactionsGoal[idMonth], label: "Reactions",title: " ",shadowOpacity: 2,shadowSize:
2, shadowVerticalOffset: 1,showMinMax: false,levelColors: [ "#FF0000",
"#F9C800","#A7D500","#A7D500", "#A7D500","#84A800"]}); var ViralChart =
new JustGage({id: "viralchart",value: (ViralNumber[idMonth]*10)/10, min:
0,max: ViralGoal[idMonth],label: "Viral Effect", title: " ",shadowOpacity:
2,shadowSize: 2,shadowVerticalOffset: 1, showMinMax: false,levelColors: [
"#FF0000", "#F9C800","#A7D500","#A7D500","#A7D500", "#84A800"]});var
ReachChart = new JustGage({ id: "reachchart",value: ReachNumber[idMonth],min:
0, max: ReachGoal[idMonth],label: "People Reached",title: " ",shadowOpacity: 2,shadowSize:
2,shadowVerticalOffset: 1,showMinMax: false, levelColors: ["#FF0000",
"#F9C800","#A7D500", "#A7D500","#A7D500","#84A800" ]});function
changeDate(idMonth){if (idMonth == 4) { document.getElementById('UpdatesNumber').innerHTML
= parseInt(UpdatesNumber[3]) + parseInt(UpdatesNumber[2]) +
parseInt(UpdatesNumber[1]) + parseInt(UpdatesNumber[0]); document.getElementById('UpdatesNumber2').innerHTML
= parseInt(UpdatesNumber[3]) + parseInt(UpdatesNumber[2]) +
parseInt(UpdatesNumber[1]) + parseInt(UpdatesNumber[0]); document.getElementById('FansNumber').innerHTML
= parseInt(FansNumber[3]) + parseInt(FansNumber[2]) +
parseInt(FansNumber[1]) + parseInt(FansNumber[0]);document.getElementById('FansNumber2').innerHTML
= parseInt(FansNumber[3]) + parseInt(FansNumber[2]) +
parseInt(FansNumber[1]) + parseInt(FansNumber[0]); document.getElementById('ReactionsNumber').innerHTML
= parseInt(ReactionsNumber[3]) + parseInt(ReactionsNumber[2]) +
parseInt(ReactionsNumber[1]) + parseInt(ReactionsNumber[0]); document.getElementById('ReactionsNumber2').innerHTML
= parseInt(ReactionsNumber[3]) + parseInt(ReactionsNumber[2]) +
parseInt(ReactionsNumber[1]) + parseInt(ReactionsNumber[0]); document.getElementById('ViralNumber').innerHTML
= Math.round((Math.round((ViralNumber[3]*10)/10 +
Math.round(ViralNumber[2]*10)/10 + Math.round(ViralNumber[1]*10)/10 +
Math.round(ViralNumber[0]*10)/10)/4)*10)/10; document.getElementById('ReachNumber').innerHTML
= parseInt(ReachNumber[3]) + parseInt(ReachNumber[2]) +
parseInt(ReachNumber[1]) + parseInt(ReachNumber[0]); document.getElementById('ReachNumber2').innerHTML
= parseInt(ReachNumber[3]) + parseInt(ReachNumber[2]) +
parseInt(ReachNumber[1]) + parseInt(ReachNumber[0]);document.getElementById('UpdatesValue').innerHTML =
parseInt(UpdatesNumber[7]) + parseInt(UpdatesNumber[6]) +
parseInt(UpdatesNumber[5]) + parseInt(UpdatesNumber[4]);document.getElementById('FansValue').innerHTML
= parseInt(FansNumber[7]) + parseInt(FansNumber[6]) +
parseInt(FansNumber[5]) + parseInt(FansNumber[4]); document.getElementById('ReactionsValue').innerHTML
= parseInt(ReactionsNumber[7]) + parseInt(ReactionsNumber[6]) +
parseInt(ReactionsNumber[5]) + parseInt(ReactionsNumber[4]); document.getElementById('ReachValue').innerHTML
= parseInt(ReachNumber[7]) + parseInt(ReachNumber[6]) +
parseInt(ReachNumber[5]) + parseInt(ReachNumber[4]); document.getElementById('UpdatesRating').innerHTML
= UpdatesRating[4];document.getElementById('FansRating').innerHTML =
FansRating[4]; document.getElementById('ReactionsRating').innerHTML =
ReactionsRating[4];document.getElementById('ViralRating').innerHTML =
ViralRating[4]; document.getElementById('ReachRating').innerHTML =
ReachRating[4];document.getElementById('Month').innerHTML = Month[3] + "

  • " + Month[0]; //UpdatesChart.refresh(parseInt(UpdatesNumber[3]) +
    parseInt(UpdatesNumber[2]) + parseInt(UpdatesNumber[1]) +
    parseInt(UpdatesNumber[0]), parseInt(UpdatesGoal[3]) +
    parseInt(UpdatesGoal[2]) + parseInt(UpdatesGoal[1]) +
    parseInt(UpdatesGoal[0])); //AudienceChart.refresh(parseInt(FansNumber[3])
  • parseInt(FansNumber[2]) + parseInt(FansNumber[1]) +
    parseInt(FansNumber[0]), parseInt(FansGoal[3]) + parseInt(FansGoal[2]) +
    parseInt(FansGoal[1]) + parseInt(FansGoal[0])); //EngagementChart.refresh(parseInt(ReactionsNumber[3])
  • parseInt(ReactionsNumber[2]) + parseInt(ReactionsNumber[1]) +
    parseInt(ReactionsNumber[0]), parseInt(ReactionsGoal[3]) +
    parseInt(ReactionsGoal[2]) + parseInt(ReactionsGoal[1]) +
    parseInt(ReactionsGoal[0])); //ViralChart.refresh(Math.round((Math.round((ViralNumber[3]*10)/10
  • Math.round(ViralNumber[2]*10)/10 + Math.round(ViralNumber[1]*10)/10 +
    Math.round(ViralNumber[0]*10)/10)/4)*10)/10, (ViralGoal[3] + ViralGoal[2] +
    ViralGoal[1] + ViralGoal[0])/4); //ReachChart.refresh(parseInt(ReachNumber[3])
  • parseInt(ReachNumber[2]) + parseInt(ReachNumber[1]) +
    parseInt(ReachNumber[0]), parseInt(ReachGoal[3]) + parseInt(ReachGoal[2]) +
    parseInt(ReachGoal[1]) + parseInt(ReachGoal[0])); }else {document.getElementById('UpdatesNumber').innerHTML
    = UpdatesNumber[idMonth]; document.getElementById('UpdatesNumber2').innerHTML
    = UpdatesNumber[idMonth];document.getElementById('FansNumber').innerHTML
    = FansNumber[idMonth]; document.getElementById('FansNumber2').innerHTML =
    FansNumber[idMonth];document.getElementById('ReactionsNumber').innerHTML
    = ReactionsNumber[idMonth]; document.getElementById('ReactionsNumber2').innerHTML
    = ReactionsNumber[idMonth];document.getElementById('ViralNumber').innerHTML
    = Math.round(ViralNumber[idMonth]*10)/10; document.getElementById('ReachNumber').innerHTML
    = ReachNumber[idMonth];document.getElementById('ReachNumber2').innerHTML
    = ReachNumber[idMonth]; document.getElementById('UpdatesValue').innerHTML
    = UpdatesNumber[idMonth + 4];document.getElementById('FansValue').innerHTML
    = FansNumber[idMonth + 4]; document.getElementById('ReactionsValue').innerHTML
    = ReactionsNumber[idMonth + 4];document.getElementById('ReachValue').innerHTML
    = ReachNumber[idMonth + 4]; document.getElementById('TotalValue').innerHTML
    = TotalValue[idMonth];document.getElementById('UpdatesRating').innerHTML
    = UpdatesRating[idMonth]; document.getElementById('FansRating').innerHTML
    = FansRating[idMonth];document.getElementById('ReactionsRating').innerHTML
    = ReactionsRating[idMonth]; document.getElementById('ViralRating').innerHTML
    = ViralRating[idMonth];document.getElementById('ReachRating').innerHTML =
    ReachRating[idMonth]; document.getElementById('Month').innerHTML =
    Month[idMonth];//document.getElementById('updateschart').innerHTML = ''; //document.getElementById('audiencechart').innerHTML
    = '';//document.getElementById('engagementchart').innerHTML = ''; //document.getElementById('viralchart').innerHTML
    = '';document.getElementById('reachchart').innerHTML = ''; //document.getElementById('StoriesSpark').innerHTML
    = '';//document.getElementById('AudienceSpark').innerHTML = ''; //document.getElementById('EngagementSpark').innerHTML
    = '';//document.getElementById('ReachSpark').innerHTML = ''; //document.getElementById('ValueLineChart').innerHTML
    = '';UpdatesChart.refresh(UpdatesNumber[idMonth], UpdatesGoal[idMonth]); AudienceChart.refresh(FansNumber[idMonth],
    FansGoal[idMonth]);EngagementChart.refresh(ReactionsNumber[idMonth],
    ReactionsGoal[idMonth]); ViralChart.refresh(Math.round(ViralNumber[idMonth]*10)/10,
    ViralGoal[idMonth]);ReachChart.refresh(ReachNumber[idMonth],
    ReachGoal[idMonth]); }};//window.onload = changeDate(0);</script>

On Mon, Mar 25, 2013 at 8:26 AM, Bojan Djuricic notifications@github.comwrote:

Can you give me just the part with gauge setup? Because we first need to
determine if it's gauge setup related issue, and then look further if
needed.


Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-15399787
.

ok, just sent you a zip, not sure if it will run though..

On Mon, Mar 25, 2013 at 8:35 AM, Bojan Djuricic notifications@github.comwrote:

OMG dude :D
Did you just paste a whole lot of code straight to a comment box? :D

Can you give me just a url to a html example?

Or shoot me email with zipped example I can run locally.


Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-15400355
.

It runs, I get two missing css errors, and DOM security exception 18 error, gauges run fine. I'm running it on Chrome 25. Tried on Firefox too, no DOM error, gauges run fine.
What do I need do to get "Object has no method 'toFixed'"?

Click on December / January a few times, that's what triggers the .refresh
method and causes the error.

Thanks!

-James

On Tue, Mar 26, 2013 at 4:38 PM, Bojan Djuricic notifications@github.comwrote:

It runs, I get two missing css errors, and DOM security exception 18
error, gauges run fine. I'm running it on Chrome 25. Tried on Firefox too,
no DOM error, gauges run fine.
What do I need do to get "Object has no method 'toFixed'"?


Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-15495900
.

+1, having this same issue

Guys, please pull fresh update, and try. The problem is with type of value being sent to refresh method - it is supposed to be number. So technically it wasn't my fault :P

I still have to check places in code where number is expected and do simple * 1 trick to make sure library is working with numbers, not strings.

Yep, there was definitely an issue with James's example and new max value being sent as a string. This should work like charm now. Scream if I screwed up something :)