Skip to content

Commit

Permalink
Fix error with rendering when ItemDropDown values are undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
adiletelf committed Jan 25, 2024
1 parent 0a494e7 commit 0bc0e4e
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/timeLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,22 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
}];
}

const weekStandardFormat: WeekStandard = WeekStandard[timelineSettings.weeksDeterminationStandards.weekStandard.value.value];
const weekStandardFormat: WeekStandard = timelineSettings.weeksDeterminationStandards.weekStandard.value
? WeekStandard[timelineSettings.weeksDeterminationStandards.weekStandard.value.value]
: WeekStandard.NotSet;

const calendarFormat: CalendarFormat = {
month: Month[timelineSettings.fiscalYearCalendar.month.value.value],
month: timelineSettings.fiscalYearCalendar.month.value
? Month[timelineSettings.fiscalYearCalendar.month.value.value]
: Month.January,
day: timelineSettings.fiscalYearCalendar.day.value,
}

const weekDayFormat: WeekDayFormat = {
daySelection: timelineSettings.weekDay.daySelection.value,
day: timelineSettings.weekDay.day.value ? Day[timelineSettings.weekDay.day.value.value] : Day.Sunday,
day: timelineSettings.weekDay.day.value
? Day[timelineSettings.weekDay.day.value.value]
: Day.Sunday,
}

const isCalendarChanged: boolean = previousCalendar
Expand Down Expand Up @@ -507,7 +513,9 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
colorPalette: powerbiVisualsApi.extensibility.ISandboxExtendedColorPalette,
): void {
const calendarFormat: CalendarFormat = {
month: Month[settings.fiscalYearCalendar.month.value.value],
month: settings.fiscalYearCalendar.month.value
? Month[settings.fiscalYearCalendar.month.value.value]
: Month.January,
day: settings.fiscalYearCalendar.day.value,
}

Expand Down Expand Up @@ -708,6 +716,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual

public update(options: powerbiVisualsApi.extensibility.visual.VisualUpdateOptions): void {
try {
debugger;

Check failure on line 719 in src/timeLine.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected 'debugger' statement
this.host.eventService.renderingStarted(options);

if (!Timeline.ARE_VISUAL_UPDATE_OPTIONS_VALID(options)) {
Expand Down Expand Up @@ -797,7 +806,9 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
}

if (adjustedPeriod.period.startDate && adjustedPeriod.period.endDate) {
const granularityType = GranularityType[this.formattingSettings.granularity.granularity.value.value];
const granularityType = this.formattingSettings.granularity.granularity.value
? GranularityType[this.formattingSettings.granularity.granularity.value.value]
: GranularityType.month;
this.changeGranularity(granularityType, adjustedPeriod.period.startDate, adjustedPeriod.period.endDate);
this.updateCalendar(this.formattingSettings, oldEnableManualSizing, newEnableManualSizing);
}
Expand Down Expand Up @@ -1290,16 +1301,22 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
localizationManager: powerbiVisualsApi.extensibility.ILocalizationManager,
) {

const weekStandardFormat: WeekStandard = WeekStandard[formattingSettings.weeksDeterminationStandards.weekStandard.value.value];
const weekStandardFormat: WeekStandard = formattingSettings.weeksDeterminationStandards.weekStandard.value
? WeekStandard[formattingSettings.weeksDeterminationStandards.weekStandard.value.value]
: WeekStandard.NotSet;

const calendarFormat: CalendarFormat = {
month: Month[formattingSettings.fiscalYearCalendar.month.value.value],
month: formattingSettings.fiscalYearCalendar.month.value
? Month[formattingSettings.fiscalYearCalendar.month.value.value]
: Month.January,
day: formattingSettings.fiscalYearCalendar.day.value,
}

const weekDayFormat: WeekDayFormat = {
daySelection: formattingSettings.weekDay.daySelection.value,
day: formattingSettings.weekDay.day.value ? Day[formattingSettings.weekDay.day.value.value] : Day.Sunday,
day: formattingSettings.weekDay.day.value
? Day[formattingSettings.weekDay.day.value.value]
: Day.Sunday,
}

const calendar: Calendar = this.calendarFactory.create(weekStandardFormat, calendarFormat, weekDayFormat);
Expand All @@ -1324,7 +1341,9 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual
actualEndDate.getTime() !== prevEndDate.getTime();

if (!changedSelection) {
const granularityType = GranularityType[formattingSettings.granularity.granularity.value.value];
const granularityType = formattingSettings.granularity.granularity.value
? GranularityType[formattingSettings.granularity.granularity.value.value]
: GranularityType.month;
this.changeGranularity(
granularityType,
startDate,
Expand Down

0 comments on commit 0bc0e4e

Please sign in to comment.