Skip to content

Commit 1caedf4

Browse files
committed
HoneycombOverlay 增加绘制label
1 parent c840293 commit 1caedf4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/config/HoneycombConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
font: '12px sans-serif',
3333
shadowBlur: 0,
3434
lineWidth: 1,
35-
color: 'rgba(75,80,86,1)',
35+
color: 'rgba(255,255,255,1)'
3636
},
3737
},
3838
mouseOver: {

src/overlay/HoneycombOverlay.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class HoneycombOverlay extends Parameter {
1212
setOptionStyle(ops, callback) {
1313
this._setStyle(this._option, ops, callback);
1414
}
15-
15+
1616
draw() {
1717
this._toDraw();
1818
}
@@ -226,6 +226,15 @@ export default class HoneycombOverlay extends Parameter {
226226
if (item.list.length > 0 && x > -gridsW && y > -gridsW && x < mapSize.width + gridsW && y < mapSize.height + gridsW) {
227227
let drawStyle = this._getStyle(item, i);
228228
this._drawLine(x, y, gridsW - style.padding, drawStyle, this._ctx);
229+
if (style.label.show) {
230+
const text = item.count.toFixed(0);
231+
this._ctx.font = style.label.font;
232+
this._ctx.fillStyle = style.label.color;
233+
let width = this._ctx.measureText(text).width;
234+
const labelX = (x - width / 2);
235+
const labelY = y;
236+
this._ctx.fillText(text, labelX, labelY);
237+
}
229238
}
230239
}
231240
}

0 commit comments

Comments
 (0)