Skip to content

Commit d7d203b

Browse files
committed
Merge branch 'compare-quadrant-chart' of https://github.com/npmx-dev/npmx.dev into compare-quadrant-chart
2 parents 7079805 + 901f8c2 commit d7d203b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

app/utils/charts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ export function createAltTextForCompareQuadrantChart({
649649
config,
650650
}: AltCopyArgs<VueUiQuadrantDatapoint[], CompareQuadrantChartConfig>) {
651651
if (!dataset) return ''
652-
652+
653653
const packages = {
654654
topRight: dataset.filter(d => d.quadrant === 'TOP_RIGHT'),
655655
topLeft: dataset.filter(d => d.quadrant === 'TOP_LEFT'),

app/utils/compare-quadrant-chart.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface PackageQuadrantPoint {
4141
const WEIGHTS = {
4242
adoption: {
4343
downloads: 0.75, // dominant signal because they best reflect real-world adoption (in the data we have through facets currently)
44-
freshness: 0.15, // small correction so stale packages are slightly
44+
freshness: 0.15, // small correction so stale packages are slightly
4545
likes: 0.1, // might be pumped up in the future when ./npmx likes are more mainstream
4646
},
4747
efficiency: {
@@ -59,11 +59,11 @@ const WEIGHTS = {
5959
}
6060

6161
/* Fixed logarithmic ceilings to normalize metrics onto a stable [-1, 1] scale.
62-
* This avoids dataset-relative min/max normalization, which would shift scores depending
63-
* on which packages are being compared. Ceilings act as reference points for what is
64-
* considered 'high' for each metric, ensuring consistent positioning across different
65-
* datasets while preserving meaningful differences via log scaling.
66-
*/
62+
* This avoids dataset-relative min/max normalization, which would shift scores depending
63+
* on which packages are being compared. Ceilings act as reference points for what is
64+
* considered 'high' for each metric, ensuring consistent positioning across different
65+
* datasets while preserving meaningful differences via log scaling.
66+
*/
6767
const LOG_CEILINGS = {
6868
downloads: 100_000_000,
6969
likes: 1000, // might be pumped up in the future when ./npmx likes are more mainstream
@@ -165,7 +165,10 @@ function createQuadrantPoint(packageItem: PackageQuadrantInput): PackageQuadrant
165165
const normalisedLikes = normalizeLogHigherBetter(totalLikes, LOG_CEILINGS.likes)
166166
const normalisedInstallSize = normalizeLogLowerBetter(installSize, LOG_CEILINGS.installSize)
167167
const normalisedDependencies = normalizeLogLowerBetter(dependencies, LOG_CEILINGS.dependencies)
168-
const normalisedTotalDependencies = normalizeLogLowerBetter(totalDependencies, LOG_CEILINGS.totalDependencies)
168+
const normalisedTotalDependencies = normalizeLogLowerBetter(
169+
totalDependencies,
170+
LOG_CEILINGS.totalDependencies,
171+
)
169172
const normalisedPackageSize = normalizeLogLowerBetter(packageSize, LOG_CEILINGS.packageSize)
170173

171174
const normalisedVulnerabilities = getVulnerabilityPenalty(vulnerabilities)
@@ -216,4 +219,4 @@ function createQuadrantPoint(packageItem: PackageQuadrantInput): PackageQuadrant
216219
export function createQuadrantDataset(packages: PackageQuadrantInput[]): PackageQuadrantPoint[] {
217220
if (!packages.length) return []
218221
return packages.map(packageItem => createQuadrantPoint(packageItem))
219-
}
222+
}

test/unit/app/utils/compare-quadrant-chart.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,4 +623,4 @@ describe('createQuadrantDataset', () => {
623623
expect(point.y).toBeLessThanOrEqual(1)
624624
}
625625
})
626-
})
626+
})

0 commit comments

Comments
 (0)