Skip to content

Commit

Permalink
Table: separate scaling for NHS icons, resize cells with icon (#323)
Browse files Browse the repository at this point in the history
* Table: separate scaling for NHS icons, resize cells with icon

* Stray logging
  • Loading branch information
andrjohns authored Aug 20, 2024
1 parent 82bbed8 commit 504abec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
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":"SPC Charts",
"guid":"PBISPC",
"visualClassName":"Visual",
"version":"1.4.4.4",
"version":"1.4.4.5",
"description":"A PowerBI custom visual for SPC charts",
"supportUrl":"https://github.com/AUS-DOH-Safety-and-Quality/PowerBI-SPC",
"gitHubUrl":"https://github.com/AUS-DOH-Safety-and-Quality/PowerBI-SPC"
Expand Down
14 changes: 5 additions & 9 deletions src/D3 Plotting Functions/drawSummaryTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,22 @@ function drawTableCells(selection: divBaseType, cols: { name: string; label: str

const draw_icons: boolean = inputSettings.nhs_icons.show_variation_icons || inputSettings.nhs_icons.show_assurance_icons;
const thisSelDims = (tableCells.node() as SVGGElement).getBoundingClientRect()
const scaling = inputSettings.nhs_icons.variation_icons_scaling

const icon_x: number = (thisSelDims.width * 0.8) / 0.08 / 2 - 189;
const icon_y: number = (thisSelDims.height * 0.8) / 0.08 / 2 - 189;

tableCells.each(function(d) {
const currNode = d3.select(this);
const parentNode = d3.select(currNode.property("parentNode"));
const rowData = parentNode.datum() as plotData;
if (showGrouped && draw_icons && (d.column === "variation" || d.column === "assurance")) {
const scaling = d.column === "variation" ? inputSettings.nhs_icons.variation_icons_scaling
: inputSettings.nhs_icons.assurance_icons_scaling;
currNode
.append("svg")
.attr("width", thisSelDims.width * 0.8)
.attr("height", thisSelDims.height * 0.8)
.attr("width", `${thisSelDims.width * 0.5 * scaling}px`)
.attr("viewBox", `0 0 ${378} ${378}`)
.classed("rowsvg", true)
.call(initialiseIconSVG, d.value)
.selectAll(".icongroup")
.attr("viewBox", "0 0 378 378")
.selectAll(`.${d.value}`)
.attr("transform", `scale(${0.08 * scaling}) translate(${icon_x}, ${icon_y})`)
.call(nhsIcons[d.value]);
} else {
const value: string = typeof d.value === "number"
Expand Down Expand Up @@ -188,7 +184,7 @@ function drawTableCells(selection: divBaseType, cols: { name: string; label: str
}

export default function drawSummaryTable(selection: divBaseType, visualObj: Visual) {
selection.selectAll(".iconrow").remove();
selection.selectAll(".rowsvg").remove();
selection.selectAll(".cell-text").remove();

let plotPoints: plotData[] | plotDataGrouped[];
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/identitySelected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type ISelectionId = powerbi.visuals.ISelectionId;
export default function identitySelected(identity: ISelectionId | ISelectionId[], selectionManager: powerbi.extensibility.ISelectionManager): boolean {
const allSelectedIdentities = selectionManager.getSelectionIds() as ISelectionId[];
if (Array.isArray(identity)) {
return identity.every((d) => allSelectedIdentities.some((e) => e.includes(d)));
return identity.some((d) => allSelectedIdentities.some((e) => e.includes(d)));
} else {
return allSelectedIdentities.some((d) => d.includes(identity));
}
Expand Down
4 changes: 1 addition & 3 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export class Visual implements powerbi.extensibility.IVisual {
this.viewModel = new viewModelClass();

this.selectionManager = this.host.createSelectionManager();
this.selectionManager.registerOnSelectCallback(() => {
this.updateHighlighting();
});
this.selectionManager.registerOnSelectCallback(() => this.updateHighlighting());

this.svg.call(initialiseSVG);
const table = this.tableDiv.append("table")
Expand Down

0 comments on commit 504abec

Please sign in to comment.