Skip to content

Commit 8baf1a5

Browse files
authored
fix: various chart improvements (#2003)
1 parent 36bebce commit 8baf1a5

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

app/components/Compare/FacetBarChart.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,18 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
220220
const name = datapoint?.name?.replace(/\n/g, '<br>')
221221
return `
222222
<div class="font-mono p-3 border border-border rounded-md bg-[var(--bg)]/10 backdrop-blur-md">
223-
<div class="flex items-center gap-2">
223+
<div class="grid grid-cols-[12px_minmax(0,1fr)_max-content] items-center gap-x-3">
224224
<div class="w-3 h-3">
225225
<svg viewBox="0 0 2 2" class="w-full h-full">
226226
<rect x="0" y="0" width="2" height="2" rx="0.3" fill="${datapoint?.color}" />
227227
</svg>
228228
</div>
229-
<span>${name}: ${(datapoint as VueUiHorizontalBarDatapoint).formattedValue ?? 0}</span>
229+
<span class="text-3xs uppercase tracking-wide text-[var(--fg)]/70 truncate">
230+
${name}
231+
</span>
232+
<span class="text-base text-[var(--fg)] font-mono tabular-nums text-end">
233+
${(datapoint as VueUiHorizontalBarDatapoint).formattedValue ?? 0}
234+
</span>
230235
</div>
231236
</div>
232237
`

app/components/Package/TrendsChart.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
import { DATE_INPUT_MAX } from '~/utils/input'
2121
import { applyDataCorrection } from '~/utils/chart-data-correction'
2222
import { applyBlocklistCorrection, getAnomaliesForPackages } from '~/utils/download-anomalies'
23-
import { copyAltTextForTrendLineChart, sanitise, loadFile } from '~/utils/charts'
23+
import { copyAltTextForTrendLineChart, sanitise, loadFile, applyEllipsis } from '~/utils/charts'
2424
2525
import('vue-data-ui/style.css')
2626
@@ -215,7 +215,7 @@ function formatXyDataset(
215215
const temperatureColors = lightColor ? [lightColor, accent.value] : undefined
216216
217217
const datasetItem: VueUiXyDatasetItem = {
218-
name: seriesName,
218+
name: applyEllipsis(seriesName, 32),
219219
type: 'line',
220220
series: dataset.map(d => d.value),
221221
color: accent.value,
@@ -1050,7 +1050,7 @@ const chartData = computed<{
10501050
.filter(index => index !== -1)
10511051
10521052
const item: VueUiXyDatasetItem = {
1053-
name: pkg,
1053+
name: applyEllipsis(pkg, 32),
10541054
type: 'line',
10551055
series,
10561056
dashIndices,
@@ -1111,10 +1111,10 @@ function buildExportFilename(extension: string): string {
11111111
11121112
if (!isMultiPackageMode.value) {
11131113
const name = effectivePackageNames.value[0] ?? props.packageName ?? 'package'
1114-
return `${sanitise(name)}-${g}_${range}.${extension}`
1114+
return `${sanitise(applyEllipsis(name, 32))}-${g}_${range}.${extension}`
11151115
}
11161116
1117-
const names = effectivePackageNames.value
1117+
const names = effectivePackageNames.value.map(name => applyEllipsis(name, 32))
11181118
const label = names.length === 1 ? names[0] : names.join('_')
11191119
return `${sanitise(label ?? '')}-${g}_${range}.${extension}`
11201120
}

app/components/Package/VersionDistribution.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
drawNpmxLogoAndTaglineWatermark,
1010
} from '~/composables/useChartWatermark'
1111
import TooltipApp from '~/components/Tooltip/App.vue'
12-
import { copyAltTextForVersionsBarChart, sanitise, loadFile } from '~/utils/charts'
12+
import { copyAltTextForVersionsBarChart, sanitise, loadFile, applyEllipsis } from '~/utils/charts'
1313
1414
import('vue-data-ui/style.css')
1515
@@ -131,7 +131,7 @@ const dateRangeLabel = computed(() => {
131131
function buildExportFilename(extension: string): string {
132132
const range = dateRangeLabel.value.replaceAll(' ', '_').replaceAll(',', '')
133133
134-
const label = props.packageName
134+
const label = applyEllipsis(props.packageName, 32)
135135
return `${sanitise(label ?? '')}_${range}.${extension}`
136136
}
137137
@@ -141,7 +141,7 @@ const xyDataset = computed<VueUiXyDatasetItem[]>(() => {
141141
142142
return [
143143
{
144-
name: props.packageName,
144+
name: applyEllipsis(props.packageName, 32),
145145
series: chartDataset.value.map(item => item.downloads),
146146
type: 'bar' as const,
147147
color: accent.value,

0 commit comments

Comments
 (0)