Skip to content

Commit

Permalink
feat: add font-config of tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
fwm227 committed Jul 15, 2019
1 parent 8309ed1 commit 60fffd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ BarChart.prototype.drawBars = function (move_position) {
isSelect = true;
selInfo = {
label_val: optionManager.labels[Math.floor((move_position.x - self.yAxis_left) / step_len)],
data_val: bar.val
data_val: bar.val,
style: bar.d_style
}
} else isSelect = false;
drawBar(self.context, bar, isSelect);
Expand Down
5 changes: 2 additions & 3 deletions core/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ export default {
height: 50,
radius: 4,
mark: {
radius: 5,
style: 'rgb(16, 142, 233)'
radius: 5
},
font: {
size: 14,
family: 'Arial',
style: 'rgba(0, 0, 0, 0.6)'
style: 'rgb(255, 255, 255)'
}
}
};
3 changes: 2 additions & 1 deletion core/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ function drawTooltip (ctx, move_position, info) {
ctx.fillStyle = '#fff';
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
ctx.fillStyle = optionManager.tooltip.font.style;
ctx.fillText(info.label_val, moveX + additionWidth / 2, moveY + 0.85 * tooltipHeight / 3);
ctx.fillText(tooltipText, moveX + additionWidth / 2 + 3 * markRadius, moveY + 2.1 * tooltipHeight / 3);
ctx.closePath();
ctx.stroke();

ctx.beginPath();
ctx.fillStyle = optionManager.tooltip.mark.style;
ctx.fillStyle = info.style;
ctx.arc(moveX + additionWidth / 2 + markRadius, moveY + 2 * tooltipHeight / 3, markRadius, 0, 2 * Math.PI);
ctx.fill();
}
Expand Down

0 comments on commit 60fffd7

Please sign in to comment.