Browse Source

Fix alignment of labels. "None" doesn't display anything.

parisminton 8 years ago
parent
commit
6dabb3ed91
1 changed files with 7 additions and 7 deletions
  1. 7 7
      renderer/text-wrapper.js

+ 7 - 7
renderer/text-wrapper.js View File

@@ -89,7 +89,7 @@ module.exports = function(theme) {
89 89
     } // end if caption
90 90
 
91 91
 
92
-    if (type === 'label') {
92
+    if (type === 'label' && caption != 'None') {
93 93
       var lines = [[]],
94 94
           maxWidth = 0,
95 95
           words = smartquotes(caption + "").trim().replace(/\s\s+/g, " \n").split(/ /g);
@@ -123,20 +123,20 @@ module.exports = function(theme) {
123 123
       var totalHeight = lines.length * theme.labelLineHeight + (lines.length - 1) * theme.labelLineSpacing;
124 124
 
125 125
       // horizontal alignment
126
-      var x = theme.labelAlign === "left" ? left : theme.labelAlign === "right" ? right : (left + right) / 2;
126
+      var x = theme.labelAlign === "left" ? labelLeft : theme.labelAlign === "right" ? labelRight : (labelLeft + labelRight) / 2;
127 127
 
128 128
       // Vertical alignment
129 129
       var y;
130 130
 
131
-      if (top !== null && bottom !== null) {
131
+      if (labelTop !== null && labelBottom !== null) {
132 132
         // Vertical center
133
-        y = (bottom + top - totalHeight) / 2;
134
-      } else if (bottom !== null) {
133
+        y = (labelBottom + labelTop - totalHeight) / 2;
134
+      } else if (labelBottom !== null) {
135 135
         // Vertical align bottom
136
-        y = bottom - totalHeight;
136
+        y = labelBottom - totalHeight;
137 137
       } else {
138 138
         // Vertical align top
139
-        y = top;
139
+        y = labelTop;
140 140
       }
141 141
 
142 142
       // draw label