Skip to content

Commit db37b8b

Browse files
authored
Makes Dot Plot working in IE11 (#18)
1 parent 398c7c6 commit db37b8b

8 files changed

Lines changed: 16 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.2.1
2+
* FIX: Fixed an issue that caused Dot Plot to stop working in IE 11
3+
14
## 1.2.0
25
* UPD: powerbi-visuals-tools has been updated to 1.11.0 to support Bookmarks
36
* UPD: API has been updated to 1.11.0 to support Bookmarks

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-visuals-dotplot",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "A dot plot is used to show a representation of the distribution of frequencies. It is most often used to show counts of an occurrence.",
55
"repository": {
66
"type": "git",

pbiviz.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Dot Plot",
55
"guid": "DotPlot1442374105856",
66
"visualClassName": "DotPlot",
7-
"version": "1.2.0",
7+
"version": "1.2.1",
88
"description": "A dot plot is used to show a representation of the distribution of frequencies. It is most often used to show counts of an occurrence.",
99
"supportUrl": "http://community.powerbi.com",
1010
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-dotplot"

src/dataInterfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ module powerbi.extensibility.visual {
7373
categoryColumn: DataViewCategoryColumn;
7474
dotsTotalHeight: number;
7575
maxLabelWidth: number;
76+
maxLabelHeight: number;
7677
labelFontSize: number;
7778
maxCategoryWidth: number;
7879
}

src/settings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@ module powerbi.extensibility.visual {
5858
public categoryAxis: CategoryAxisSettings = new CategoryAxisSettings();
5959
public dataPoint: DataPointSettings = new DataPointSettings();
6060
public labels: LabelsSettings = new LabelsSettings();
61-
public maxLabelWidth: number = 0;
6261
}
6362
}

src/visual.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ module powerbi.extensibility.visual {
282282
const maxLabelLength: number = _.max(formattedValues.map((value: string) => {
283283
return value.length;
284284
})) || DotPlot.MinLabelLength;
285+
285286
const maxLabelWidth: number = Math.max(
286287
DotPlot.MaxLabelWidth,
287288
maxLabelLength
@@ -291,12 +292,13 @@ module powerbi.extensibility.visual {
291292
labelFontSize))
292293
* DotPlot.LabelWidthFactor);
293294

294-
if (settings.labels.orientation === DotPlotLabelsOrientation.Vertical) {
295-
settings.maxLabelWidth = maxLabelWidth;
296-
}
295+
const maxLabelHeight: number = settings.labels.orientation === DotPlotLabelsOrientation.Vertical
296+
? maxLabelWidth
297+
: 0;
298+
297299
const diameter: number = DotPlot.RadiusFactor * radius + DotPlot.ExtraDiameter,
298300
dotsTotalHeight: number = height - maxXAxisHeight
299-
- radius * DotPlot.RadiusFactor - labelFontSize - layout.margin.top - settings.maxLabelWidth,
301+
- radius * DotPlot.RadiusFactor - labelFontSize - layout.margin.top - maxLabelHeight,
300302
maxDots: number = Math.floor(dotsTotalHeight / diameter);
301303

302304
const yScale: LinearScale<number, number> = d3.scale.linear()
@@ -356,6 +358,7 @@ module powerbi.extensibility.visual {
356358
labelFontSize,
357359
dotsTotalHeight,
358360
maxLabelWidth,
361+
maxLabelHeight,
359362
maxCategoryWidth,
360363
dataGroups: dataPointsGroup,
361364
categoryAxisName: categoryColumn.source.displayName,
@@ -500,7 +503,7 @@ module powerbi.extensibility.visual {
500503
dx: number = size.width / DotPlot.DataLabelXOffset
501504
+ size.height * DotPlot.DataLabelXOffsetIndex,
502505
dy: number = size.height + size.height / DotPlot.DataLabelYOffset;
503-
return translateAndRotate(dx, -dy + this.data.settings.maxLabelWidth - (DotPlot.MaxLabelWidth >= this.data.settings.maxLabelWidth ? 0 : this.data.settings.maxLabelWidth * DotPlot.verticalLabelMarginRatio), px, py, DotPlot.DataLabelAngle);
506+
return translateAndRotate(dx, -dy + this.data.maxLabelHeight - (DotPlot.MaxLabelWidth >= this.data.maxLabelHeight ? 0 : this.data.maxLabelHeight * DotPlot.verticalLabelMarginRatio), px, py, DotPlot.DataLabelAngle);
504507
} else {
505508
const dx: number = size.width / DotPlot.DataLabelXOffset,
506509
dy: number = size.height / DotPlot.DataLabelYOffset;
@@ -541,7 +544,7 @@ module powerbi.extensibility.visual {
541544
"transform": (dataPoint: DotPlotDataGroup) => {
542545
return translate(
543546
this.getXDotPositionByIndex(dataPoint.index),
544-
this.layout.margin.top + this.data.labelFontSize + this.data.settings.maxLabelWidth );
547+
this.layout.margin.top + this.data.labelFontSize + this.data.maxLabelHeight);
545548
},
546549
"stroke": DotPlot.DotGroupStrokeColor,
547550
"stroke-width": this.strokeWidth

test/visualBuilder.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
module powerbi.extensibility.visual.test {
3030
// powerbi.extensibility.utils.test
3131
import VisualBuilderBase = powerbi.extensibility.utils.test.VisualBuilderBase;
32-
import VisualSettings = powerbi.extensibility.visual.DotPlot1442374105856.DotPlotSettings;
32+
3333
// DotPlot1442374105856
3434
import VisualClass = powerbi.extensibility.visual.DotPlot1442374105856.DotPlot;
3535

@@ -38,10 +38,6 @@ module powerbi.extensibility.visual.test {
3838
super(width, height, "DotPlot1442374105856");
3939
}
4040

41-
public getSettings(): VisualSettings {
42-
return new VisualSettings();
43-
}
44-
4541
protected build(options: VisualConstructorOptions) {
4642
return new VisualClass(options);
4743
}

test/visualTest.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,6 @@ namespace powerbi.extensibility.visual.test {
295295
});
296296
});
297297

298-
it("orientation", () => {
299-
(dataView.metadata.objects as any).labels.orientation = DotPlotLabelsOrientation.Vertical;
300-
visualBuilder.updateFlushAllD3Transitions(dataView);
301-
visualBuilder.update(dataView);
302-
expect(visualBuilder.getSettings().maxLabelWidth).toBe(0);
303-
});
304-
305298
it("font size", () => {
306299
const fontSize: number = 23,
307300
fontSizeInPt: string = "30.6667px";

0 commit comments

Comments
 (0)