Reputation: 63
I am trying to create a date based data serial type chart, strongly based in example "Date Based Data" available in amChart's website. The code is almost the same except that I'm replacing dataProvider variable names and date format. The problem is that it's throwing jQuery error:
Uncaught TypeError: Cannot read property 'replace' of undefined
at Object.d.formatDate (amcharts.js:397)
at b.dispatchTimeZoomEvent (serial.js:45)
at b.timeZoom (serial.js:36)
at b.zoom (serial.js:34)
at b.drawChart (serial.js:31)
at b.onDataUpdated (serial.js:25)
at b.initChart (serial.js:25)
at b.measureMargins (serial.js:7)
at b.onDataUpdated (serial.js:26)
at b.initChart (serial.js:25)
And so it's not rendering the graph.
Any idea in what I could be doing wrong? Here's a fiddle with the code: https://jsfiddle.net/qtzmq9z7/
var chartData = [{"regtime": "2016-12-06T09:16:17Z", "power": -0.4},
...
{"regtime": "2016-12-06T13:28:43Z", "power": -0.4}];
var chart1 = AmCharts.makeChart("general-chart", {
...
"dataDateFormat": "YYYY-MM-DDTHH:NN:SSZ",
"categoryField": "regtime",
"categoryAxis": {
"parseDates": true,
"dashLength": 1,
"minorGridEnabled": true,
"minPeriod": "SS"
},
...
});
PS: It looks like there is some weird bug with jsfiddle and amCharts, causing the graph to increase its height infinitely, but that is not happening outside jsfiddle, so just ignore that problem.
Upvotes: 0
Views: 1480
Reputation: 6162
minPeriod uses "ss" for seconds. Notice it has to be lower-cased.
"categoryAxis": {
"parseDates": true,
"dashLength": 1,
"minorGridEnabled": true,
"minPeriod": "ss"
}
Please check the updated example https://jsfiddle.net/qtzmq9z7/1/
Upvotes: 2