return legend.textContent;
}
+// returns all text in tags w/ a given css class, sorted.
+function getClassTexts(css_class) {
+ var texts = [];
+ var els = document.getElementsByClassName(css_class);
+ for (var i = 0; i < els.length; i++) {
+ texts[i] = els[i].textContent;
+ }
+ texts.sort();
+ return texts;
+}
+
MultipleAxesTestCase.getData = function() {
var data = [];
for (var i = 1; i <= 100; i++) {
MultipleAxesTestCase.prototype.testBasicMultipleAxes = function() {
var data = MultipleAxesTestCase.getData();
- g = new Dygraph(
+ var g = new Dygraph(
document.getElementById("graph"),
data,
{
MultipleAxesTestCase.prototype.testNewStylePerAxisOptions = function() {
var data = MultipleAxesTestCase.getData();
- g = new Dygraph(
+ var g = new Dygraph(
document.getElementById("graph"),
data,
{
var el = document.getElementById("graph");
- g = new Dygraph(
+ var g = new Dygraph(
el,
data,
{
el.style.marginLeft = '200px';
el.style.marginTop = '200px';
- g = new Dygraph(
+ var g = new Dygraph(
el,
data,
{
}
);
- // returns all text in tags w/ a given css class, sorted.
- function getTexts(css_class) {
- var texts = [];
- var els = document.getElementsByClassName(css_class);
- for (var i = 0; i < els.length; i++) {
- texts[i] = els[i].textContent;
- }
- texts.sort();
- return texts;
- }
-
assertEquals(["Chart title", "x-axis", "y-axis", "y2-axis"],
- getTexts("dygraph-label"));
- assertEquals(["Chart title"], getTexts("dygraph-title"));
- assertEquals(["x-axis"], getTexts("dygraph-xlabel"));
- assertEquals(["y-axis"], getTexts("dygraph-ylabel"));
- assertEquals(["y2-axis"], getTexts("dygraph-y2label"));
+ getClassTexts("dygraph-label"));
+ assertEquals(["Chart title"], getClassTexts("dygraph-title"));
+ assertEquals(["x-axis"], getClassTexts("dygraph-xlabel"));
+ assertEquals(["y-axis"], getClassTexts("dygraph-ylabel"));
+ assertEquals(["y2-axis"], getClassTexts("dygraph-y2label"));
// TODO(danvk): check relative positioning here: title on top, y left of y2.
};
+
+// Check that a chart w/o a secondary y-axis will not get a y2label, even if one
+// is specified.
+MultipleAxesTestCase.prototype.testNoY2LabelWithoutSecondaryAxis = function() {
+ var g = new Dygraph(
+ document.getElementById("graph"),
+ MultipleAxesTestCase.getData(),
+ {
+ labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
+ width: 640,
+ height: 350,
+ xlabel: 'x-axis',
+ ylabel: 'y-axis',
+ y2label: 'y2-axis',
+ title: 'Chart title'
+ }
+ );
+
+ assertEquals(["Chart title", "x-axis", "y-axis"],
+ getClassTexts("dygraph-label"));
+ assertEquals(["Chart title"], getClassTexts("dygraph-title"));
+ assertEquals(["x-axis"], getClassTexts("dygraph-xlabel"));
+ assertEquals(["y-axis"], getClassTexts("dygraph-ylabel"));
+ assertEquals([], getClassTexts("dygraph-y2label"));
+};