Skip to content

Commit b0c6258

Browse files
committed
add layout.barcornerradius property
1 parent 31c3ac2 commit b0c6258

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

src/traces/bar/layout_attributes.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,14 @@ module.exports = {
5151
'Sets the gap (in plot fraction) between bars of',
5252
'the same location coordinate.'
5353
].join(' ')
54-
}
54+
},
55+
barcornerradius: {
56+
valType: 'any',
57+
dflt: 0,
58+
editType: 'plot',
59+
description: [
60+
'Sets the rounding of corners. May be an integer number of pixels,',
61+
'or a percentage of bar width(as a string).'
62+
].join(' ')
63+
},
5564
};

src/traces/bar/layout_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ module.exports = function(layoutIn, layoutOut, fullData) {
4747

4848
coerce('bargap', (shouldBeGapless && !gappedAnyway) ? 0 : 0.2);
4949
coerce('bargroupgap');
50+
coerce('barcornerradius');
5051
};

src/traces/bar/plot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
249249
);
250250
}
251251
}
252-
var r = calcCornerRadius(trace.marker.cornerradius);
252+
var r = calcCornerRadius(trace.marker.cornerradius || fullLayout.barcornerradius);
253253

254254
var path;
255255
if(r && isHorizontal) {

test/image/mocks/bar-rounded-corners.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
],
2222
"x": [20, 14, 2, 18],
2323
"type": "bar",
24-
"marker": {"cornerradius": "30%"},
2524
"orientation": "h",
2625
"xaxis": "x2",
2726
"yaxis": "y2"
2827
}
2928

3029
],
31-
"layout": {"grid": {"rows": 1, "columns": 2, "pattern": "independent"}}
30+
"layout": {"grid": {"rows": 1, "columns": 2, "pattern": "independent"}, "barcornerradius": "30%"}
3231
}
3332

test/plot-schema.json

+12
Original file line numberDiff line numberDiff line change
@@ -14776,6 +14776,12 @@
1477614776
"zoomScale"
1477714777
],
1477814778
"layoutAttributes": {
14779+
"barcornerradius": {
14780+
"description": "Sets the rounding of corners. May be an integer number of pixels, or a percentage of bar width(as a string).",
14781+
"dflt": 0,
14782+
"editType": "plot",
14783+
"valType": "any"
14784+
},
1477914785
"bargap": {
1478014786
"description": "Sets the gap (in plot fraction) between bars of adjacent location coordinates.",
1478114787
"editType": "calc",
@@ -32068,6 +32074,12 @@
3206832074
"showLegend"
3206932075
],
3207032076
"layoutAttributes": {
32077+
"barcornerradius": {
32078+
"description": "Sets the rounding of corners. May be an integer number of pixels, or a percentage of bar width(as a string).",
32079+
"dflt": 0,
32080+
"editType": "plot",
32081+
"valType": "any"
32082+
},
3207132083
"bargap": {
3207232084
"description": "Sets the gap (in plot fraction) between bars of adjacent location coordinates.",
3207332085
"editType": "calc",

0 commit comments

Comments
 (0)