IonicaBizau / git-stats

🍀 Local git statistics including GitHub-like contributions calendars.
MIT License
6.41k stars 182 forks source link

TypeError: Cannot set property 'NaN' of undefined #114

Open kdavis opened 7 years ago

kdavis commented 7 years ago

System:

User@DesktopPC MINGW64 /e/Git/GitStatsTest (branch/test)
$ git-stats -a
C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\node_modules\cli-graph\lib\index.js:63
    self.graph[settings.center.y][settings.center.x] = settings.marks.center;
                                                     ^

TypeError: Cannot set property 'NaN' of undefined
    at new CliGraph (C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\node_modules\cli-graph\lib\index.js:63:54)
    at new CliCircle (C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\node_modules\cli-circle\lib\index.js:35:18)
    at CliPie.toString (C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\node_modules\cli-pie\lib\index.js:170:18)
    at C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\lib\index.js:612:87
    at C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\lib\index.js:548:9
    at LimitIt.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\node_modules\gry\lib\index.js:86:17)
    at C:\Users\User\AppData\Roaming\npm\node_modules\git-stats\node_modules\limit-it\lib\index.js:138:20
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
IonicaBizau commented 7 years ago

Whoups! Debugging is welcome since I do not have a Windows machine around...

kdavis commented 7 years ago

I put a console.log above the offending line.

console.log(settings);
self.graph[settings.center.y][settings.center.x] = settings.marks.center;

It seems the settings.center children nodes are NaN for some reason, could be a Windows bug?

{ width: NaN,
  height: NaN,
  marks:
   { hAxis: ' ',
     vAxis: ' ',
     center: ' ',
     point: ' ',
     rightArrow: ' ',
     topArrow: ' ',
     background: ' ' },
  center: { x: NaN, y: NaN }, // <- Here
  aRatio: 1 }
IonicaBizau commented 7 years ago

Whoups!

This is the place here the centers are set: https://github.com/IonicaBizau/node-cli-graph/blob/4f3acc270e5718ebc8b087c750b369551976df56/lib/index.js#L49-L55

yangjiebeijing commented 7 years ago

i have the same problem

kdavis commented 7 years ago

It looks like the defaults aren't being merged with the options. settings = self.options = Ul.deepMerge(options, CliGraph.defaults)

mjamro commented 6 years ago

For me it happens in the git bash. In the cmd.exe it looks ok. Can anyone confirm that?

robodude666 commented 6 years ago

@mariuszjamro I can confirm the -a works in cmd.exe but not in Git Bash, however the coloring/scale is broken in cmd.exe.

codexp commented 6 years ago

I confirm this issue under Windows 7. Also confirm using cmd.exe produces no usable output even not with --disable-ansi git-bash ouput is not same as screenshots on main git page, but it's ok.