diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eab366..f4c3be6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package-lock.json b/package-lock.json index 589ca27..43e7054 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "powerbi-visuals-bulletchart", - "version": "2.4.1.0", + "version": "2.4.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "powerbi-visuals-bulletchart", - "version": "2.4.1.0", + "version": "2.4.2.0", "license": "MIT", "dependencies": { "d3-array": "^3.2.4", diff --git a/package.json b/package.json index 190b74a..61763a1 100644 --- a/package.json +++ b/package.json @@ -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": "pbicvsupport@microsoft.com" diff --git a/pbiviz.json b/pbiviz.json index f06b0dc..cadd1df 100644 --- a/pbiviz.json +++ b/pbiviz.json @@ -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" diff --git a/src/visual.ts b/src/visual.ts index d34b5bc..e14465a 100644 --- a/src/visual.ts +++ b/src/visual.ts @@ -364,6 +364,7 @@ export class BulletChart implements IVisual { const categoricalValues: BulletChartColumns = BulletChartColumns.GET_CATEGORICAL_VALUES(dataView); + BulletChart.updateOrientation(visualSettings, dataView); BulletChart.limitProperties(visualSettings); visualSettings = this.SetHighContrastColors(visualSettings, colorHelper); @@ -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;