Skip to content

Commit

Permalink
Check for old enums value like "Horizontal Left" with space to mainta…
Browse files Browse the repository at this point in the history
…in backwards compatibility
  • Loading branch information
adiletelf committed Apr 23, 2024
1 parent b846f80 commit dcec06e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
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 {
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

0 comments on commit dcec06e

Please sign in to comment.