瀏覽代碼

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

parisminton 8 年之前
父節點
當前提交
6dabb3ed91
共有 1 個文件被更改,包括 7 次插入7 次删除
  1. 7 7
      renderer/text-wrapper.js

+ 7 - 7
renderer/text-wrapper.js 查看文件

89
     } // end if caption
89
     } // end if caption
90
 
90
 
91
 
91
 
92
-    if (type === 'label') {
92
+    if (type === 'label' && caption != 'None') {
93
       var lines = [[]],
93
       var lines = [[]],
94
           maxWidth = 0,
94
           maxWidth = 0,
95
           words = smartquotes(caption + "").trim().replace(/\s\s+/g, " \n").split(/ /g);
95
           words = smartquotes(caption + "").trim().replace(/\s\s+/g, " \n").split(/ /g);
123
       var totalHeight = lines.length * theme.labelLineHeight + (lines.length - 1) * theme.labelLineSpacing;
123
       var totalHeight = lines.length * theme.labelLineHeight + (lines.length - 1) * theme.labelLineSpacing;
124
 
124
 
125
       // horizontal alignment
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
       // Vertical alignment
128
       // Vertical alignment
129
       var y;
129
       var y;
130
 
130
 
131
-      if (top !== null && bottom !== null) {
131
+      if (labelTop !== null && labelBottom !== null) {
132
         // Vertical center
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
         // Vertical align bottom
135
         // Vertical align bottom
136
-        y = bottom - totalHeight;
136
+        y = labelBottom - totalHeight;
137
       } else {
137
       } else {
138
         // Vertical align top
138
         // Vertical align top
139
-        y = top;
139
+        y = labelTop;
140
       }
140
       }
141
 
141
 
142
       // draw label
142
       // draw label