in packages/tablesorter-powerbi/src/TableSorterVisual.ts [512:548]
private cellFormatter(selection: d3.Selection<ICellFormatterObject>) {
const getColumnColor = (d: ICellFormatterObject) => {
if (this._data && this._data.rankingInfo) {
const { values, column, colors: rankColors } = this._data.rankingInfo;
const cellColName = d.column && d.column.column && d.column.column.column;
const rankColName = column.displayName;
// If this is the column we are ranking, then color it
return cellColName === rankColName ? rankColors[d.row[rankColName]] : undefined;
}
};
const rankHistogram = this.visualSettings.rankSettings.histogram;
const isConfidence = (d: ICellFormatterObject) => {
// Path: Object -> Layout Column -> Lineup Column -> Config
const config = get(d, v => v.column.column.config, {});
return config.isConfidence;
};
selection
.style({
"background": (d) => {
return rankHistogram && isConfidence(d) && d.label > 1 ?
vendorPrefix + `linear-gradient(bottom, rgba(0,0,0,.2) ${d.label}%, rgba(0,0,0,0) ${d.label}%)` :
getColumnColor(d);
},
"width": (d) => `${d["width"] + (rankHistogram && isConfidence(d) ? 2 : 0)}px`,
"margin-left": (d) => rankHistogram && isConfidence(d) ? `-1px` : undefined,
"color": (d) => {
if (this.visualSettings.presentation.textColor) {
return this.visualSettings.presentation.textColor;
}
const color = getColumnColor(d) || "#ffffff";
const d3Color = d3.hcl(color);
return d3Color.l <= 60 ? "#ececec" : "#333333";
},
})
.text((d) => isConfidence(d) && (d.label + "") === "0" ? " - " : d.label);
}