Skip to content

Commit

Permalink
20094 RadarChart: displays only one point with incorrect value tooltip (
Browse files Browse the repository at this point in the history
#14)

20149 Bug: RadarChart 1.0.3: axis settings is not availible
  • Loading branch information
vtkalek authored and ignatvilesov committed Aug 4, 2017
1 parent 74d6b91 commit 86ca52e
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.4
* Fix bug: displays only one point with incorrect value tooltip
* Fix bug: axis settings "Axis start" is not availible

## 1.0.3

* Remove all 'any' or mistyped values
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-radarchart",
"description": "A simple radar chart supporting multiple measures plotted over a categorical axis. Also known as a web chart, spider chart, or star chart. Use to display performance metrics for quality improvement.",
"version": "1.0.3",
"version": "1.0.4",
"author": {
"name": "Microsoft",
"email": "pbicvsupport@microsoft.com"
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": "Radar Chart",
"guid": "RadarChart1446119667547",
"visualClassName": "RadarChart",
"version": "1.0.3",
"version": "1.0.4",
"description": "A simple radar chart supporting multiple measures plotted over a categorical axis. Also known as a web chart, spider chart, or star chart. Use to display performance metrics for quality improvement.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/PowerBI-visuals-RadarChart"
Expand Down
45 changes: 35 additions & 10 deletions src/radarChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,17 @@ module powerbi.extensibility.visual {

return labelsData;
}

public static checkAndUpdateAxis(dataView: DataView, values: DataViewValueColumns) {
if (dataView.categorical.categories[0].values.length <= 2) {// add 2-3 categories to make it looks like a rhomb
for (let i: number = dataView.categorical.categories[0].values.length; i < RadarChart.minimumAxisCount; i++) {
dataView.categorical.categories[0].values.push(" ");
for (let j: number = 0; j < values.length; j++) {
values[j].values.push(0);
}
}
}
}
private static minimumAxisCount: number = 4;
public static converter(dataView: DataView,
colorPalette: IColorPalette,
visualHost: IVisualHost,
Expand All @@ -280,12 +290,12 @@ module powerbi.extensibility.visual {
series: [],
};
}

let catDv: DataViewCategorical = dataView.categorical,
values: DataViewValueColumns = catDv.values,
series: RadarChartSeries[] = [],
grouped: DataViewValueColumnGroup[];
const settings: RadarChartSettings = this.parseSettings(dataView, colorPalette);
RadarChart.checkAndUpdateAxis(dataView, values);
grouped = catDv && catDv.values
? catDv.values.grouped()
: null;
Expand All @@ -302,7 +312,6 @@ module powerbi.extensibility.visual {
dataPoints: [],
title: settings.legend.titleText
};

for (let i: number = 0, iLen: number = values.length; i < iLen; i++) {
let color: string = colorPalette.getColor(i.toString()).value,
serieIdentity: ISelectionId,
Expand Down Expand Up @@ -354,7 +363,7 @@ module powerbi.extensibility.visual {
catDv.categories[0].values[k],
values[i].values[k],
i);

let currCatValue = catDv.categories[0].values[k];
let labelFormatString: string = valueFormatter.getFormatStringByColumn(catDv.values[i].source),
fontSizeInPx: string = PixelConverter.fromPoint(settings.labels.fontSize);

Expand All @@ -372,7 +381,8 @@ module powerbi.extensibility.visual {
value: y,
labelFormatString: labelFormatString,
labelFontSize: fontSizeInPx,
highlight: hasHighlights && !!(values[0].highlights[k])
highlight: hasHighlights && !!(values[0].highlights[k]),
showPoint: currCatValue === " " ? false : true
});
}
}
Expand Down Expand Up @@ -456,7 +466,6 @@ module powerbi.extensibility.visual {
return;
}
let dataView: DataView = options.dataViews[0];

this.radarChartData = RadarChart.converter(
dataView,
this.colorPalette,
Expand Down Expand Up @@ -635,7 +644,7 @@ module powerbi.extensibility.visual {
.remove();
}

private isIntersect(y11: number, y12: number, y21: number, y22: number): boolean {
public static isIntersect(y11: number, y12: number, y21: number, y22: number): boolean {
if (y11 <= y21 && y21 <= y12) {
return true;
}
Expand Down Expand Up @@ -684,7 +693,7 @@ module powerbi.extensibility.visual {
let curTextUpperPoint: number = current.y - currentTextHeight;
let labelTextUpperPoint: number = label.y - otherTextHeight;

if (this.isIntersect(current.y, curTextUpperPoint, label.y, labelTextUpperPoint)) {
if (RadarChart.isIntersect(current.y, curTextUpperPoint, label.y, labelTextUpperPoint)) {
let shift: number = this.shiftText(current.y, curTextUpperPoint, label.y, labelTextUpperPoint, shiftDown);
current.y += shift;
if (!shiftDown && current.y - 5 < 0 || shiftDown && current.y + currentTextHeight / 2 + 5 > 0) {
Expand Down Expand Up @@ -989,7 +998,7 @@ module powerbi.extensibility.visual {
let dotsSelection: UpdateSelection<RadarChartDatapoint> = nodeSelection
.selectAll(RadarChart.ChartDotSelector.selector)
.data((dataPoints: RadarChartDatapoint[]) => {
return dataPoints.filter(d => d.y != null);
return dataPoints.filter(d => d.y != null && d.showPoint);
});

dotsSelection
Expand Down Expand Up @@ -1050,7 +1059,7 @@ module powerbi.extensibility.visual {
return dataPoint.y;
});

let minValue: number = this.radarChartData.settings.minValue;
let minValue: number = this.radarChartData.settings.displaySettings.minValue;

if (this.isPercentChart(dataPointsList)) {
minValue = minValue >= RadarChart.MinDomainValue
Expand Down Expand Up @@ -1135,6 +1144,22 @@ module powerbi.extensibility.visual {

private static parseSettings(dataView: DataView, colorPalette: IColorPalette): RadarChartSettings {
let settings: RadarChartSettings = RadarChartSettings.parse<RadarChartSettings>(dataView);
if (dataView && dataView.categorical) {
if (dataView.categorical.categories[0].values.length <= 2) {
settings.displaySettings.minValue = 0;
} else {
let minValue = d3.min(<number[]>dataView.categorical.values[0].values);
for (let i: number = 0; i < dataView.categorical.values.length; i++) {
let minValueL = d3.min(<number[]>dataView.categorical.values[i].values);
if (minValue > minValueL) {
minValue = minValueL;
}
}
if (settings.displaySettings.minValue > minValue) {
settings.displaySettings.minValue = minValue;
}
}
}
return settings;
}

Expand Down
1 change: 1 addition & 0 deletions src/radarChartDataInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module powerbi.extensibility.visual {
labelFormatString?: string;
labelFontSize?: string;
highlight?: boolean;
showPoint: boolean;
}

export interface RadarChartAxesLabel {
Expand Down
1 change: 0 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module powerbi.extensibility.visual {
import LegendPosition = powerbi.extensibility.utils.chart.legend.LegendPosition;

export class RadarChartSettings extends DataViewObjectsParser {
public minValue: number = 0;
public legend: LegendSettings = new LegendSettings();
public labels: LabelSettings = new LabelSettings();
public dataPoint: DataPointSettings = new DataPointSettings();
Expand Down
4 changes: 2 additions & 2 deletions test/visualData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ module powerbi.extensibility.visual.test {
public valuesY1: number[] = [742731.43, 162066.43, 283085.78, 300263.49, 376074.57, 814724.34, 570921.34, 742731.43, 162066.43, 283085.78, 300263.49, 376074.57, 814724.34, 570921.34, 742731.43, 162066.43, 283085.78, 300263.49, 376074.57, 814724.34, 570921.34, 742731.43, 162066.43, 283085.78, 300263.49, 376074.57, 814724.34, 570921.34];
public valuesY2: number[] = [123455.43, 40566.43, 200457.78, 5000.49, 320000.57, 450000.34, 140832.67, 123455.43, 40566.43, 200457.78, 5000.49, 320000.57, 450000.34, 140832.67, 123455.43, 40566.43, 200457.78, 5000.49, 320000.57, 450000.34, 140832.67, 123455.43, 40566.43, 200457.78, 5000.49, 320000.57, 450000.34, 140832.67];

public getDataView(columnNames?: string[]): powerbi.DataView {
public getDataView(columnNames?: string[], valuesCategory?: string[] ): powerbi.DataView {
return this.createCategoricalDataViewBuilder([
{
source: {
displayName: "Day",
queryName: RadarChartData.ColumnCategory,
type: ValueType.fromDescriptor({ text: true })
},
values: this.valuesCategory
values: valuesCategory ? valuesCategory : this.valuesCategory
}
], [
{
Expand Down
28 changes: 28 additions & 0 deletions test/visualTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,34 @@ module powerbi.extensibility.visual.test {
});
});

describe("Display settings", () => {
let dataViewTemp: DataView;
beforeEach(() => {
dataViewTemp = defaultDataViewBuilder.getDataView(null, ["Monday"]);
dataViewTemp.metadata.objects = {
line: {
show: true
}
};
});
it("check and update func", () => {
expect(() => {
VisualClass.checkAndUpdateAxis(dataViewTemp, dataViewTemp.categorical.values);
}).not.toThrow();
});

it("is intersect 1", () => {
let retValue = VisualClass.isIntersect(11, 16, 13, 14);
expect(retValue).toBe(true);
});

it("is intersect 2", () => {
let retValue = VisualClass.isIntersect(100, 10, 4, 2);
expect(retValue).toBe(false);
});

});

describe("Draw lines", () => {
beforeEach(() => {
dataView.metadata.objects = {
Expand Down

0 comments on commit 86ca52e

Please sign in to comment.