Release 2.4.1: five answers to the intraday chart feedback - #4
Merged
Merged
Conversation
pointWidth is a fixed distance, so a handful of intraday bars bunched up against the left edge and left the rest of the chart empty. Fitting widens the spacing to fill the plot, and widens the candle and volume bars with it so they keep their proportions. It only ever widens, so a series long enough to fill the plot is laid out on pointWidth as before and the flag can stay on while history pages in. A fitted series is exactly as wide as the plot, so the scroll holds at zero rather than leaving the half point the last candle's centre normally needs.
A locked axis holds the range it was given, so a tick beyond it had nowhere of its own to be drawn: the line was painted over the volume and indicator panes, or off the canvas where it was invisible. A horizontal line at such a price is now left out of the plot, and its label is pinned to the edge the price went past and marked with an arrow so the level can still be found. The current-price line, the signal lines and the trading tags are clamped to the same edge; the trading lines already skipped themselves, and now say so through the same shared test. The large-history perf test priced its drawings below everything on screen, which no longer resolves an anchor at all now that an unreachable line is skipped before the lookup. Priced around the newest candle instead.
…Price A locked axis holds the range it was given, so a market that trades past it walked off the top or the bottom of the chart until resetPriceScale was called. The new flag grows the locked range just enough to cover the newest candle, and never shrinks it back or refits it to the window, so the axis still sits still while the chart is scrolled. Only the newest candle counts, and only while it is in view: growing the axis to swallow the history a scroll moves over would undo the lock a little at a time. Whether it is in view is asked of the painter as it stands, which is last frame's window over last frame's candles, so a tick that has just arrived is measured against the window it arrived into rather than waiting a frame.
fixedLength only said how many decimals a price is written to, so a currency symbol, a thousands separator or a tick size had nowhere to go. The new callback takes the writing over, the way dateFormatter already does on the date axis. It covers every price the chart itself says: the axis labels, the crosshair's price label, the current-price tag, the high, low and signal tags, and the OHLC legend. An axis that reads out a move rather than a price writes that move itself and does not ask. Drawings keep their own titles.
The chart had one price axis, so reading a move as a percentage meant giving up the prices. secondaryPriceAxisScale reads the same candles a second way in a gutter on the side verticalTextAlignment left free. It marks its own round values rather than labelling the price axis's, so a percentage axis reads +2%, +4%, +6%. The grid stays ruled by the price axis: a second set of lines over one set of candles would say nothing the second set of labels does not, and the crosshair and the price tags keep following priceAxisScale. The two gutters are clamped against each other rather than separately, so between them they can never take more than half the chart's width.
The intraday demo was working the candle spacing out by hand, which is what ChartStyle.fitContent now does; it sets the flag instead. The tour app gets a toggle for each of the rest: a locked axis that follows the price, a level the axis cannot reach, fitting the candles to the width, and prices written as currency. Goldens for four of them, including a short series before and after fitting, which is the complaint the issue opened with. Drawing those turned up a background filled from the canvas edge for the plot's width: a gutter on the right showed whatever was under the widget, and a gutter on the left shifted the fill. Every band now spans the canvas.
Five changes, one for each point raised in issue #3 about the intraday chart: candles fitted to the width, a price the locked axis cannot reach held inside the candle area, a locked axis that can follow the price, a formatter for the prices the chart writes, and a second price axis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3.
Five changes, one for each point raised in the issue. Each is its own commit.
Fit a short series to the width —
ChartStyle.fitContentpointWidthis a fixed distance, so a handful of intraday bars bunched upagainst the left edge and left the rest of the chart empty. Fitting widens the
spacing to fill the plot, and widens the candle and volume bars with it so they
keep their proportions. It only ever widens, so a series long enough to fill the
plot is laid out on
pointWidthas before and the flag can stay on whilehistory pages in.
A fitted series is exactly as wide as the plot, so
getMinTranslateXholds thescroll at zero rather than leaving the half point the last candle's centre
normally needs.
Keep a price the locked axis cannot reach inside the candle area — bug fix
A locked axis holds the range it was given, so a tick beyond it had nowhere of
its own to be drawn: the line was painted over the volume and indicator panes,
or off the canvas where it was invisible.
A horizontal line at such a price is now left out of the plot, and its label is
pinned to the edge the price went past and marked with an arrow so the level can
still be found. The current-price line, the signal lines and the trading tags
are clamped to the same edge — they were clamped to the window's extremes,
which under a lock are not the axis's.
Keep the newest candle on a locked axis —
lockedScaleFollowsPriceOpt-in, so an existing
lockPriceScale: truechart behaves exactly as before.The locked range grows just enough to cover the newest candle and never shrinks
back or refits to the window, so the axis still sits still while the chart is
scrolled. Only the newest candle counts, and only while it is in view: growing
the axis to swallow the history a scroll moves over would undo the lock a little
at a time.
Write the chart's prices —
priceFormatterfixedLengthonly said how many decimals a price is written to, so a currencysymbol, a thousands separator or a tick size had nowhere to go. The new callback
is the counterpart to
dateFormatterand covers every price the chart itselfsays: the axis labels, the crosshair's price label, the current-price tag, the
high, low and signal tags, and the OHLC legend. An axis that reads out a move
rather than a price writes that move itself and does not ask.
A second price axis —
secondaryPriceAxisScaleThe chart had one price axis, so reading a move as a percentage meant giving up
the prices. A second axis reads the same candles another way, in a gutter on the
side
verticalTextAlignmentleft free and sized byChartStyle.secondaryPriceAxisWidth. It marks its own round values rather thanlabelling the price axis's, the grid stays ruled by the price axis, and the
crosshair and price tags keep following
priceAxisScale. The two gutters areclamped against each other, so between them they can never take more than half
the chart's width.
Also in here
plot's width, so a gutter on the right showed whatever was under the widget
and a gutter on the left shifted the fill. Every band now spans the canvas.
fitContentinstead of working the spacing out by hand.currency prices and the edge-marked level.
no longer resolves an anchor now that an unreachable line is skipped before
the lookup. Repriced around the newest candle; its subject is unchanged.
Release
Version 2.4.1, with the changelog entry and the README's install line updated.
Testing
898 tests pass,
flutter analyzeanddart formatclean, and the examplebuilds for both entry points. 22 new tests, including three that fail without
the out-of-range fix.