my-archives / nchart

nChart for node.js inspired by Chart.js.
MIT License
48 stars 10 forks source link

Define tmpl, so creating a Line chart doesn't fail #4

Closed aliou closed 10 years ago

aliou commented 10 years ago

Right now, using the scaleOverride and the scaleSteps options produces the following error:

ReferenceError: tmpl is not defined
  at new Line (/Users/alioudiallo/src/misc/reporter/node_modules/nchart/lib/line.js:65:11)
  at Chart.proto.Line (/Users/alioudiallo/src/misc/reporter/node_modules/nchart/lib/chart.js:36:10)
  at Object.module.exports.LineGraph (/Users/alioudiallo/src/misc/reporter/helper.coffee:60:3, <js>:70:20)
  at /Users/alioudiallo/src/misc/reporter/daily_mood.coffee:36:3, <js>:60:19
  at Function._.each._.forEach (/Users/alioudiallo/src/misc/reporter/node_modules/underscore/underscore.js:87:22)
  at Object.<anonymous> (/Users/alioudiallo/src/misc/reporter/daily_mood.coffee:20:1, <js>:37:5)
  at Object.<anonymous> (/Users/alioudiallo/src/misc/reporter/daily_mood.coffee:1:1, <js>:63:4)
  at Module._compile (module.js:456:26)

This pull defines tmpl and fixes the issue.

aliou commented 10 years ago

Actually never mind, this seems to not show the right scale values... (this should be from one to five)
friday february 14 2014

aliou commented 10 years ago

For some reason, these lines always returns the scaleStepWidth. Any idea?

fundon commented 10 years ago

Thanks. Good catch!

// Is `i`, not `1`.
value: (cfg.scaleStartValue + cfg.scaleStepWidth * 1).toFixed(getDecimalPlaces(cfg.scaleStepWidth))

If using the scaleOverride, scaleSteps scaleStepWidth and scaleStartValue must be required. See http://www.chartjs.org/docs/#lineChart-chartOptions.

aliou commented 10 years ago

Cool, thanks ! :+1:

fundon commented 10 years ago

I will add some test cases.