Downloading data from script |
Top Previous Next |
To download data from a button press, simply call the downloadData function: $.dc.dataSource.downloadData(data source name, options) Options can be a whole bunch of stuff, but if you leave it empty and just do, for example: $.dc.dataSource.downloadData("Belleville") it will prompt the user for many of the items, including which tags to download. Options is a javascript object, with these defaults: { Probably a little confusing. First an example, let's say you want to display a different default file name and interval:
$.dc.dataSource.downloadData("Belleville", {filename : "myfile.csv", interval : 120000}) Here's a description of the options: filename: the default file name displayed, or the actual final file name if promptMember is false columns: an array specifying exactly what to download. Should only be used if promptMember is false. Takes an array of objects in the form: {tag : "xxx", label : "yyy"}. Use this when you want to create a button that downloads the same set of tags every time and you don't want to ask the user. Using this is a nice replacement for a dataset tags: an array of string specifying the tags to download. This is just a slimmer version of columns. Use one or the other. Using columns gives you control over labels. This uses the tag name as the label. tagsToDisplay: an array of strings listing (case sensitive) the tags you'd like the user to see when the popup arrives. Leave null to list all tags in the data source start/end: the start and end of the time range to download, in ms. Defaults to the last day. format: presently always "csv" interval: the spacing of the data, in milliseconds. Defaults to 60 seconds. ignoreEmpty: if true, then a row is only created if there is data in one of the columns. If false, then a row is created at every interval between start and end promptMember: if true, then a popup asking for the tags, range, interval, etc is displayed. Otherwise it uses the above settings. Make sure tags or columns is specified if this is false. Make sure they aren't specified if true. |