@@ -28,6 +28,7 @@ interface ServiceChartProps {
2828 useSkuAnalysis ?: boolean ; // Override to use SKU-based analysis instead of repository-based
2929 breakdown ?: "cost" | "quantity" ; // Whether to breakdown by cost or quantity
3030 hasMultipleOrganizations ?: boolean ; // Whether to show organization breakdown charts
31+ storageUnit ?: "gb-hours" | "gb-months" ; // Unit for displaying storage data
3132}
3233
3334const COLORS = [
@@ -44,12 +45,21 @@ const COLORS = [
4445 "#64748b" ,
4546] ;
4647
48+ // Conversion constant: 1 month ≈ 730 hours (average)
49+ const HOURS_PER_MONTH = 730 ;
50+
51+ // Convert GB-hours to GB-months
52+ function convertToGBMonths ( gbHours : number ) : number {
53+ return gbHours / HOURS_PER_MONTH ;
54+ }
55+
4756export function ServiceChart ( {
4857 data,
4958 title,
5059 serviceType,
5160 useSkuAnalysis = false ,
5261 breakdown = "quantity" ,
62+ storageUnit = "gb-hours" ,
5363} : ServiceChartProps ) {
5464 if ( ! data || data . length === 0 ) {
5565 return (
@@ -84,6 +94,7 @@ export function ServiceChart({
8494 title = { title }
8595 serviceType = { serviceType }
8696 breakdown = { breakdown }
97+ storageUnit = { storageUnit }
8798 />
8899 ) ;
89100 }
@@ -117,6 +128,7 @@ export function ServiceChart({
117128 serviceType = { serviceType }
118129 breakdown = { breakdown }
119130 hasMultipleOrganizations = { hasMultipleOrganizations }
131+ storageUnit = { storageUnit }
120132 />
121133 ) ;
122134 } else {
@@ -126,6 +138,7 @@ export function ServiceChart({
126138 title = { title }
127139 serviceType = { serviceType }
128140 breakdown = { breakdown }
141+ storageUnit = { storageUnit }
129142 />
130143 ) ;
131144 }
@@ -136,6 +149,7 @@ function RepositorySpecificChart({
136149 title,
137150 serviceType,
138151 breakdown = "quantity" ,
152+ storageUnit = "gb-hours" ,
139153} : ServiceChartProps ) {
140154 const repository = data [ 0 ] ?. repository || "Unknown Repository" ;
141155
@@ -187,6 +201,10 @@ function RepositorySpecificChart({
187201 if ( serviceType === "actionsMinutes" ) {
188202 return `${ value . toLocaleString ( ) } min` ;
189203 } else if ( serviceType === "actionsStorage" || serviceType === "packages" ) {
204+ if ( storageUnit === "gb-months" ) {
205+ const gbMonths = convertToGBMonths ( value ) ;
206+ return `${ gbMonths . toLocaleString ( undefined , { maximumFractionDigits : 2 } ) } GB·mo` ;
207+ }
190208 return `${ value . toLocaleString ( ) } GB·h` ;
191209 } else if ( serviceType === "copilot" ) {
192210 return `${ value . toFixed ( 2 ) } users` ;
@@ -682,6 +700,7 @@ function RepositoryBasedChart({
682700 serviceType,
683701 breakdown = "quantity" ,
684702 hasMultipleOrganizations = false ,
703+ storageUnit = "gb-hours" ,
685704} : ServiceChartProps ) {
686705 // Get top 10 repositories by the selected breakdown metric
687706 const repoTotals = data . reduce ( ( acc , item ) => {
@@ -832,6 +851,10 @@ function RepositoryBasedChart({
832851 if ( serviceType === "actionsMinutes" ) {
833852 return `${ value . toLocaleString ( ) } min` ;
834853 } else if ( serviceType === "actionsStorage" || serviceType === "packages" ) {
854+ if ( storageUnit === "gb-months" ) {
855+ const gbMonths = convertToGBMonths ( value ) ;
856+ return `${ gbMonths . toLocaleString ( undefined , { maximumFractionDigits : 2 } ) } GB·mo` ;
857+ }
835858 return `${ value . toLocaleString ( ) } GB·h` ;
836859 } else if ( serviceType === "copilot" ) {
837860 return `${ value . toFixed ( 2 ) } users` ;
@@ -1084,6 +1107,7 @@ function SKUBasedChart({
10841107 title,
10851108 serviceType,
10861109 breakdown = "quantity" ,
1110+ storageUnit = "gb-hours" ,
10871111} : ServiceChartProps ) {
10881112 // Check if we have multiple organizations to show organization breakdown
10891113 const organizations = Array . from (
@@ -1163,6 +1187,10 @@ function SKUBasedChart({
11631187 if ( serviceType === "actionsMinutes" ) {
11641188 return `${ value . toLocaleString ( ) } min` ;
11651189 } else if ( serviceType === "actionsStorage" || serviceType === "packages" ) {
1190+ if ( storageUnit === "gb-months" ) {
1191+ const gbMonths = convertToGBMonths ( value ) ;
1192+ return `${ gbMonths . toLocaleString ( undefined , { maximumFractionDigits : 2 } ) } GB·mo` ;
1193+ }
11661194 return `${ value . toLocaleString ( ) } GB·h` ;
11671195 } else if ( serviceType === "copilot" ) {
11681196 return `${ value . toFixed ( 2 ) } users` ;
0 commit comments