diff --git a/CHANGELOG.md b/CHANGELOG.md index 7822f9e..2cab993 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.8.1 +* Fixed visual's fail on data with empty category field ## 1.8.0 * Implements high contrast mode * API 1.13.0 diff --git a/package.json b/package.json index 22e6854..def6c82 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "powerbi-visuals-bulletchart", "description": "Bullet chart", - "version": "1.8.0", + "version": "1.8.1", "author": { "name": "Microsoft", "email": "pbicvsupport@microsoft.com" diff --git a/pbiviz.json b/pbiviz.json index 686831a..5545d83 100644 --- a/pbiviz.json +++ b/pbiviz.json @@ -1,10 +1,10 @@ { "visual": { "name": "BulletChart", - "displayName": "Bullet Chart 1.8.0", + "displayName": "Bullet Chart 1.8.1", "guid": "BulletChart1443347686880", "visualClassName": "BulletChart", - "version": "1.8.0", + "version": "1.8.1", "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 abd95b2..b709006 100644 --- a/src/visual.ts +++ b/src/visual.ts @@ -167,7 +167,7 @@ module powerbi.extensibility.visual { } let categoricalValues: BulletChartColumns = BulletChartColumns.getCategoricalValues(dataView); - let settings: BulletchartSettings = BulletChart.parseSettings(dataView, categorical.Category.source, colorHelper); + let settings: BulletchartSettings = BulletChart.parseSettings(dataView, colorHelper); BulletChart.updateOrientation(settings); BulletChart.limitProperties(settings); @@ -470,7 +470,7 @@ module powerbi.extensibility.visual { return this.data && this.data.settings; } - private static parseSettings(dataView: DataView, categorySource: DataViewMetadataColumn, colorHelper: ColorHelper): BulletchartSettings { + private static parseSettings(dataView: DataView, colorHelper: ColorHelper): BulletchartSettings { let settings: BulletchartSettings = BulletchartSettings.parse(dataView); // change colors for high contrast mode diff --git a/test/visualData.ts b/test/visualData.ts index f2cfbd4..84306cd 100644 --- a/test/visualData.ts +++ b/test/visualData.ts @@ -52,8 +52,8 @@ module powerbi.extensibility.visual.test { public valuesGood = [4, 4, 4, 6, 6, 6, 4, 4]; public valuesMaximum = [6, 6, 6, 8, 8, 8, 8, 7]; - public getDataView(columnNames?: string[], customizeColumns?: CustomizeColumnFn): DataView { - return this.createCategoricalDataViewBuilder([ + public getDataView(columnNames?: string[], customizeColumns?: CustomizeColumnFn, hasCategories: boolean = true): DataView { + let categoriesOptions = hasCategories ? [ { source: { displayName: BulletChartData.ColumnCategory, @@ -62,7 +62,10 @@ module powerbi.extensibility.visual.test { }, values: this.valuesCategory } - ], [ + ] : []; + return this.createCategoricalDataViewBuilder( + categoriesOptions, + [ { source: { displayName: BulletChartData.ColumnValue, diff --git a/test/visualTest.ts b/test/visualTest.ts index 3007b18..1554e77 100644 --- a/test/visualTest.ts +++ b/test/visualTest.ts @@ -577,6 +577,34 @@ module powerbi.extensibility.visual.test { }); }); }); + + describe("empty categories", () => { + let rangeRects: JQuery[]; + let valueRects: JQuery[]; + + beforeEach(() => { + dataView = defaultDataViewBuilder.getDataView([ + BulletChartData.ColumnCategory, + BulletChartData.ColumnValue, + BulletChartData.ColumnTargetValue, + BulletChartData.ColumnSatisfactory, + BulletChartData.ColumnGood, + BulletChartData.ColumnMaximum + ], undefined, false); + visualBuilder.update(dataView); + + rangeRects = visualBuilder.rangeRects.toArray().map($); + valueRects = visualBuilder.valueRects.toArray().map($); + }); + + it("should visual's elements be rendered", (done) => { + visualBuilder.updateRenderTimeout(dataView, () => { + expect(rangeRects.length).not.toBe(0); + expect(valueRects.length).not.toBe(0); + done(); + }); + }); + }); }); }); }