Skip to content

Fix single candlestick bar visibility by using proper time scale#28

Closed
Copilot wants to merge 10 commits into
masterfrom
copilot/fix-first-bar-chart-issue
Closed

Fix single candlestick bar visibility by using proper time scale#28
Copilot wants to merge 10 commits into
masterfrom
copilot/fix-first-bar-chart-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 1, 2026

Single candlestick bars were invisible on the chart because halfWidth was calculated as _widthPercent (0.25 seconds) instead of scaling it to a meaningful time unit. On charts spanning millions of seconds, a 0.5-second bar is imperceptible.

Changes

  • ImplotWrapper::PlotCandlestickOld(): Use 86400.0 * _widthPercent for single bars (1 day base unit)
  • ImplotWrapper::PlotCandlestickNew(): Use 86400.0 * _widthPercent for single bars (1 day base unit)
// Before: 0.25 seconds halfWidth → 0.5 second total width (invisible)
const double halfWidth = _count > 1 ? (_bars[1].t - _bars[0].t) * _widthPercent : _widthPercent;

// After: 21,600 seconds halfWidth → 12 hour total width (visible on daily charts)  
const double halfWidth = _count > 1 ? (_bars[1].t - _bars[0].t) * _widthPercent : 86400.0 * _widthPercent;

Multi-bar behavior unchanged.

Original prompt

When i launch the app, the first created bar only appears on the chart when the second bar is on the chart


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 1, 2026 19:50
…bars

Co-authored-by: Maxime-Leguevacques <154900517+Maxime-Leguevacques@users.noreply.github.com>
Co-authored-by: Maxime-Leguevacques <154900517+Maxime-Leguevacques@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix first bar visibility issue in chart Fix single candlestick bar visibility by using proper time scale Feb 1, 2026
@Maxime-Leguevacques
Copy link
Copy Markdown
Owner

why this number?

@Maxime-Leguevacques
Copy link
Copy Markdown
Owner

@copilot why that number?

Copy link
Copy Markdown
Author

Copilot AI commented Feb 1, 2026

why this number?

86400 is the number of seconds in 1 day (60 × 60 × 24). This chart displays time-based candlestick data where bars typically represent daily intervals. When there's only one bar, we need a reasonable default width - using 1 day as the base unit ensures the bar is visible on daily/weekly charts while matching the typical bar spacing when multiple bars exist.

@copilot why that number?

86400 = seconds in 1 day (60 × 60 × 24). Since this is a time-series candlestick chart where bars represent daily data, using 1 day as the default spacing makes the single bar visible and consistent with multi-bar behavior. The chart setup on line 36 of chartWindow.cpp also uses this time scale (606024*14 for zoom constraints).

@Maxime-Leguevacques Maxime-Leguevacques deleted the copilot/fix-first-bar-chart-issue branch February 1, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants