Commit 41c8d80
feat: Advanced charts integration in token details page (#26465)
## **Description**
The token overview page's chart experience has been upgraded in two
ways:
### 1. Updated legacy chart to visually match the advanced chart's line
mode
The existing SVG line chart (`PriceChart`) has been restyled so that
even without the feature flag, users see a modernized chart:
- **Line color now reflects price direction** — green
(`success.default`) for positive, red (`error.default`) for negative,
replacing the old primary blue color used regardless of direction.
- **Removed the area gradient fill** under the line — the chart now
renders as a clean line-only chart (`svg.fill` set to `'none'`,
`DataGradient` removed).
- **Added a TradingView-style end dot** (`EndDot`) — a 16px circle
marker at the last data point with a background-colored stroke, matching
the chart line color.
- **Shared chart height** — new `TOKEN_OVERVIEW_CHART_HEIGHT` constant
(24% screen height) replaces the old 44%, aligning both legacy and
advanced chart dimensions.
- **Responsive width** — chart uses `width: '100%'` / `alignSelf:
'stretch'` instead of `Dimensions.get('screen').width`, preventing
overflow in padded containers and enabling proper end-dot visibility via
`contentInset.right`.
- **Price diff text color** now uses design system `TextColor` enums
(`SuccessDefault` / `ErrorDefault` / `TextAlternative`) instead of the
old stylesheet-based `priceDiff` style.
### 2. New advanced OHLCV chart behind feature flag
A new `tokenDetailsAdvancedCharts` remote feature flag (version-gated,
minimum 7.73) enables a TradingView Lightweight Charts-based WebView
chart with candlestick and line modes. When the flag is disabled, the
updated legacy chart renders.
**Architecture:**
- **Refactored `Price` component** into a routing layer delegating to
`PriceAdvanced` (new) or `PriceLegacy` (extracted from original) based
on `selectTokenOverviewAdvancedChartEnabled`.
- **`PriceAdvanced`** — renders `AdvancedChart` WebView with time range
selector (1H/1D/1W/1M/1Y), chart type toggle (line ↔ candlestick),
volume overlay, `OHLCVBar` crosshair data display, and empty/error
states with a placeholder SVG.
- **`useOHLCVChart` hook** — fetches OHLCV data from the MetaMask Price
API (`/v3/ohlcv-chart`) with cursor-based pagination for scroll-back
history.
- **`OHLCVBar` component** — displays Open, High, Low, Close, Volume
values above the chart when crosshair is active in candlestick mode.
- **`TimeRangeSelector` updates** — added chart type toggle icon
(line/candlestick) and exported `TIME_RANGE_CONFIGS` for OHLCV API
mapping.
- **`AssetOverviewContent`** — conditionally hides the legacy
`ChartNavigationButton` time period tabs when the advanced chart is
enabled (the range selector lives inside `PriceAdvanced`).
- **Analytics** — new MetaMetrics events: `chart_type_changed`,
`chart_timeframe_changed`, `chart_interacted`,
`chart_tradingview_clicked`, `chart_empty_displayed`.
- **Styles migration** — `Price.styles.tsx` simplified (removed
`priceDiff` vars param; added chart container, time range, and empty
state styles for the advanced chart).
- **Feature flag selector** — `selectTokenOverviewAdvancedChartEnabled`
reads `tokenDetailsAdvancedCharts` from remote feature flags with
version gating via `validatedVersionGatedFeatureFlag`.
- **E2E mocking** — added OHLCV API mock response in the E2E mock
defaults.
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Updated token overview chart visuals (direction-colored
line, end dot marker, no area fill) and added an advanced OHLCV
candlestick/line chart behind a remote feature flag
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/4d8b5fa0-6a6a-471e-b55f-77a672d77980
## **Pre-merge author checklist**
- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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]
> **Medium Risk**
> Moderate risk: introduces new TradingView WebView chart behavior (data
syncing, pagination, external link handling) and refactors the token
overview `Price` header/chart rendering behind a feature flag, which
could affect chart loading and interaction flows.
>
> **Overview**
> Adds a feature-flagged advanced token overview chart (`PriceAdvanced`)
backed by a new `useOHLCVChart` hook that fetches/paginates OHLCV data
from the Price API, supports line/candlestick toggling, time-range
selection, crosshair OHLCV display, and empty/insufficient-data
overlays.
>
> Refactors `Price` into a flag-based router between new `PriceAdvanced`
and extracted `PriceLegacy`, and updates the legacy `PriceChart`
visuals/behavior to better match the advanced experience (shared chart
height, responsive width, direction-colored line, no area fill,
TradingView-style end-dot marker, improved touch mapping).
>
> Enhances `AdvancedChart`’s RN↔WebView protocol and rendering: adds
`ohlcvSeriesKey`-based full data reloads vs realtime updates,
layout-settle skeleton gating, volume overlay support, line-chrome
configuration, TradingView external link interception (in-app browser +
debounce), and additional analytics hooks; updates `TimeRangeSelector`
UI/ranges and adds new `OHLCVBar` + volume formatting utilities.
Includes comprehensive new/updated unit tests across these components.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
76c6fac. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@consensys.net>1 parent f923f78 commit 41c8d80
42 files changed
Lines changed: 9322 additions & 981 deletions
File tree
- app
- components/UI
- AssetOverview
- PriceChart
- Price
- Charts/AdvancedChart
- OHLCVBar
- __tests__
- webview
- Predict/utils
- TokenDetails
- Views
- components
- core/Analytics
- selectors/featureFlagController/tokenOverviewAdvancedChart
- util/number
- locales/languages
- tests
- api-mocking/mock-responses/defaults
- feature-flags
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 278 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 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 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
0 commit comments