Skip to content
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
1 change: 1 addition & 0 deletions examples/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<div class="input-group" data-name="itemLabelBaselineOffset" data-type="range" data-min="-50" data-max="50" data-multiplier="0.01"></div>
<div class="input-group" data-name="itemLabelColors" data-type="textboxArray"></div>
<div class="input-group" data-name="itemLabelFont" data-type="textbox"></div>
<div class="input-group" data-name="itemLabelFontWeight" data-type="textbox"></div>
<div class="input-group" data-name="itemLabelFontSizeMax" data-type="range" data-min="10" data-max="150"></div>
<div class="input-group" data-name="itemLabelRadius" data-type="range" data-min="0" data-max="100" data-multiplier="0.01"></div>
<div class="input-group" data-name="itemLabelRadiusMax" data-type="range" data-min="0" data-max="100" data-multiplier="0.01"></div>
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const Defaults = Object.freeze({
itemLabelBaselineOffset: 0,
itemLabelColors: ['#000'],
itemLabelFont: 'sans-serif',
itemLabelFontWeight: '',
itemLabelFontSizeMax: baseCanvasSize,
itemLabelRadius: 0.85,
itemLabelRadiusMax: 0.2,
Expand Down
22 changes: 21 additions & 1 deletion src/wheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class Wheel {
this.itemLabelBaselineOffset = props.itemLabelBaselineOffset;
this.itemLabelColors = props.itemLabelColors;
this.itemLabelFont = props.itemLabelFont;
this.itemLabelFontWeight = props.itemLabelFontWeight;
this.itemLabelFontSizeMax = props.itemLabelFontSizeMax;
this.itemLabelRadius = props.itemLabelRadius;
this.itemLabelRadiusMax = props.itemLabelRadiusMax;
Expand Down Expand Up @@ -188,7 +189,7 @@ export class Wheel {
// Set font:
ctx.textBaseline = 'middle';
ctx.textAlign = this.itemLabelAlign;
ctx.font = this._itemLabelFontSize + 'px ' + this.itemLabelFont;
ctx.font = this.itemLabelFontWeight.concat(' ', this._itemLabelFontSize + 'px ' + this.itemLabelFont).trim();

// Build paths for each item:
for (const [i, a] of angles.entries()) {
Expand Down Expand Up @@ -986,6 +987,25 @@ export class Wheel {
this.resize();
}

/**
* The [font weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) to use for all item labels.
* Example: `'bold'`.
*/
get itemLabelFontWeight() {
return this._itemLabelFontWeight;
}
set itemLabelFontWeight(val) {
this._itemLabelFontWeight = util.setProp({
val,
isValid: typeof val === 'string',
errorMessage: 'Wheel.itemLabelFontWeight must be a string',
defaultValue: Defaults.wheel.itemLabelFontWeight,
});

this.resize();
}


/**
* The maximum font size (in pixels) for all item labels.
*/
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/item.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ Item {
"_itemLabelFont": "sans-serif",
"_itemLabelFontSize": 500,
"_itemLabelFontSizeMax": 500,
"_itemLabelFontWeight": "",
"_itemLabelRadius": 0.85,
"_itemLabelRadiusMax": 0.2,
"_itemLabelRotation": 0,
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/wheel.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Wheel {
"_itemLabelFont": "sans-serif",
"_itemLabelFontSize": 500,
"_itemLabelFontSizeMax": 500,
"_itemLabelFontWeight": "",
"_itemLabelRadius": 0.85,
"_itemLabelRadiusMax": 0.2,
"_itemLabelRotation": 0,
Expand Down