X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FUtil.js;h=7fca030a765695cc4470b528f38c4f9766d85556;hb=009e949fc89eae685ef50e47e96ec86f26808c49;hp=7ab0b9a485b69118fb390acb9ecc6ee9b722660a;hpb=fa607ffbc86e564cd44c2626f14ef799518b8252;p=dygraphs.git diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 7ab0b9a..7fca030 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -6,8 +6,9 @@ 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 || ""; @@ -21,6 +22,21 @@ Util.getYLabels = function(axis_num, parent) { } /** + * 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. * You can specify a parent if more than one graph is on the document. */ @@ -34,3 +50,10 @@ Util.getClassTexts = function(css_class, parent) { texts.sort(); return texts; } + +Util.getLegend = function(parent) { + parent = parent || document; + var legend = parent.getElementsByClassName("dygraph-legend")[0]; + return legend.textContent; +} +