Skip to content

Commit

Permalink
fixed 0 minimum bug for not 0 minimum value (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvgaliev authored and uve committed Nov 10, 2017
1 parent 48bd304 commit a44042c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.5.2
* Fixed bug when not 0 minimum value calculated as 0

## 1.5.1
* Added check for null objects toString call

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.5.1",
"version": "1.5.2",
"author": {
"name": "Microsoft",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion pbiviz.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Bullet Chart",
"guid": "BulletChart1443347686880",
"visualClassName": "BulletChart",
"version": "1.5.1",
"version": "1.5.2",
"description": "A bullet chart that includes four orientations and a few customization options. Use to feature a single measure against a qualitative range.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-bulletchart"
Expand Down
6 changes: 3 additions & 3 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module powerbi.extensibility.visual {

let anyRangeIsDefined: boolean = [needsImprovement, satisfactory, good, veryGood].some(_.isNumber);

minimum = _.isNumber(minimum) && categoricalValues.Minimum ? minimum : BulletChart.zeroValue;
minimum = _.isNumber(minimum) ? minimum : BulletChart.zeroValue;
needsImprovement = _.isNumber(needsImprovement) ? Math.max(minimum, needsImprovement) : needsImprovement;
satisfactory = _.isNumber(satisfactory) ? Math.max(satisfactory, needsImprovement) : satisfactory;
good = _.isNumber(good) ? Math.max(good, satisfactory) : good;
Expand Down Expand Up @@ -388,11 +388,11 @@ module powerbi.extensibility.visual {
}

public static getRangeValue(value: number, percent: number, targetValue: number, minimum?: number): number {
let negativeMinimumCoef: number;
let negativeMinimumCoef: number = 0;

if (minimum === undefined) {
negativeMinimumCoef = value ? value : BulletChart.zeroValue;
} else {
} else if (minimum < 0) {
negativeMinimumCoef = minimum;
}

Expand Down
2 changes: 1 addition & 1 deletion test/visualData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module powerbi.extensibility.visual.test {
public valuesCategory = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight"];
public valuesValue = [2, 4, 3, 3, 4, 3, 4, 5];
public valuesTargetValue = [3, 3, 3, 2, 2, 2, 3, 3];
public valuesMinimum = [1, 1, 1, 1, 1, 1, 2, 2];
public valuesMinimum = [-1, 1, 1, 1, 1, 1, 2, 2];
public valuesSatisfactory = [2, 2, 2, 3, 3, 3, 3, 3];
public valuesGood = [4, 4, 4, 6, 6, 6, 4, 4];
public valuesMaximum = [6, 6, 6, 8, 8, 8, 8, 7];
Expand Down

0 comments on commit a44042c

Please sign in to comment.