@@ -28,6 +28,7 @@ const props = defineProps<{
2828 selectedVersion: string | null
2929}>()
3030
31+ const { settings } = useSettings ()
3132const route = useRoute (' timeline' )
3233
3334const activeVersion = computed (() => route .params .version )
@@ -36,43 +37,6 @@ const packageName = computed(() =>
3637 route .params .org ? ` ${route .params .org }/${route .params .packageName } ` : route .params .packageName ,
3738)
3839
39- function addTimelineEntries(
40- entries : ConvertedTimelineSizeCacheEntry [],
41- timelineEntries : TimelineVersion [],
42- ): EnrichedTimelineSizeCacheEntry [] {
43- const timelineEntryByVersion = new Map (timelineEntries .map (entry => [entry .version , entry ]))
44-
45- return entries .map (entry => {
46- const version = entry .name .split (' @' )[1 ] ?? ' '
47- const timelineEntry = timelineEntryByVersion .get (version )
48-
49- return {
50- ... entry ,
51- version ,
52- time: timelineEntry ?.time ,
53- license: timelineEntry ?.license ,
54- type: timelineEntry ?.type ,
55- hasTypes: timelineEntry ?.hasTypes ,
56- hasTrustedPublisher: timelineEntry ?.hasTrustedPublisher ,
57- hasProvenance: timelineEntry ?.hasProvenance ,
58- tags: timelineEntry ?.tags ?? [],
59- events: [],
60- hasPositive: false ,
61- hasNegative: false ,
62- }
63- })
64- }
65-
66- function convertMapEntries(
67- entries : Array <{ key: string ; value: TimelineSizeCacheValue }>,
68- ): ConvertedTimelineSizeCacheEntry [] {
69- return entries .map (({ key , value }) => ({
70- name: key ,
71- totalSize: value .totalSize ,
72- dependencyCount: value .dependencyCount ,
73- }))
74- }
75-
7640function addEvaluationFlags(
7741 entries : EnrichedTimelineSizeCacheEntry [],
7842 versionSubEvents : Map <string , SubEvent []>,
@@ -90,9 +54,33 @@ function addEvaluationFlags(
9054}
9155
9256const convertedData = computed (() => {
93- const base = convertMapEntries (Array .from (props .sizeCache , ([key , value ]) => ({ key , value })))
94- const withTimelineEntries = addTimelineEntries (base , props .timelineEntries )
95- return addEvaluationFlags (withTimelineEntries , props .versionSubEvents ).toReversed ()
57+ const entries = props .timelineEntries .flatMap (timelineEntry => {
58+ const key = ` ${packageName .value }@${timelineEntry .version } `
59+ const value = props .sizeCache .get (key )
60+
61+ if (! value ) {
62+ return []
63+ }
64+
65+ return {
66+ name: key ,
67+ totalSize: value .totalSize ,
68+ dependencyCount: value .dependencyCount ,
69+ version: timelineEntry .version ,
70+ time: timelineEntry .time ,
71+ license: timelineEntry .license ,
72+ type: timelineEntry .type ,
73+ hasTypes: timelineEntry .hasTypes ,
74+ hasTrustedPublisher: timelineEntry .hasTrustedPublisher ,
75+ hasProvenance: timelineEntry .hasProvenance ,
76+ tags: timelineEntry .tags ?? [],
77+ events: [],
78+ hasPositive: false ,
79+ hasNegative: false ,
80+ }
81+ })
82+
83+ return addEvaluationFlags (entries , props .versionSubEvents ).toReversed ()
9684})
9785
9886const versions = computed (() => convertedData .value .map (d => d .name .split (' @' )[1 ] ?? ' ' ))
@@ -230,7 +218,7 @@ const watermarkColors = computed(() => ({
230218
231219const mobileBreakpointWidth = 640
232220const isMobile = computed (() => width .value > 0 && width .value < mobileBreakpointWidth )
233- const isZeroBase = shallowRef ( false )
221+
234222const commonScaleSteps = computed (() => {
235223 if (activeTab .value === ' totalSize' ) {
236224 return seriesTotalSize .value .max - seriesTotalSize .value .min > 5 ? 6 : 3
@@ -283,7 +271,7 @@ const config = computed<VueUiXyConfig>(() => {
283271 formatter : ({ value }) => {
284272 return formatter .value .format (value ?? 0 )
285273 },
286- scaleMin: isZeroBase .value
274+ scaleMin: settings .value . timelineChart . isZeroBased
287275 ? 0
288276 : activeTab .value === ' totalSize'
289277 ? seriesTotalSize .value .min
@@ -478,7 +466,10 @@ const indexSelection = computed(() => {
478466 </TabList >
479467 </TabRoot >
480468
481- <SettingsToggle v-model =" isZeroBase" :label =" $t('package.timeline.chart.base_scale')" />
469+ <SettingsToggle
470+ v-model =" settings.timelineChart.isZeroBased"
471+ :label =" $t('package.timeline.chart.base_scale')"
472+ />
482473 </div >
483474 <ClientOnly >
484475 <VueUiXy :dataset =" datasets[activeTab]" :config :selected-x-index =" indexSelection" >
0 commit comments