+var createRotatedDiv = function(g, box, axis, classes, html) {
+ // TODO(danvk): is this outer div actually necessary?
+ var div = document.createElement("div");
+ div.style.position = 'absolute';
+ if (axis == 1) {
+ // NOTE: this is cheating. Should be positioned relative to the box.
+ div.style.left = '0px';
+ } else {
+ div.style.left = box.x + 'px';
+ }
+ div.style.top = box.y + 'px';
+ div.style.width = box.w + 'px';
+ div.style.height = box.h + 'px';
+ div.style.fontSize = (g.getOption('yLabelWidth') - 2) + 'px';
+
+ var inner_div = document.createElement("div");
+ inner_div.style.position = 'absolute';
+ inner_div.style.width = box.h + 'px';
+ inner_div.style.height = box.w + 'px';
+ inner_div.style.top = (box.h / 2 - box.w / 2) + 'px';
+ inner_div.style.left = (box.w / 2 - box.h / 2) + 'px';
+ inner_div.style.textAlign = 'center';
+
+ // CSS rotation is an HTML5 feature which is not standardized. Hence every
+ // browser has its own name for the CSS style.
+ var val = 'rotate(' + (axis == 1 ? '-' : '') + '90deg)';
+ inner_div.style.transform = val; // HTML5
+ inner_div.style.WebkitTransform = val; // Safari/Chrome
+ inner_div.style.MozTransform = val; // Firefox
+ inner_div.style.OTransform = val; // Opera
+ inner_div.style.msTransform = val; // IE9
+
+ if (typeof(document.documentMode) !== 'undefined' &&
+ document.documentMode < 9) {
+ // We're dealing w/ an old version of IE, so we have to rotate the text
+ // using a BasicImage transform. This uses a different origin of rotation
+ // than HTML5 rotation (top left of div vs. its center).
+ inner_div.style.filter =
+ 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' +
+ (axis == 1 ? '3' : '1') + ')';
+ inner_div.style.left = '0px';
+ inner_div.style.top = '0px';
+ }
+
+ var class_div = document.createElement("div");
+ class_div.className = classes;
+ class_div.innerHTML = html;
+
+ inner_div.appendChild(class_div);
+ div.appendChild(inner_div);
+ return div;
+};
+