Using Chart Tools (Chart Data XY) with Data Structure from XML Importer

lukee's picture

I'm just evaluating Chart Tools.

I want to do a simple line plot of a single value for about 60 items (actually these are minutes in the hour). I have an XML that has elements "min00", "min01" etc. containing the single value for each.

This XML comes through as a structure value that looks like: 0:"min00" = 11 1:"min01" = 12 2:"min02" = 13 ... etc for 60 minutes

Now, what I'm finding is that this structure (which appears to have NSCFString types for the values - presumably normal for the XML Importer output) won't actually work when presented to Chart Data XY's "Data Structure" input. I get a plot of all zeros (though if I turn on value or key data labels then I can see each zero has its 'min' label or the associated value).

If I write a little Javascript to copy array values over to a new structure (essentially a new Javascript Array object), then the values are plotted correctly (though at the moment, I'm losing the keys as these are replaced by the simple index of the Javascript Array).

So, I'm wondering if there's some limitation of Chart Data XY's expectations with respect to the structure it can use (connected to the "Data Structure" input). Specifically, whether the string values from the XML Importer output are all resulting in the zero values for the data series.

Would somebody be kind enough to indicate whether its possible to get the unchanged output from the XML Importer to work (preferably so I can plot proper keys as well as data values).

Also, I can't find any documentation to suggest exactly what structure formats the Chart Data XY patch supports. Clearly, an array of numbers generated by the Javascript patch works fine. Maybe I can modify my Javascript patch to convert the output from the XML Importer to preserve the keys, but have numeric values... assuming that the string values are the only reason this is not working out-of-the-box.

Anyway, any clues greatly appreciated!

-- Luke

lukee's picture
Re: Using Chart Tools (Chart Data XY) with Data Structure ...

OK, so I think what this is turning into is a precise question:

How can I build a QC Structure object in the Javascript patch that has the useful properties of both an ordinal index and a key for each element/value in the 'array'?

I can see that the XML Importer patch generates just this kind of QC Structure when you provide a list of members with unique tags at any level. My only problem with that seems to be the fact that it uses strings for all the values, which Kineme Chart Data XY does not seem to like. I can use Javascript to create a structure with numeric values, but need to create the linear index and key per value. I can see examples that just use a simple index array (0..n) and other examples that use a dictionary (association array), but I'm not seeing anything that generates this combined structure that preserves index/order and has keys.

khenkel's picture
Re: Using Chart Tools (Chart Data XY) with Data Structure ...

I don't know of a way to preserve indexes when creating an associative array in Javascript. Instead, try building your structure using Kineme Named Structure Maker (in DataTools, located here: http://kineme.net/release/DataTools/10). You'll still need to parse the XML output values for the numerical input, but Kineme Named Structure Maker should keep the index and key data in order.

lukee's picture
Re: Using Chart Tools (Chart Data XY) with Data Structure ...

Thanks for your comments.

Well, I downloaded the DataTools plug-in and installed it in the usual place (where my ChartTools are happily running), but unfortunately none of the expected patches (based on those listed on the DataTools page) appear in the patch library when I reset QC. Perhaps this is an instance of things not quite working right on Mountain Lion, though many existing patch plugins seem to work just fine.

Anyway, as soon as I can figure out how to get the DataTools working I'll have a play. I might also be able to find an older Mac somewhere, so might at least see how this could address my problem.

khenkel's picture
Re: Using Chart Tools (Chart Data XY) with Data Structure ...

DataTools has been updated to work with 10.8 (version 1.1). Good luck with your composition!