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

Check for old enums value like "Horizontal Left" with space #110

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# 2.4.1
## 2.4.2
* Check old enums with space like "Horizontal left" to maintain backward compatibility

## 2.4.1
* Packages update
* Fixed tests with measureUnits
* Fixed eslint errors

# 2.4.0
## 2.4.0
* Update powerbi packages, API to 5.7.0
* Migrate from tslint to eslint
* Use new formatting model API
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "powerbi-visuals-bulletchart",
"description": "Bullet chart",
"version": "2.4.1.0",
"version": "2.4.2.0",
"author": {
"name": "Microsoft",
"email": "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions pbiviz.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"visual": {
"name": "BulletChart",
"displayName": "Bullet Chart 2.4.1.0",
"displayName": "Bullet Chart 2.4.2.0",
"guid": "BulletChart1443347686880",
"visualClassName": "BulletChart",
"version": "2.4.1.0",
"version": "2.4.2.0",
"description": "A bullet chart that includes four orientations and a few customization options. Use to feature a single measure against a qualitative range.",
"supportUrl": "https://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-bulletchart"
Expand Down
21 changes: 21 additions & 0 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ export class BulletChart implements IVisual {
const categoricalValues: BulletChartColumns<any[]> =
BulletChartColumns.GET_CATEGORICAL_VALUES(dataView);

BulletChart.updateOrientation(visualSettings, dataView);
BulletChart.limitProperties(visualSettings);
visualSettings = this.SetHighContrastColors(visualSettings, colorHelper);

Expand Down Expand Up @@ -655,6 +656,26 @@ export class BulletChart implements IVisual {
return null;
}

// Implemented for old enums using space containing keys for example "Horizontal Left" which doesn't exist in current version
private static updateOrientation(settings: BulletChartSettingsModel, dataView: DataView): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't mutate args in a static function
give this function a return type or make it not static

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in a089cf8

let orientationValue: string = "";

if (settings?.orientation?.orientation.value?.value) {
orientationValue = settings.orientation.orientation.value.value.toString();
}
else if (dataView?.metadata?.objects?.orientation?.orientation) {
orientationValue = dataView.metadata.objects?.orientation?.orientation as string;
}

const noSpaceOrientation: string = orientationValue.toString().replace(" ", "");

if (Object.values(BulletChartOrientation).includes(noSpaceOrientation as BulletChartOrientation)) {
settings.orientation.orientation.value = settings.orientation.orientation.items.find(option => option.value.toString() === noSpaceOrientation);
} else {
settings.orientation.orientation.value = settings.orientation.orientation.items.find(option => option.value.toString() === BulletChartOrientation.HorizontalLeft);
}
}

private static limitProperties(settings: BulletChartSettingsModel): void {
if (settings.values.minimumPercent.value > settings.values.maximumPercent.value) {
settings.values.maximumPercent.value = settings.values.minimumPercent.value;
Expand Down
Loading