feat(market): default chart to 1M, divider below interval buttons, drop chart dots
- Default the price chart to the 1M range on open (was 1D). - Move the hero divider from below the price row to below the interval buttons (centered in the gap between the buttons and the plot). - Remove the dot markers on the chart: no per-point dots, no current-price dot, and no high/low dot anchors — just the clean line + area fill (the high/low price labels and the hover crosshair remain). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -167,7 +167,7 @@ static std::vector<double> pfSparklineSeries(const MarketInfo& m, int interval)
|
||||
|
||||
// Main price-chart interval selector (same semantics as pfSparklineSeries):
|
||||
// 0=Live (in-session minute buffer) 1=hour 2=day 3=week 4=month. Session-scoped.
|
||||
static int s_chart_interval = 2; // default: Day (historical)
|
||||
static int s_chart_interval = 4; // default: 1M (last 30 days)
|
||||
|
||||
// Timestamped price series backing the main chart for the selected RANGE (Live/1H/1D/1W/1M).
|
||||
// The interval buttons select a time window ending at `now`: 1H = last hour, 1D = last 24h,
|
||||
@@ -1019,12 +1019,7 @@ void RenderMarketTab(App* app)
|
||||
dl->AddRectFilled(bMin, bMax, badgeBg, 4.0f * dp);
|
||||
dl->AddText(capFont, capFont->LegacySize, ImVec2(bMin.x + badgePadH, bMin.y + badgePadV), chgCol, buf);
|
||||
|
||||
// ---- SEPARATOR (below the price row; 24H volume + market cap now overlay the chart) ----
|
||||
float sepY = cy + h3->LegacySize + Layout::spacingMd();
|
||||
float rnd = glassSpec.rounding;
|
||||
dl->AddLine(ImVec2(cardMin.x + rnd * 0.5f, sepY),
|
||||
ImVec2(cardMax.x - rnd * 0.5f, sepY),
|
||||
WithAlpha(OnSurface(), 15), 1.0f * dp);
|
||||
// (Divider is drawn in the chart block, below the interval buttons.)
|
||||
|
||||
// ---- TRADE BUTTON (top-right of card) ----
|
||||
if (!currentExchange.pairs.empty()) {
|
||||
@@ -1195,6 +1190,14 @@ void RenderMarketTab(App* app)
|
||||
float plotW = plotRight - plotLeft;
|
||||
float plotH = plotBottom - plotTop;
|
||||
|
||||
// Divider between the interval buttons and the plot (centered in the gap below the strip).
|
||||
{
|
||||
float rnd = glassSpec.rounding;
|
||||
float divY = (stripTop + pillH + plotTop) * 0.5f;
|
||||
dl->AddLine(ImVec2(chartMin.x + rnd * 0.5f, divY), ImVec2(chartMax.x - rnd * 0.5f, divY),
|
||||
WithAlpha(OnSurface(), 15), 1.0f * mktDp);
|
||||
}
|
||||
|
||||
if (s_price_history.size() >= 2) {
|
||||
// Compute Y range with padding
|
||||
double yMin = *std::min_element(s_price_history.begin(), s_price_history.end());
|
||||
@@ -1244,19 +1247,10 @@ void RenderMarketTab(App* app)
|
||||
dl->PathLineTo(ImVec2(points[0].x, plotBottom));
|
||||
dl->PathFillConcave(WithAlpha(dirCol, 28));
|
||||
|
||||
// Line
|
||||
// Line (no per-point dots — a clean curve).
|
||||
dl->AddPolyline(points.data(), (int)points.size(), lineCol, ImDrawFlags_None, S.drawElement("tabs.market", "chart-line-thickness").size);
|
||||
|
||||
// Dots: only for a sparse series — a dense historical curve reads better as a clean line.
|
||||
// Always mark the latest point (current price) with a dot + ring.
|
||||
float dotR = std::max(S.drawElement("tabs.market", "chart-dot-min-radius").size, S.drawElement("tabs.market", "chart-dot-radius").size * hs);
|
||||
if (n <= 40) {
|
||||
for (size_t i = 0; i < n; i++) dl->AddCircleFilled(points[i], dotR, dotCol);
|
||||
}
|
||||
dl->AddCircleFilled(points[n - 1], dotR + 1.0f * mktDp, dotCol);
|
||||
dl->AddCircle(points[n - 1], dotR + 3.5f * mktDp, WithAlpha(dotCol, 130), 0, 1.4f * mktDp);
|
||||
|
||||
// High/low markers for the displayed range: a hollow dot + price label at the extremes.
|
||||
// High/low price labels at the displayed range's extremes (no dot markers).
|
||||
if (n >= 3) {
|
||||
size_t hiIdx = (size_t)(std::max_element(s_price_history.begin(), s_price_history.end()) - s_price_history.begin());
|
||||
size_t loIdx = (size_t)(std::min_element(s_price_history.begin(), s_price_history.end()) - s_price_history.begin());
|
||||
@@ -1266,7 +1260,6 @@ void RenderMarketTab(App* app)
|
||||
ImVec2 ls = capFont->CalcTextSizeA(capFont->LegacySize, FLT_MAX, 0, lbl.c_str());
|
||||
float ly = high ? p.y - ls.y - 5.0f * mktDp : p.y + 5.0f * mktDp;
|
||||
float lx = std::min(std::max(plotLeft, p.x - ls.x * 0.5f), plotRight - ls.x);
|
||||
dl->AddCircle(p, 2.6f * mktDp, WithAlpha(OnSurface(), 190), 0, 1.3f * mktDp);
|
||||
dl->AddText(capFont, capFont->LegacySize, ImVec2(lx, ly), OnSurfaceMedium(), lbl.c_str());
|
||||
};
|
||||
markExtreme(hiIdx, true);
|
||||
|
||||
Reference in New Issue
Block a user