|
|
@@ -200,10 +200,10 @@ export default class StockHeatmap extends React.Component {
|
|
|
let l = 0, l2 = 0;
|
|
|
switch (direction) {
|
|
|
case 'zoom-in':
|
|
|
- l = Math.max(this.windowLength - 8, 3);
|
|
|
+ l = Math.max(this.windowLength - 16, 3);
|
|
|
break;
|
|
|
case 'zoom-out':
|
|
|
- l = Math.min(this.windowLength + 8, this.data.length - 8);
|
|
|
+ l = Math.min(this.windowLength + 16, this.data.length - 16);
|
|
|
break;
|
|
|
}
|
|
|
l2 = this.windowLength - l;
|
|
|
@@ -394,6 +394,7 @@ export default class StockHeatmap extends React.Component {
|
|
|
*/
|
|
|
drawYAxisAndBidAskGraph = () => {
|
|
|
if (this.yDomainValues !== null) {
|
|
|
+ const yh2 = this.yScale.bandwidth() * 0.5;
|
|
|
// clear canvas before axis draw
|
|
|
this.clearCanvas(
|
|
|
this.defaults.borderPadding[3] + this.defaults.hmWidth(), this.defaults.borderPadding[0],
|
|
|
@@ -409,10 +410,10 @@ export default class StockHeatmap extends React.Component {
|
|
|
this.drawingContext.textBaseline = 'top';
|
|
|
let maxTextWidth = 0;
|
|
|
this.yDomainValues.map(d => {
|
|
|
- let y = this.yScale(d);
|
|
|
+ let y = this.yScale(d) + yh2;
|
|
|
this.drawingContext.moveTo(0, y);
|
|
|
this.drawingContext.lineTo(this.defaults.axisTickSize, y);
|
|
|
- this.drawingContext.fillText(d.toFixed(2), this.defaults.axisTickSize + this.defaults.yAxisTextPadding, y + 2, this.defaults.axisYWidth - this.defaults.axisTickSize + this.defaults.yAxisTextPadding);
|
|
|
+ this.drawingContext.fillText(d.toFixed(2), this.defaults.axisTickSize + this.defaults.yAxisTextPadding, y, this.defaults.axisYWidth - this.defaults.axisTickSize + this.defaults.yAxisTextPadding);
|
|
|
let tw = this.drawingContext.measureText(d.toFixed(2)).width;
|
|
|
maxTextWidth = maxTextWidth >= tw ? maxTextWidth : tw;
|
|
|
});
|
|
|
@@ -463,15 +464,16 @@ export default class StockHeatmap extends React.Component {
|
|
|
this.bidAskBarAnimConfig[v.rate] = d3.interpolateNumber(this.bidAskBarAnimConfig[v.rate] || 0, l)(t);
|
|
|
this.drawingContext.fillRect(0, this.yScale(v.rate), this.bidAskBarAnimConfig[v.rate], h);
|
|
|
let tw = this.drawingContext.measureText(v.qty).width;
|
|
|
- if (this.defaults.bidAskWidth - this.bidAskBarAnimConfig[v.rate] - 2 >= tw) {
|
|
|
+
|
|
|
+ if (this.defaults.bidAskWidth - this.bidAskBarAnimConfig[v.rate] - tw >= tw) {
|
|
|
// text outside bar
|
|
|
this.drawingContext.textAlign = 'start';
|
|
|
this.drawingContext.fillStyle = this.defaults.textOnBackground;
|
|
|
- this.drawingContext.fillText(v.qty, this.bidAskBarAnimConfig[v.rate] + 2, this.yScale(v.rate) + h / 2 + 1);
|
|
|
+ this.drawingContext.fillText(v.qty, this.bidAskBarAnimConfig[v.rate] + 1, this.yScale(v.rate) + h / 2 + 1);
|
|
|
} else {
|
|
|
this.drawingContext.textAlign = 'end';
|
|
|
this.drawingContext.fillStyle = textColor;
|
|
|
- this.drawingContext.fillText(v.qty, this.bidAskBarAnimConfig[v.rate] - 2, this.yScale(v.rate) + h / 2 + 1);
|
|
|
+ this.drawingContext.fillText(v.qty, this.bidAskBarAnimConfig[v.rate] - tw, this.yScale(v.rate) + h / 2 + 1);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -534,7 +536,7 @@ export default class StockHeatmap extends React.Component {
|
|
|
// draw trade size
|
|
|
let trade_color = marketDepth.lastTradedPrice <= bid1.rate ? this.defaults.sellColor : this.defaults.buyColor;
|
|
|
this.drawingContext.fillStyle = trade_color.toString();
|
|
|
- const r = /*xh2*/ this.defaults.volumeCircleMaxRadius * (+marketDepth.lastTradedQty / maxTradedVolume);
|
|
|
+ const r = /*xh2*/ this.defaults.volumeCircleMaxRadius * (+marketDepth.lastTradedQty / maxTradedVolume) + 3;
|
|
|
this.drawingContext.beginPath();
|
|
|
this.drawingContext.arc(
|
|
|
this.xScale(ts) + xh2,
|
|
|
@@ -543,6 +545,11 @@ export default class StockHeatmap extends React.Component {
|
|
|
);
|
|
|
this.drawingContext.strokeStyle = trade_color;
|
|
|
this.drawingContext.fill();
|
|
|
+
|
|
|
+ // 为球添加白色边框
|
|
|
+ this.drawingContext.lineWidth = 1; // 设置线宽,可以根据需要调整
|
|
|
+ this.drawingContext.strokeStyle = 'white'; // 设置描边颜色为白色
|
|
|
+ this.drawingContext.stroke(); // 执行描边操作
|
|
|
});
|
|
|
|
|
|
// draw buy line path
|
|
|
@@ -670,6 +677,8 @@ export default class StockHeatmap extends React.Component {
|
|
|
width: '100%',
|
|
|
height: '100%',
|
|
|
cursor: 'crosshair',
|
|
|
+ paddingRight: '3%',
|
|
|
+ boxSizing: "border-box"
|
|
|
}}></canvas>
|
|
|
);
|
|
|
}
|