Skip to content

Commit

Permalink
Remove displayAll from labels
Browse files Browse the repository at this point in the history
  • Loading branch information
adiletelf committed Jul 31, 2024
1 parent 4dbb131 commit a76b6c7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
5 changes: 0 additions & 5 deletions capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,6 @@
"bool": true
}
},
"displayAll": {
"type": {
"bool": true
}
},
"displayYears": {
"type": {
"bool": true
Expand Down
42 changes: 36 additions & 6 deletions src/timeLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
const labelSize: number = pixelConverter.fromPointToPixel(this.visualSettings.labels.textSize.value);

if (this.visualSettings.labels.show.value) {
const granularityOffset: number = this.visualSettings.labels.displayAll.value ? granularityType + 1 : 1;
const granularityOffset: number = this.visualSettings.labels.show.value ? granularityType + 1 : 1;

this.timelineProperties.cellsYPosition += labelSize
* Timeline.LabelSizeFactor
Expand Down Expand Up @@ -1090,6 +1090,36 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
this.visualSettings.calendar.disabled = true;
}

const granularity = this.getGranularityType();

switch (granularity) {
case GranularityType.year:
this.visualSettings.labels.displayQuarters.visible = false;
this.visualSettings.labels.displayMonths.visible = false;
this.visualSettings.labels.displayWeeks.visible = false;
this.visualSettings.labels.displayDays.visible = false;
break;
case GranularityType.quarter:
this.visualSettings.labels.displayMonths.visible = false;
this.visualSettings.labels.displayWeeks.visible = false;
this.visualSettings.labels.displayDays.visible = false;
break;
case GranularityType.month:
this.visualSettings.labels.displayWeeks.visible = false;
this.visualSettings.labels.displayDays.visible = false;
break;
case GranularityType.week:
this.visualSettings.labels.displayDays.visible = false;
break;
default:
this.visualSettings.labels.displayMonths.visible = true;
this.visualSettings.labels.displayQuarters.visible = true;
this.visualSettings.labels.displayMonths.visible = true;
this.visualSettings.labels.displayWeeks.visible = true;
this.visualSettings.labels.displayDays.visible = true;
break;
}

return this.formattingSettingsService.buildFormattingModel(this.visualSettings);
}

Expand Down Expand Up @@ -1447,7 +1477,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
let yPos: number = 0;

if (settings.labels.show.value) {
if ((settings.labels.displayAll.value && settings.labels.displayYears.value) || granularityType === GranularityType.year) {
if (settings.labels.displayYears.value || granularityType === GranularityType.year) {
this.renderLabels(
extendedLabels.yearLabels,
this.yearLabelsSelection,
Expand All @@ -1458,7 +1488,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
}
}

if ((settings.labels.displayAll.value && settings.labels.displayQuarters.value) || granularityType === GranularityType.quarter) {
if (settings.labels.displayQuarters.value || granularityType === GranularityType.quarter) {
this.renderLabels(
extendedLabels.quarterLabels,
this.quarterLabelsSelection,
Expand All @@ -1469,7 +1499,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
}
}

if ((settings.labels.displayAll.value && settings.labels.displayMonths.value) || granularityType === GranularityType.month) {
if (settings.labels.displayMonths.value || granularityType === GranularityType.month) {
this.renderLabels(
extendedLabels.monthLabels,
this.monthLabelsSelection,
Expand All @@ -1480,7 +1510,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
}
}

if ((settings.labels.displayAll.value && settings.labels.displayWeeks.value) || granularityType === GranularityType.week) {
if (settings.labels.displayWeeks.value || granularityType === GranularityType.week) {
this.renderLabels(
extendedLabels.weekLabels,
this.weekLabelsSelection,
Expand All @@ -1491,7 +1521,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
}
}

if ((settings.labels.displayAll.value && settings.labels.displayDays.value) || granularityType === GranularityType.day) {
if (settings.labels.displayDays.value || granularityType === GranularityType.day) {
this.renderLabels(
extendedLabels.dayLabels,
this.dayLabelsSelection,
Expand Down
8 changes: 0 additions & 8 deletions src/timeLineSettingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,6 @@ export class LabelsSettingsCard extends Card {
value: true,
});

displayAll = new formattingSettings.ToggleSwitch({
name: "displayAll",
displayName: "Display all",
displayNameKey: "Visual_DisplayAll",
value: true,
});

displayYears = new formattingSettings.ToggleSwitch({
name: "displayYears",
displayName: "Display years",
Expand Down Expand Up @@ -455,7 +448,6 @@ export class LabelsSettingsCard extends Card {
displayName: string = "Labels";
displayNameKey: string = "Visual_Labels";
slices = [
this.displayAll,
this.displayYears,
this.displayQuarters,
this.displayMonths,
Expand Down

0 comments on commit a76b6c7

Please sign in to comment.