Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gradient issue #113

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

## 3.0.5.0
* Fix bug with empty columns gradient when legend is disabled

## 3.0.4.0
* Use selectionManager instead of interactivity utils
* Add interactivity to legend
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-tornadochart",
"version": "3.0.4.0",
"version": "3.0.5.0",
"author": {
"name": "Microsoft",
"email": "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions pbiviz.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"visual": {
"name": "TornadoChart",
"displayName": "Tornado 3.0.4.0",
"displayName": "Tornado 3.0.5.0",
"guid": "TornadoChart1452517688218",
"visualClassName": "TornadoChart",
"version": "3.0.4.0",
"version": "3.0.5.0",
"description": "A bar chart with category values listed vertically. Use for comparing the relative importance of a variable between two distinct groups.",
"supportUrl": "https://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/PowerBI-visuals-Tornado"
Expand Down
30 changes: 16 additions & 14 deletions src/TornadoChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,50 +1029,52 @@ export class TornadoChart implements IVisual {
}

private renderLegend(): void {
const formattingSettings: TornadoChartSettingsModel = this.formattingSettings;
if (formattingSettings.legendCardSettings.show.value) {
const legendSettings: LegendCardSettings = this.formattingSettings.legendCardSettings;
if (legendSettings.show.value) {

const legend: LegendData = this.dataView.legend;
if (!legend) {
return;
}

const legendLabelsColor: string = formattingSettings.legendCardSettings.labelColor.value.value;
const legendLabelsColor: string = legendSettings.labelColor.value.value;
const legendData: LegendData = {
title: legend.title,
dataPoints: legend.dataPoints,
fontSize: formattingSettings.legendCardSettings.font.fontSize.value,
fontFamily: formattingSettings.legendCardSettings.font.fontFamily.value,
fontSize: legendSettings.font.fontSize.value,
fontFamily: legendSettings.font.fontFamily.value,
labelColor: this.colorHelper.isHighContrast ? this.colorHelper.getHighContrastColor("foreground", legendLabelsColor) : legendLabelsColor
};

if (this.dataView.legendObjectProperties) {
LegendDataModule.update(legendData, this.dataView.legendObjectProperties);

const position = this.formattingSettings.legendCardSettings.positionDropdown.value.value;
const position = legendSettings.positionDropdown.value.value;

if (position) {
this.legend.changeOrientation(LegendPosition[position]);
}
}

this.legend.drawLegend(legendData, { ...this.viewport });
this.legendItems = this.legendSelection.selectAll(TornadoChart.LegendItemSelector.selectorName);

this.legendSelection.selectAll("text")
.style("font-weight", () => this.formattingSettings.legendCardSettings.font.bold.value ? "bold" : "normal")
.style("font-style", () => this.formattingSettings.legendCardSettings.font.italic.value ? "italic" : "normal")
.style("text-decoration", () => this.formattingSettings.legendCardSettings.font.underline.value ? "underline" : "none");

if (legendData.dataPoints.length > 0 && formattingSettings.legendCardSettings.show.value) {
if (legendData.dataPoints.length > 0 && legendSettings.show.value) {
this.updateViewport();
}
}
else {
this.legend.reset();
this.legend.drawLegend({ dataPoints: [] }, this.viewport);
}
TornadoChart.SetPositionsDependingOnLegend(this.rootContainer, formattingSettings.legendCardSettings, this.legend);

this.legendItems = this.legendSelection.selectAll(TornadoChart.LegendItemSelector.selectorName);

this.legendSelection.selectAll("text")
.style("font-weight", () => legendSettings.font.bold.value ? "bold" : "normal")
.style("font-style", () => legendSettings.font.italic.value ? "italic" : "normal")
.style("text-decoration", () => legendSettings.font.underline.value ? "underline" : "none");

TornadoChart.SetPositionsDependingOnLegend(this.rootContainer, legendSettings, this.legend);
}

public static SetPositionsDependingOnLegend(chartArea: HTMLElement, legendSettings: LegendCardSettings, legend: ILegend): void{
Expand Down
Loading