Skip to content

Commit

Permalink
No category issue fix (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elena Rodionova authored and ignatvilesov committed Aug 16, 2018
1 parent 4d19356 commit bf93115
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
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": "1.8.0",
"version": "1.8.1",
"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 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"
Expand Down
4 changes: 2 additions & 2 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module powerbi.extensibility.visual {
}

let categoricalValues: BulletChartColumns<any[]> = 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);
Expand Down Expand Up @@ -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<BulletchartSettings>(dataView);

// change colors for high contrast mode
Expand Down
9 changes: 6 additions & 3 deletions test/visualData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -62,7 +62,10 @@ module powerbi.extensibility.visual.test {
},
values: this.valuesCategory
}
], [
] : [];
return this.createCategoricalDataViewBuilder(
categoriesOptions,
[
{
source: {
displayName: BulletChartData.ColumnValue,
Expand Down
28 changes: 28 additions & 0 deletions test/visualTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
});
});
}

0 comments on commit bf93115

Please sign in to comment.