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

Add OnObject functionality #102

Merged
merged 9 commits into from
Feb 27, 2024
34 changes: 28 additions & 6 deletions capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,40 @@
}
}
},
"maxWidth": {
"displayName": "Maximum width",
"displayNameKey": "Visual_MaxWidth",
"type": {
"numeric": true
}
},
"fontSize": {
"displayName": "Text Size",
"displayNameKey": "Visual_TextSize",
"type": {
"formatting": {
"fontSize": true
}
}
},
"maxWidth": {
"displayName": "Maximum width",
"displayNameKey": "Visual_MaxWidth",
"fontFamily": {
"type": {
"numeric": true
"formatting": {
"fontFamily": true
}
}
},
"fontBold": {
"type": {
"bool": true
}
},
"fontItalic": {
"type": {
"bool": true
}
},
"fontUnderline": {
"type": {
"bool": true
}
}
}
Expand Down Expand Up @@ -456,6 +476,8 @@
"privileges": [],
"supportsHighlight": true,
"supportsKeyboardFocus": true,
"supportsOnObjectFormatting": true,
"enablePointerEventsFormatMode": true,
"sorting": {
"default": {}
},
Expand Down
46 changes: 42 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@
"moment": "^2.29.4",
"playwright-chromium": "^1.41.1",
"powerbi-models": "1.14.0",
"powerbi-visuals-api": "~5.7.0",
"powerbi-visuals-tools": "^5.4.0",
"powerbi-visuals-api": "shafeeqz/powerbi-visuals-api#dev/shafeeqazzam/api_5_8_0",
"powerbi-visuals-utils-onobjectformatting": "shafeeqz/powerbi-visuals-utils-onobjectformatting#dev/shafeeqazzam/add-onobject-formatting-utils",
"powerbi-visuals-utils-testutils": "^6.0.3",
"powerbi-visuals-tools": "^5.4.0",
"style-loader": "3.3.4",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
Expand Down
2 changes: 1 addition & 1 deletion pbiviz.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"supportUrl": "https://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-bulletchart"
},
"apiVersion": "5.7.0",
"apiVersion": "5.8.0",
"author": {
"name": "Microsoft",
"email": "[email protected]"
Expand Down
59 changes: 44 additions & 15 deletions src/BulletChartSettingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import IEnumMember = powerbi.IEnumMember;
import {BulletChartOrientation} from "./BulletChartOrientation";
import ILocalizationManager = powerbi.extensibility.ILocalizationManager;

export const BulletChartObjectNames = {
Labels: { name: "labels", displayName: "Category labels" },
} as const;


class TextSizeDefaults {
public static readonly DefaultSize = 11;
public static readonly MinSize = 7;
Expand All @@ -20,6 +25,41 @@ const orientationOptions: IEnumMember[] = [
{ value: BulletChartOrientation.VerticalBottom, displayName: "Visual_Orientation_VerticalBottom" },
];


class BaseFontCardSettings extends Card {
font = new formattingSettings.FontControl({
name: "font",
displayName: "Font",
displayNameKey: "Visual_Font",
fontSize: new formattingSettings.NumUpDown({
name: "fontSize",
displayName: "Text Size",
displayNameKey: "Visual_TextSize",
value: TextSizeDefaults.DefaultSize,
options: {
minValue: { value: TextSizeDefaults.MinSize, type: powerbi.visuals.ValidatorType.Min },
maxValue: { value: TextSizeDefaults.MaxSize, type: powerbi.visuals.ValidatorType.Max },
}
}),
fontFamily: new formattingSettings.FontPicker({
name: "fontFamily",
value: "Arial, sans-serif",
}),
bold: new formattingSettings.ToggleSwitch({
name: "fontBold",
value: false,
}),
italic: new formattingSettings.ToggleSwitch({
name: "fontItalic",
value: false,
}),
underline: new formattingSettings.ToggleSwitch({
name: "fontUnderline",
value: false,
}),
});
}

class DataValuesCard extends Card {
targetValue = new formattingSettings.NumUpDown({
name: "targetValue",
Expand Down Expand Up @@ -124,7 +164,7 @@ class TooltipsCard extends Card {
slices = [this.valueCustomName, this.targetCustomName, this.target2CustomName];
}

class LabelsCard extends Card {
class LabelsCard extends BaseFontCardSettings {
show: SimpleSlice<boolean> = new formattingSettings.ToggleSwitch({
name: "show",
displayName: "Show",
Expand All @@ -143,28 +183,17 @@ class LabelsCard extends Card {
value: { value: "#000000" }
});

fontSize = new formattingSettings.NumUpDown({
name: "fontSize",
displayName: "Text size",
displayNameKey: "Visual_TextSize",
value: TextSizeDefaults.DefaultSize,
options: {
minValue: { value: TextSizeDefaults.MinSize, type: powerbi.visuals.ValidatorType.Min },
maxValue: { value: TextSizeDefaults.MaxSize, type: powerbi.visuals.ValidatorType.Max },
}
});

maxWidth = new formattingSettings.NumUpDown({
name: "maxWidth",
displayName: "Maximum width",
displayNameKey: "Visual_MaxWidth",
value: 80,
});

name: string = "labels";
displayName: string = "Category labels";
name: string = BulletChartObjectNames.Labels.name;
displayName: string = BulletChartObjectNames.Labels.displayName
displayNameKey: string = "Visual_CategoryLabels";
slices = [this.labelColor, this.fontSize, this.maxWidth];
slices = [this.font, this.labelColor, this.maxWidth];
}

class OrientationCard extends Card {
Expand Down
Loading