Commit 2d39ddc
authored
fix(perps): Prevent duplicate day markers on TradingView chart (MetaMask#23179)
## **Description**
This PR enhances the TradingView chart's timestamp display system to
prevent duplicate day markers and improve date label clarity across
different chart time ranges.
**What is the reason for the change?**
The TradingView chart was displaying duplicate or redundant date labels
on the X-axis, particularly when viewing charts at different time scales
(hourly, daily, weekly). This made the chart harder to read.
## **Changelog**
CHANGELOG entry: Fixed duplicate day markers on TradingView chart X-axis
and improved timestamp display clarity
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1807
## **Manual testing steps**
```gherkin
Feature: TradingView Chart Day Markers
Scenario: user views chart with different timeframes
Given the user is on the Perps trading screen
And the TradingView chart is loaded with data
When user selects different timeframes (1H, 1D, 1W)
Then the chart should show clear day markers without duplicates
And day boundaries should display date + time (e.g., "17 Nov 00:15")
And subsequent hours on the same day should show time only (e.g., "01:15")
And today's date should show time only without the date label
Scenario: user scrolls through chart history
Given the user has a chart with day markers displayed
When user scrolls or zooms the chart to view different time periods
Then the displayed date tracking should reset
And new day markers should appear correctly for the newly visible range
And no duplicate day markers should appear
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/8b2607df-38a3-4eb0-b05e-8a00a8e9fbee
### **After**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/a9f5776c-0276-442c-946d-6e392c4bbd93
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Refactors chart time label formatting to show day+month on daily ticks
and conditional date+time on intraday ticks, preventing duplicate day
markers and improving clarity across zoom ranges.
>
> - **TradingView chart timestamp formatting**
(`app/components/UI/Perps/components/TradingViewChart/TradingViewChartTemplate.tsx`):
> - Add helpers `getDateString` and `isToday` for timezone-aware date
checks.
> - Update `formatTimestamp`:
> - `DayOfMonth`: always `"DD Mon"` (e.g., `17 Nov`).
> - `Hour`/`Minute`: show `"DD Mon HH:MM"` if not today, else `"HH:MM"`.
> - `Second`: unchanged (HH:MM:SS).
> - Fallback based on visible range mirrors above rules; longer ranges
always `"DD Mon"`.
> - Crosshair labels remain full date+time.
> - Adjust final fallback to return `"DD Mon HH:MM"`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
418c660. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b7b6b07 commit 2d39ddc
1 file changed
Lines changed: 121 additions & 35 deletions
Lines changed: 121 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
59 | 75 | | |
60 | 76 | | |
61 | 77 | | |
| |||
200 | 216 | | |
201 | 217 | | |
202 | 218 | | |
203 | | - | |
204 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
205 | 222 | | |
206 | 223 | | |
207 | 224 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 225 | + | |
| 226 | + | |
213 | 227 | | |
214 | 228 | | |
| 229 | + | |
| 230 | + | |
215 | 231 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
222 | 259 | | |
223 | 260 | | |
224 | 261 | | |
| |||
241 | 278 | | |
242 | 279 | | |
243 | 280 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
251 | 308 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
262 | 340 | | |
263 | 341 | | |
264 | 342 | | |
265 | | - | |
266 | | - | |
267 | | - | |
| 343 | + | |
268 | 344 | | |
269 | 345 | | |
270 | 346 | | |
| 347 | + | |
271 | 348 | | |
272 | 349 | | |
273 | 350 | | |
274 | 351 | | |
275 | 352 | | |
276 | | - | |
277 | | - | |
| 353 | + | |
| 354 | + | |
278 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
279 | 363 | | |
280 | 364 | | |
281 | 365 | | |
282 | 366 | | |
283 | 367 | | |
| 368 | + | |
| 369 | + | |
284 | 370 | | |
285 | 371 | | |
286 | 372 | | |
| |||
0 commit comments