Skip to content

Commit

Permalink
Add barColor prop to BarPlot component
Browse files Browse the repository at this point in the history
  • Loading branch information
keller-mark committed Jan 7, 2019
1 parent 17892d2 commit 60863b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples-src/App.vue
Expand Up @@ -159,6 +159,7 @@
data="exposures_error_single_data"
x="signature"
y="exposure_error"
barColor="gray"
:getData="getData"
:getScale="getScale"
:clickHandler="exampleClickHandler"
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "vue-declarative-plots",
"version": "1.2.16",
"version": "1.2.17",
"private": false,
"scripts": {
"serve": "vue-cli-service serve --open ./examples-src/index.js",
Expand Down
11 changes: 10 additions & 1 deletion src/components/plots/BarPlot.vue
Expand Up @@ -71,6 +71,7 @@ let uuid = 0;
* @prop {string} x The x-scale variable key.
* @prop {string} y The y-scale variable key.
* @prop {number} barMarginX The value for the horizontal margin between bars. Default: 2
* @prop {string} barColor A color for all bars. Optional. If provided, overrides using the x scale for colors.
* @extends mixin
*
* @example
Expand Down Expand Up @@ -99,6 +100,9 @@ export default {
'y': {
type: String
},
'barColor': {
type: String
},
'barMarginX': {
type: Number,
default: BAR_MARGIN_X_DEFAULT
Expand Down Expand Up @@ -277,7 +281,12 @@ export default {
const col = genColor();
colToNode[col] = { "x": d[vm.x], "y": d[vm.y] };
contextHidden.fillStyle = col;
context.fillStyle = xScale.color(d[vm.x]);
if(vm.barColor !== undefined) {
context.fillStyle = vm.barColor;
} else {
context.fillStyle = xScale.color(d[vm.x]);
}
let height = vm.pHeight - y(d[vm.y]) - (vm.pHeight - yOfZero);
context.fillRect(x(d[vm.x]) + (barMarginX/2), y(d[vm.y]), barWidth - barMarginX, height);
Expand Down

0 comments on commit 60863b9

Please sign in to comment.