Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option for bullet chart to change padding of internal target #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/chart-bullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,24 @@
Math.round(this.canvasHeight * 0.4) - 1, color, color);
},

renderTarget: function (highlight) {
var targetval = this.values[0],
x = Math.round(this.canvasWidth * ((targetval - this.min) / this.range) - (this.options.get('targetWidth') / 2)),
targettop = Math.round(this.canvasHeight * 0.10),
targetheight = this.canvasHeight - (targettop * 2),
color = this.options.get('targetColor');
if (highlight) {
color = this.calcHighlightColor(color, this.options);
}
return this.target.drawRect(x, targettop, this.options.get('targetWidth') - 1, targetheight - 1, color, color);
},
renderTarget: function (highlight) {
var targetval = this.values[0],
x = Math.round(this.canvasWidth * ((targetval - this.min) / this.range) - (this.options.get('targetWidth') / 2)),
color = this.options.get('targetColor');
if (highlight) {
color = this.calcHighlightColor(color, this.options);
}

var targettop = Math.round(this.canvasHeight * 0.10)

if(this.options.get('targetVerticalPadding') != null){
targettop = this.options.get('targetVerticalPadding');
}

var targetheight = this.canvasHeight - (targettop * 2)

return this.target.drawRect(x, targettop, this.options.get('targetWidth') - 1, targetheight - 1, color, color);
},

render: function () {
var vlen = this.values.length,
Expand Down
1 change: 1 addition & 0 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
bullet: {
targetColor: '#f33',
targetWidth: 3, // width of the target bar in pixels
targetVerticalPadding: null,
performanceColor: '#33f',
rangeColors: ['#d3dafe', '#a8b6ff', '#7f94ff'],
base: undefined, // set this to a number to change the base start number
Expand Down
1 change: 1 addition & 0 deletions src/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
* options:
* targetColor - The color of the vertical target marker
* targetWidth - The width of the target marker in pixels
* targetVerticalPadding - The top and bottom padding of the target marker in pixels
* performanceColor - The color of the performance measure horizontal bar
* rangeColors - Colors to use for each qualitative range background color
*
Expand Down