Skip to content

Commit 1fef75d

Browse files
Skip all borders if borderSkipped === true (#10530)
* Skip all borders if borderSkipped === true This will allow you to skip all borders (not just one side) if you set borderSkipped to boolean true and so allow you to have a consistent legend marker even for bars without borders. Reason is that even if same colored borders are set there are artifacts that make the bar look bad and also even with inflateAmount the bars do look good when big but when only a few pixel in size they start to look bad too so this was the only way for me to make it work so legends are looking good and bars too. * fix failing test, update docs and typings * update typing comment Co-authored-by: Istvan Petres <[email protected]>
1 parent a31e1e5 commit 1fef75d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

docs/charts/bar.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Only the `data` option needs to be specified in the dataset namespace.
7474
| [`barPercentage`](#barpercentage) | `number` | - | - | `0.9` |
7575
| [`barThickness`](#barthickness) | `number`\|`string` | - | - | |
7676
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
77-
| [`borderSkipped`](#borderskipped) | `string` | Yes | Yes | `'start'`
77+
| [`borderSkipped`](#borderskipped) | `string`\|`boolean` | Yes | Yes | `'start'`
7878
| [`borderWidth`](#borderwidth) | `number`\|`object` | Yes | Yes | `0`
7979
| [`borderRadius`](#borderradius) | `number`\|`object` | Yes | Yes | `0`
8080
| [`categoryPercentage`](#categorypercentage) | `number` | - | - | `0.8` |
@@ -163,7 +163,8 @@ Options are:
163163
* `'left'`
164164
* `'top'`
165165
* `'right'`
166-
* `false`
166+
* `false` (don't skip any borders)
167+
* `true` (skip all borders)
167168

168169
#### borderWidth
169170

src/controllers/controller.bar.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ function setBorderSkipped(properties, options, stack, index) {
208208
return;
209209
}
210210

211+
if (edge === true) {
212+
properties.borderSkipped = {top: true, right: true, bottom: true, left: true};
213+
return;
214+
}
215+
211216
const {start, end, reverse, top, bottom} = borderProps(properties);
212217

213218
if (edge === 'middle' && stack) {

types/index.esm.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,10 +1984,10 @@ export interface BarOptions extends Omit<CommonElementOptions, 'borderWidth'> {
19841984
base: number;
19851985

19861986
/**
1987-
* Skipped (excluded) border: 'start', 'end', 'left', 'right', 'bottom', 'top', 'middle' or false (none).
1987+
* Skipped (excluded) border: 'start', 'end', 'left', 'right', 'bottom', 'top', 'middle', false (none) or true (all).
19881988
* @default 'start'
19891989
*/
1990-
borderSkipped: 'start' | 'end' | 'left' | 'right' | 'bottom' | 'top' | 'middle' | false;
1990+
borderSkipped: 'start' | 'end' | 'left' | 'right' | 'bottom' | 'top' | 'middle' | boolean;
19911991

19921992
/**
19931993
* Border radius

0 commit comments

Comments
 (0)