var Util = {};
/**
- * Get the y-labels for a given axis. You can specify a parent if more than one
- * graph is on the document.
+ * Get the y-labels for a given axis.
+ *
+ * You can specify a parent if more than one graph is in the document.
*/
Util.getYLabels = function(axis_num, parent) {
axis_num = axis_num || "";
ary.push(y_labels[i].innerHTML);
}
return ary;
-}
+};
+
+/**
+ * Get the x-labels for a given axis.
+ *
+ * You can specify a parent if more than one graph is in the document.
+ */
+Util.getXLabels = function(parent) {
+ parent = parent || document;
+ var x_labels = parent.getElementsByClassName("dygraph-axis-label-x");
+ var ary = [];
+ for (var i = 0; i < x_labels.length; i++) {
+ ary.push(x_labels[i].innerHTML);
+ }
+ return ary;
+};
/**
* Returns all text in tags w/ a given css class, sorted.
}
texts.sort();
return texts;
-}
+};
+
+Util.getLegend = function(parent) {
+ parent = parent || document;
+ var legend = parent.getElementsByClassName("dygraph-legend")[0];
+ var re = new RegExp(String.fromCharCode(160), 'g');
+ return legend.textContent.replace(re, ' ');
+};
+
+/**
+ * Assert that all elements have a certain style property.
+ */
+Util.assertStyleOfChildren = function(selector, property, expectedValue) {
+ assertTrue(selector.length > 0);
+ $.each(selector, function(idx, child) {
+ assertEquals(expectedValue, $(child).css(property));
+ });
+};
+
+
+/**
+ * Takes in an array of strings and returns an array of floats.
+ */
+Util.makeNumbers = function(ary) {
+ var ret = [];
+ for (var i = 0; i < ary.length; i++) {
+ ret.push(parseFloat(ary[i]));
+ }
+ return ret;
+};