Skip to content

Commit ec48b0e

Browse files
improve graph on mobile
1 parent 2522455 commit ec48b0e

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/components/OverviewChart.jsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,22 @@ export default function OverviewChart({
451451
maxCountsSeries.push(metrics.maxCount);
452452
avgDaysSeries.push(metrics.avgDays);
453453

454-
const radius = dotSizeMode === 'days'
454+
const baseRadius = dotSizeMode === 'days'
455455
? (metrics.avgDays !== null ? getPointSizeFromDays(metrics.avgDays) : 5)
456456
: (metrics.avgCount > 0 ? getPointSizeFromStock(metrics.avgCount) : 5);
457+
458+
// Progressive scaling based on viewport width
459+
const getScaleFactor = () => {
460+
if (typeof window === 'undefined') return 1;
461+
const width = window.innerWidth;
462+
// Full size at 1200px and above, scale down to 0.3x at 320px
463+
if (width >= 1200) return 1;
464+
if (width <= 320) return 0.3;
465+
// Linear interpolation between 320px and 1200px
466+
return 0.3 + ((width - 320) / (1200 - 320)) * 0.7;
467+
};
468+
469+
const radius = baseRadius * getScaleFactor();
457470
pointRadii.push(radius);
458471
});
459472

@@ -779,15 +792,27 @@ export default function OverviewChart({
779792
if (meta.dataset) {
780793
const line = meta.dataset;
781794
line.options.borderWidth = isHovered ? 3 : hasHover ? 1.25 : 2;
795+
796+
// Use same dimming logic as ranges for consistency
797+
const lineAlpha = hasHover
798+
? (isHovered ? 1.0 : (prefersDark ? 0.15 : 0.1))
799+
: 1.0;
800+
782801
line.options.borderColor = isHovered
783802
? baseColor
784-
: hasHover ? toRgba(baseColor, 0.3) : baseColor;
803+
: hasHover ? toRgba(baseColor, lineAlpha) : baseColor;
785804
const pointFill = isHovered
786805
? baseColor
787-
: hasHover ? toRgba(baseColor, 0.35) : baseColor;
788-
const pointBorder = isHovered
806+
: hasHover ? toRgba(baseColor, lineAlpha * 1.2) : baseColor;
807+
808+
// Dim point borders for non-hovered models
809+
const pointBorderBase = isHovered
789810
? adjustLightness(baseColor, -0.12)
790-
: adjustLightness(baseColor, hasHover ? -0.08 : -0.03);
811+
: adjustLightness(baseColor, -0.08);
812+
const pointBorder = hasHover && !isHovered
813+
? toRgba(pointBorderBase, lineAlpha)
814+
: pointBorderBase;
815+
791816
line.options.pointBackgroundColor = pointFill;
792817
line.options.pointBorderColor = pointBorder;
793818

src/utils/inventoryScale.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export function createInventoryScale(inventoryCounts) {
3535
Infinity
3636
];
3737

38-
// More dramatic size progression with exponential-like growth
39-
const sizes = [2, 4, 7, 10, 14, 18, 22];
38+
const sizes = [2, 4, 7, 9, 11, 14, 19];
4039

4140
// Return a function that maps count to size
4241
return (count) => {

0 commit comments

Comments
 (0)