How it works
The two interactions have separate engineering lines. Week-to-month switching: the two datasets may have different bar counts, so render the maximum count of both, and extra bars transition their height to zero and hide. Every bar then grows or shrinks in place through a percentage height with a 0.4-second easeOut transition - the chart morphs like a liquid instead of being torn down and rebuilt, which is what makes the switch feel premium.
Long-press focus: on pointerdown start a 300-millisecond timer; when it fires, add a focus class to the container - all bars except the target drop to 0.25 opacity while a value bubble floats up above the chosen bar. Moving the finger during the hold retargets bar to bar, and lifting or leaving clears the state. Building this on pointer events instead of mouseenter means touch and mouse share one code path with no divergence.
How to use this prompt
Made for spending summaries, step comparisons, any metric where users flip granularity. Send two sample datasets and the AI generates both the morph and the press logic. If your bars have two-tone segments like income versus expense, describe the split in the prompt and it will be preserved through transitions.
Tips for better results
The long-press threshold belongs between 250 and 350 milliseconds - shorter collides with taps, longer feels unresponsive. During focus, lift the active bar 2px on top of the dimming; the double contrast reads instantly. Keep the bubble 8px above the bar top so numbers never touch the geometry. When bar counts differ a lot (7 versus 30), transition bar widths too, or the crowd-apart motion snaps while heights glide. And suppress focus detection while the height transition is still running so users cannot trigger it on a half-drawn chart.