Question: How can I build an X axis for a dojo chart from a Date column?
I'm trying to create a custom addAxis() function for the x axis of a Dojo multiseries line chart.
Incoming JSON data is stored in an Observable Memory dstore, retrieved via xhr from a PHP script, and looks like:
{"Date":1415854800,"Pressure1":23.2312,"Pressure2":17,"Pressure3":0,"Pressure4":0},
{"Date":1415913460,"Pressure1":25.0123,"Pressure2":17,"Pressure3":0.015,"Pressure4":0},...
That "Date" field is a Unix epochal timestamp via MySQL's UNIX_TIMESTAMP() on a Date column. It doesn't have to be, but I've tried a lot of recipes and that's the latest one.
My custom function looks like:
var data = new Memory({data:myjsondata});
...
labelFunc: function(n) {
var d = dates.get(n).Date;
alert(d);
}
The "data" object is good as far as addSeries is concerned: addSeries() can plot all 4 pressures correctly. That's the hard part. Usually.
Dojo charts accept dstore, store, and DataTable objects, and probably other data types as well, but the "API Reference" (aka "brief overview/tutorial" in any other project) only provides limited recipes for those objects, and examples of useless hard-coded arrays.
The data objects aren't really documented either, I don't have time to read the source and figure out a hack, and besides, there appear to be many obsolete iterations of data objects. It's easy to get lost and that's exactly where I am.
That dates.get(n).Date throws an exception because 'Date' is undefined. According to the most recent documentation for the version I'm using, that's a way to do it. Maybe. If this version of the Memory dstore object documentation isn't in error.
Question: How can I build an X axis for a dojo chart from a Date column?
I can make the data look like anything, but the X axis needs to reflect that Date value, and every other field in the row is a Y axis value for that Date.