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
8 changes: 7 additions & 1 deletion karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ module.exports = (config) => {
config.set({
mode: "development",
browserNoActivityTimeout: 10000,
browsers: ["ChromeHeadless"],
browsers: ["ChromeDebugging"],
customLaunchers: {
MulyukovAidar marked this conversation as resolved.
Show resolved Hide resolved
ChromeDebugging: {
base: "ChromeHeadless",
flags: ["--remote-debugging-port=9333"]
}
},
colors: true,
frameworks: ["jasmine"],
reporters: ["progress", "junit"],
Expand Down
23 changes: 7 additions & 16 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"moment": "^2.29.4",
"playwright-chromium": "^1.41.1",
"powerbi-models": "1.14.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-api": "^5.8.0",
"powerbi-visuals-utils-onobjectutils": "^6.0.1",
"powerbi-visuals-utils-testutils": "^6.0.3",
"powerbi-visuals-tools": "^5.4.0",
"style-loader": "3.3.4",
Expand Down
118 changes: 118 additions & 0 deletions src/BulletChartSettingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import IEnumMember = powerbi.IEnumMember;
import {BulletChartOrientation} from "./BulletChartOrientation";
import ILocalizationManager = powerbi.extensibility.ILocalizationManager;
import {BarRectType} from "./dataInterfaces";
import FormattingId = powerbi.visuals.FormattingId;

const nameof = <T>(name: Extract<keyof T, string>): string => name;
MulyukovAidar marked this conversation as resolved.
Show resolved Hide resolved

export const BulletChartObjectNames = {
Labels: { name: "labels", displayName: "Category labels" },
Expand All @@ -23,6 +26,121 @@ export const BulletChartObjectNames = {
Bullet: { name: BarRectType.Bullet, displayName: "Bullet" },
} as const;

export const labelsReference: {
cardUid: string;
groupUid: string;
fontFamily: FormattingId;
bold: FormattingId;
italic: FormattingId;
underline: FormattingId;
fontSize: FormattingId;
labelColor: FormattingId;
show: FormattingId;
} = {
cardUid: "Visual-labels-card",
groupUid: "labels-group",
fontFamily: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontFamily"
},
bold: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontBold"
},
italic: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontItalic"
},
underline: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontUnderline"
},
fontSize: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontSize"
},
labelColor: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: nameof<LabelsCard>("labelColor")
},
show: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: nameof<LabelsCard>("show")
MulyukovAidar marked this conversation as resolved.
Show resolved Hide resolved
}
} as const;

export const axisReference: {
cardUid: string;
groupUid: string;
axis: FormattingId;
axisColor: FormattingId,
syncAxis: FormattingId,
showMainAxis: FormattingId,
orientation: FormattingId,
} = {
cardUid: "Visual-axis-card",
groupUid: "axis-group",
axis: {
objectName: BulletChartObjectNames.Axis.name,
propertyName: nameof<AxisCard>("axis")
},
axisColor: {
objectName: BulletChartObjectNames.Axis.name,
propertyName: nameof<AxisCard>("axisColor")
},
syncAxis: {
objectName: BulletChartObjectNames.SyncAxis.name,
propertyName: nameof<SyncAxis>("syncAxis")
},
showMainAxis: {
objectName: BulletChartObjectNames.SyncAxis.name,
propertyName: nameof<SyncAxis>("showMainAxis")
},
orientation: {
objectName: BulletChartObjectNames.Orientation.name,
propertyName: nameof<OrientationCard>("orientation")
},
} as const;


export const colorsReference: {
cardUid: string;
groupUid: string;
minColor: FormattingId;
needsImprovementColor: FormattingId;
satisfactoryColor: FormattingId;
goodColor: FormattingId;
veryGoodColor: FormattingId;
bulletColor: FormattingId;
} = {
cardUid: "Visual-colors-card",
groupUid: "colors-group",
minColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: nameof<ColorsCard>("minColor")
},
needsImprovementColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: nameof<ColorsCard>("needsImprovementColor")
},
satisfactoryColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: nameof<ColorsCard>("satisfactoryColor")
},
goodColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: nameof<ColorsCard>("goodColor")
},
veryGoodColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: nameof<ColorsCard>("veryGoodColor")
},
bulletColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: nameof<ColorsCard>("bulletColor")
},
} as const;


class TextSizeDefaults {
public static readonly DefaultSize = 11;
Expand Down
126 changes: 5 additions & 121 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import {
SubSelectableDisplayNameAttribute,
SubSelectableObjectNameAttribute,
SubSelectableTypeAttribute,
} from "powerbi-visuals-utils-onobjectformatting/src"
} from "powerbi-visuals-utils-onobjectutils"

// d3
type BulletSelection<T1, T2 = T1> = Selection<any, T1, any, T2>;
Expand Down Expand Up @@ -119,11 +119,11 @@ import ILocalizationManager = powerbi.extensibility.ILocalizationManager;
import CustomVisualSubSelection = powerbi.visuals.CustomVisualSubSelection;
import SubSelectionStyles = powerbi.visuals.SubSelectionStyles;
import VisualSubSelectionShortcuts = powerbi.visuals.VisualSubSelectionShortcuts;
import FormattingId = powerbi.visuals.FormattingId;
import VisualShortcutType = powerbi.visuals.VisualShortcutType;
import CustomVisualObject = powerbi.visuals.CustomVisualObject;
import SubSelectionStylesType = powerbi.visuals.SubSelectionStylesType;

import { labelsReference, axisReference, colorsReference } from "./BulletChartSettingsModel";

interface ClassAndSelector {
className: string;
Expand All @@ -138,122 +138,6 @@ function CreateClassAndSelector(className: string) {
}


const labelsReference: {
cardUid: string;
groupUid: string;
fontFamily: FormattingId;
bold: FormattingId;
italic: FormattingId;
underline: FormattingId;
fontSize: FormattingId;
color: FormattingId;
show: FormattingId;
} = {
cardUid: "Visual-labels-card",
groupUid: "labels-group",
fontFamily: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontFamily"
},
bold: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontBold"
},
italic: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontItalic"
},
underline: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontUnderline"
},
fontSize: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "fontSize"
},
color: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "color"
},
show: {
objectName: BulletChartObjectNames.Labels.name,
propertyName: "show"
}
} as const;

const axisReference: {
cardUid: string;
groupUid: string;
axis: FormattingId;
axisColor: FormattingId,
syncAxis: FormattingId,
showMainAxis: FormattingId,
orientation: FormattingId,
} = {
cardUid: "Visual-axis-card",
groupUid: "axis-group",
axis: {
objectName: BulletChartObjectNames.Axis.name,
propertyName: "axis"
},
axisColor: {
objectName: BulletChartObjectNames.Axis.name,
propertyName: "axisColor"
},
syncAxis: {
objectName: BulletChartObjectNames.SyncAxis.name,
propertyName: "syncAxis"
},
showMainAxis: {
objectName: BulletChartObjectNames.SyncAxis.name,
propertyName: "showMainAxis"
},
orientation: {
objectName: BulletChartObjectNames.Orientation.name,
propertyName: "orientation"
},
} as const;


const colorsReference: {
cardUid: string;
groupUid: string;
minColor: FormattingId;
needsImprovementColor: FormattingId;
satisfactoryColor: FormattingId;
goodColor: FormattingId;
veryGoodColor: FormattingId;
bulletColor: FormattingId;
} = {
cardUid: "Visual-colors-card",
groupUid: "colors-group",
minColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: "minColor"
},
needsImprovementColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: "needsImprovementColor"
},
satisfactoryColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: "satisfactoryColor"
},
goodColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: "goodColor"
},
veryGoodColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: "veryGoodColor"
},
bulletColor: {
objectName: BulletChartObjectNames.Colors.name,
propertyName: "bulletColor"
},
} as const;


export class BulletChart implements IVisual {
private static ScrollBarSize: number = 22;
private static SpaceRequiredForBarVertically: number = 100;
Expand Down Expand Up @@ -1651,8 +1535,8 @@ export class BulletChart implements IVisual {
label: labelsReference.fontSize.propertyName
},
fontColor: {
reference: { ...labelsReference.color },
label: labelsReference.color.propertyName
reference: { ...labelsReference.labelColor },
label: labelsReference.labelColor.propertyName
}
};
}
Expand Down Expand Up @@ -1752,7 +1636,7 @@ export class BulletChart implements IVisual {
labelsReference.fontSize,
labelsReference.italic,
labelsReference.underline,
labelsReference.color
labelsReference.labelColor
]
},
{
Expand Down