in src/visual.ts [1084:1124]
private renderLegend(): void {
const legendsData: ILegend[] = Visual.getLegendsData(
this.data.settings,
this.viewport,
this.viewportIn,
this.localizationManager
);
let legendSelection: Selection<ILegend> = this.legendSelection.data(legendsData);
let updateLegendSelection = legendSelection
.enter()
.append("svg:text");
legendSelection
.merge(updateLegendSelection)
.attr("x", Default.SvgLegendPosition)
.attr("y", Default.SvgLegendPosition)
.attr("dx", (legend: ILegend) => legend.dx)
.attr("dy", (legend: ILegend) => legend.dy)
.attr("transform", (legend: ILegend) => legend.transform)
.style("fill", (legend: ILegend) => legend.color)
.text((item: ILegend) => item.text)
.classed(Visual.Legend.className, true);
legendSelection
.exit()
.remove();
const getDisplayForAxisTitle = (axisSettings: HistogramAxisSettings): string =>
(axisSettings && axisSettings.title) ? null : "none";
this.legend
.select("text")
.style("display", getDisplayForAxisTitle(this.data.settings.xAxis));
this.legend
.selectAll("text")
.filter((d, index: number) => index === 1)
.style("display", getDisplayForAxisTitle(this.data.settings.yAxis));
}