diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d4268c8..79e2102 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,8 +29,7 @@ jobs: - run: npm ci - run: npm outdated continue-on-error: true - - run: npm run eslint --if-present - - run: npm run lint --if-present + - run: npm run eslint - run: npm run package - run: npm test env: diff --git a/package-lock.json b/package-lock.json index 597d5bf..75ba11e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "2.5.0.0", "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "^6.19.0", - "@typescript-eslint/parser": "^6.19.0", + "@typescript-eslint/eslint-plugin": "^6.19.1", + "@typescript-eslint/parser": "^6.19.1", "d3-array": "^3.2.4", "d3-drag": "^3.0.0", "d3-selection": "^3.0.0", @@ -40,10 +40,10 @@ "karma-sourcemap-loader": "^0.4.0", "karma-webpack": "^5.0.0", "less": "^4.2.0", - "less-loader": "^12.0.0", - "playwright-chromium": "^1.41.0", + "less-loader": "^12.1.0", + "playwright-chromium": "^1.41.1", "powerbi-visuals-api": "~5.7.0", - "powerbi-visuals-tools": "^5.4.0", + "powerbi-visuals-tools": "^5.4.1", "powerbi-visuals-utils-testutils": "^6.0.3", "style-loader": "^3.3.4", "ts-loader": "^9.5.1", @@ -592,15 +592,15 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.0.tgz", - "integrity": "sha512-DUCUkQNklCQYnrBSSikjVChdc84/vMPDQSgJTHBZ64G9bA9w0Crc0rd2diujKbTdp6w2J47qkeHQLoi0rpLCdg==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz", + "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.19.0", - "@typescript-eslint/type-utils": "6.19.0", - "@typescript-eslint/utils": "6.19.0", - "@typescript-eslint/visitor-keys": "6.19.0", + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/type-utils": "6.19.1", + "@typescript-eslint/utils": "6.19.1", + "@typescript-eslint/visitor-keys": "6.19.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -626,14 +626,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.0.tgz", - "integrity": "sha512-1DyBLG5SH7PYCd00QlroiW60YJ4rWMuUGa/JBV0iZuqi4l4IK3twKPq5ZkEebmGqRjXWVgsUzfd3+nZveewgow==", - "dependencies": { - "@typescript-eslint/scope-manager": "6.19.0", - "@typescript-eslint/types": "6.19.0", - "@typescript-eslint/typescript-estree": "6.19.0", - "@typescript-eslint/visitor-keys": "6.19.0", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", + "integrity": "sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==", + "dependencies": { + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/typescript-estree": "6.19.1", + "@typescript-eslint/visitor-keys": "6.19.1", "debug": "^4.3.4" }, "engines": { @@ -653,12 +653,12 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.0.tgz", - "integrity": "sha512-dO1XMhV2ehBI6QN8Ufi7I10wmUovmLU0Oru3n5LVlM2JuzB4M+dVphCPLkVpKvGij2j/pHBWuJ9piuXx+BhzxQ==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz", + "integrity": "sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==", "dependencies": { - "@typescript-eslint/types": "6.19.0", - "@typescript-eslint/visitor-keys": "6.19.0" + "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/visitor-keys": "6.19.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -669,12 +669,12 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.0.tgz", - "integrity": "sha512-mcvS6WSWbjiSxKCwBcXtOM5pRkPQ6kcDds/juxcy/727IQr3xMEcwr/YLHW2A2+Fp5ql6khjbKBzOyjuPqGi/w==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", + "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", "dependencies": { - "@typescript-eslint/typescript-estree": "6.19.0", - "@typescript-eslint/utils": "6.19.0", + "@typescript-eslint/typescript-estree": "6.19.1", + "@typescript-eslint/utils": "6.19.1", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -695,9 +695,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.0.tgz", - "integrity": "sha512-lFviGV/vYhOy3m8BJ/nAKoAyNhInTdXpftonhWle66XHAtT1ouBlkjL496b5H5hb8dWXHwtypTqgtb/DEa+j5A==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", + "integrity": "sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg==", "engines": { "node": "^16.0.0 || >=18.0.0" }, @@ -707,12 +707,12 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.0.tgz", - "integrity": "sha512-o/zefXIbbLBZ8YJ51NlkSAt2BamrK6XOmuxSR3hynMIzzyMY33KuJ9vuMdFSXW+H0tVvdF9qBPTHA91HDb4BIQ==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz", + "integrity": "sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==", "dependencies": { - "@typescript-eslint/types": "6.19.0", - "@typescript-eslint/visitor-keys": "6.19.0", + "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/visitor-keys": "6.19.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -756,16 +756,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.0.tgz", - "integrity": "sha512-QR41YXySiuN++/dC9UArYOg4X86OAYP83OWTewpVx5ct1IZhjjgTLocj7QNxGhWoTqknsgpl7L+hGygCO+sdYw==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", + "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.19.0", - "@typescript-eslint/types": "6.19.0", - "@typescript-eslint/typescript-estree": "6.19.0", + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/typescript-estree": "6.19.1", "semver": "^7.5.4" }, "engines": { @@ -780,11 +780,11 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.0.tgz", - "integrity": "sha512-hZaUCORLgubBvtGpp1JEFEazcuEdfxta9j4iUwdSAr7mEsYYAp3EAUyCZk3VEEqGj6W+AV4uWyrDGtrlawAsgQ==", + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", + "integrity": "sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==", "dependencies": { - "@typescript-eslint/types": "6.19.0", + "@typescript-eslint/types": "6.19.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -4380,9 +4380,9 @@ } }, "node_modules/less-loader": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-12.0.0.tgz", - "integrity": "sha512-fcRoWK28+eD+1PxuwNG+44V2v32IBdzsYAi0keUncHVblbpxMPWwrGlnw0wZKCdOg7O0HNwfhWNw/DrRZ45xCA==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-12.1.0.tgz", + "integrity": "sha512-N/MRZA9iILOW+TQ9xoDptsSPbtBJDWshOj3LNqL+UJAYDhtoraLECiBa93DeLJUfR4m/VE6bWuxaVs40+wBXYw==", "dev": true, "engines": { "node": ">= 18.12.0" @@ -5302,13 +5302,13 @@ } }, "node_modules/playwright-chromium": { - "version": "1.41.0", - "resolved": "https://registry.npmjs.org/playwright-chromium/-/playwright-chromium-1.41.0.tgz", - "integrity": "sha512-8mg2Yqp4LUSQgAqoP0PA7rhVc8glazce4TLyyRCgydfcebO1ur9AMWUSAoalJtisciXuldsQuNfTGggC7eu7ig==", + "version": "1.41.1", + "resolved": "https://registry.npmjs.org/playwright-chromium/-/playwright-chromium-1.41.1.tgz", + "integrity": "sha512-Nr1/rnmRB4QzoAQwCors1Qsa9PLSdipsKiI4FZCQjSDzoBVBzoQqfXGtcIEnoAXEEEpzxuCPqjJNQwCVA66tCw==", "dev": true, "hasInstallScript": true, "dependencies": { - "playwright-core": "1.41.0" + "playwright-core": "1.41.1" }, "bin": { "playwright": "cli.js" @@ -5318,9 +5318,9 @@ } }, "node_modules/playwright-core": { - "version": "1.41.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.0.tgz", - "integrity": "sha512-UGKASUhXmvqm2Lxa1fNr8sFwAtqjpgBRr9jQ7XBI8Rn5uFiEowGUGwrruUQsVPIom4bk7Lt+oLGpXobnXzrBIw==", + "version": "1.41.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.1.tgz", + "integrity": "sha512-/KPO5DzXSMlxSX77wy+HihKGOunh3hqndhqeo/nMxfigiKzogn8kfL0ZBDu0L1RKgan5XHCPmn6zXd2NUJgjhg==", "dev": true, "bin": { "playwright-core": "cli.js" @@ -5449,9 +5449,9 @@ } }, "node_modules/powerbi-visuals-tools": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/powerbi-visuals-tools/-/powerbi-visuals-tools-5.4.0.tgz", - "integrity": "sha512-X0DTH7qqrwHZ92O/yfEFfi3x6vKzNSag8Z1a3DkZ/5lk+vZu+rzdlpU3Tpnbt3k+gs8plpTVVGVh2sXv7pu/gA==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/powerbi-visuals-tools/-/powerbi-visuals-tools-5.4.1.tgz", + "integrity": "sha512-hUaift3mKeamcnt7vKBjZqo5a4O7Q1uE9OSFaP1px/9PfITNaovSwqRjy2UiCoJaNy/FI0wjxBSfYTeb2TrYeQ==", "dev": true, "dependencies": { "@typescript-eslint/parser": "^6.17.0", diff --git a/package.json b/package.json index 12e3fb0..8965b40 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,10 @@ "karma-sourcemap-loader": "^0.4.0", "karma-webpack": "^5.0.0", "less": "^4.2.0", - "less-loader": "^12.0.0", - "playwright-chromium": "^1.41.0", + "less-loader": "^12.1.0", + "playwright-chromium": "^1.41.1", "powerbi-visuals-api": "~5.7.0", - "powerbi-visuals-tools": "^5.4.0", + "powerbi-visuals-tools": "^5.4.1", "powerbi-visuals-utils-testutils": "^6.0.3", "style-loader": "^3.3.4", "ts-loader": "^9.5.1", @@ -53,8 +53,8 @@ "webpack": "^5.89.0" }, "dependencies": { - "@typescript-eslint/eslint-plugin": "^6.19.0", - "@typescript-eslint/parser": "^6.19.0", + "@typescript-eslint/eslint-plugin": "^6.19.1", + "@typescript-eslint/parser": "^6.19.1", "d3-array": "^3.2.4", "d3-drag": "^3.0.0", "d3-selection": "^3.0.0", diff --git a/src/granularity/granularityBase.ts b/src/granularity/granularityBase.ts index 8046711..292ea92 100644 --- a/src/granularity/granularityBase.ts +++ b/src/granularity/granularityBase.ts @@ -44,7 +44,6 @@ import { IExtendedLabel, ITimelineLabel, } from "../dataInterfaces"; -import {GranularitySettingsCard} from "../timeLineSettingsModel"; import {GranularityType} from "./granularityType"; export class GranularityBase implements IGranularity { @@ -118,11 +117,16 @@ export class GranularityBase implements IGranularity { .attr("y", pixelConverter.toString(0 - this.textLabelYOffset)) .attr("dx", this.textLabelDx); + const propsGranularity: GranularityType = props.granularSettings.granularity.value + ? GranularityType[props.granularSettings.granularity.value.value] + : GranularityType.month; + // render slider - if (GranularityType[props.granularSettings.granularity.value.value] === this.granularityProps.granularityType) { + if (propsGranularity === this.granularityProps.granularityType) { this.renderSlider( granularitySelection, - props.granularSettings, + props.granularSettings.sliderColor.value.value, + propsGranularity ); } @@ -149,7 +153,9 @@ export class GranularityBase implements IGranularity { this.renderSlider( granularitySelection, - props.granularSettings, + // props.granularSettings, + props.granularSettings.sliderColor.value.value, + propsGranularity ); }); @@ -293,17 +299,18 @@ export class GranularityBase implements IGranularity { private renderSlider( selection: Selection, - granularSettings: GranularitySettingsCard, + sliderColor: string, + granularity: GranularityType, ): void { selection .append("rect") .classed("periodSlicerRect", true) - .style("stroke", granularSettings.sliderColor.value.value) + .style("stroke", sliderColor) .attr("x", pixelConverter.toString(0 - this.sliderXOffset)) .attr("y", pixelConverter.toString(0 - this.sliderYOffset)) .attr("rx", pixelConverter.toString(this.sliderRx)) .attr("width", pixelConverter.toString(this.sliderWidth)) .attr("height", pixelConverter.toString(this.sliderHeight)) - .data([GranularityType[granularSettings.granularity.value.value]]); + .data([granularity]); } } diff --git a/src/timeLine.ts b/src/timeLine.ts index 8f2b38e..77bd590 100644 --- a/src/timeLine.ts +++ b/src/timeLine.ts @@ -78,7 +78,6 @@ import { } from "./timeLineSettingsModel"; import {Day} from "./calendars/day"; import {Month} from "./calendars/month"; - import ISelectionManager = powerbiVisualsApi.extensibility.ISelectionManager; import extractFilterColumnTarget = interactivityFilterService.extractFilterColumnTarget; @@ -161,7 +160,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual const weekDayFormat: WeekDayFormat = { daySelection: timelineSettings.weekDay.daySelection.value, - day: Day[timelineSettings.weekDay.day.value.value], + day: timelineSettings.weekDay.day.value ? Day[timelineSettings.weekDay.day.value.value] : Day.Sunday, } const isCalendarChanged: boolean = previousCalendar @@ -175,7 +174,10 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual if (!initialized || isCalendarChanged) { calendar = new CalendarFactory().create(weekStandardFormat, calendarFormat, weekDayFormat); timelineData.currentGranularity = timelineGranularityData.getGranularity( - GranularityType[timelineSettings.granularity.granularity.value.value]); + timelineSettings.granularity.granularity.value + ? GranularityType[timelineSettings.granularity.granularity.value.value] + : GranularityType.month, + ); } else { calendar = previousCalendar; @@ -756,7 +758,10 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual const adjustedPeriod: IAdjustedFilterDatePeriod = this.adjustFilterDatePeriod(); const datePeriod: ITimelineDatePeriodBase = this.datePeriod; - const granularity: GranularityType = GranularityType[this.formattingSettings.granularity.granularity.value.value]; + const granularity: GranularityType = this.formattingSettings.granularity.granularity.value + ? GranularityType[this.formattingSettings.granularity.granularity.value.value] + : GranularityType.month; + const isCurrentPeriodSelected: boolean = !this.isForceSelectionReset && this.formattingSettings.forceSelection.currentPeriod.value; const isLatestAvailableDateSelected: boolean = !this.isForceSelectionReset && this.formattingSettings.forceSelection.latestAvailableDate.value; const isForceSelected: boolean = !this.isForceSelectionReset && (isCurrentPeriodSelected || isLatestAvailableDateSelected); @@ -1294,7 +1299,7 @@ export class Timeline implements powerbiVisualsApi.extensibility.visual.IVisual const weekDayFormat: WeekDayFormat = { daySelection: formattingSettings.weekDay.daySelection.value, - day: Day[formattingSettings.weekDay.day.value.value], + day: formattingSettings.weekDay.day.value ? Day[formattingSettings.weekDay.day.value.value] : Day.Sunday, } const calendar: Calendar = this.calendarFactory.create(weekStandardFormat, calendarFormat, weekDayFormat); diff --git a/stringResources/en-US/resources.resjson b/stringResources/en-US/resources.resjson index 4121a72..71778dd 100644 --- a/stringResources/en-US/resources.resjson +++ b/stringResources/en-US/resources.resjson @@ -1,6 +1,8 @@ { "Role_Time": "Time", "Visual_General": "General", + "Visual_Short_Description": "Graphical date range selector to use for filtering dates", + "Visual_Long_Description": "The Timeline slicer is a graphical date range selector used as a filtering component in Power BI. This makes filtering data by date dimension easy and fun.\nHow often do you have to filter your data for a date range or at higher level such as month or quarter? Every single time. Right? Filtering is pain when you have to click through large numbers of date values to select the range you want. Changing the filter granularity from months, the quarters and years on the fly is super tedious. Well, it used to be super tedious.\nThe Timeline slicer is going to make this experience a breeze. With this simple slider control for dates, all you need to do, is just click and drag to the range that you want. You can also switch to a Year, Quarter or Month view to select ranges even at a higher level than dates.\nYou can simply click on the slicer to select a single value or click the edge and drag it to the range that you want.\nYou can also change the background & selection color and number of other formatting options to control the look-n-feel. SHIFT+Click also works for selecting a range.", "Visual_FiscalYearStart": "Fiscal Year Start", "Visual_FiscalYear": "Fiscal Year", "Visual_Month": "Month",