gloomberb 0.19.4 → 0.19.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/src/api-client/equity-screener.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app.tsx +63 -16
- package/src/cli/commands/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +264 -33
- package/src/cli/commands/search.ts +22 -4
- package/src/cli/commands/ticker.ts +84 -39
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/glossary.ts +3 -3
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +25 -2
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +31 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +11 -6
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/series-search.ts +4 -5
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-bitmap.ts +28 -2
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +30 -7
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/layout/shell/active-drag.ts +38 -7
- package/src/components/layout/shell/drag/magnets.ts +106 -0
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +4 -0
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +20 -0
- package/src/components/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +20 -0
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/quote-flash.ts +36 -32
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +10 -0
- package/src/i18n/ja.ts +10 -0
- package/src/i18n/ko.ts +10 -0
- package/src/i18n/zh-cn.ts +10 -0
- package/src/i18n/zh-tw.ts +10 -0
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/coordinator/events.ts +17 -1
- package/src/market-data/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/hooks.tsx +12 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/math.ts +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
- package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +30 -6
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
- package/src/plugins/builtin/equity-screener/headless.ts +4 -2
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +180 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/futures/series.ts +16 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +2 -1
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +4 -2
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +8 -5
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/vol-surface/client.ts +2 -1
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +9 -2
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/portfolio/collection-name.ts +19 -0
- package/src/portfolio/column-values.ts +76 -10
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +13 -2
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +15 -2
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +322 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +4 -97
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +50 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/price-units.ts +11 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +4 -0
- package/src/types/headless.ts +19 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/host.tsx +2 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/fx-market-hours.ts +43 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/sec-filings.ts +7 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ComponentProps, type ReactNode, type RefObject } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
ChartSurface,
|
|
@@ -83,6 +83,7 @@ import {
|
|
|
83
83
|
} from "./panel-gestures";
|
|
84
84
|
import { resolvePanelCrosshair, axisLabelRows, cursorAxisLabel, resolveSeriesCursorYRatio, resolveSeriesAxisTags } from "./panel-labels";
|
|
85
85
|
import type { KeyboardToolDrag } from "./use-composite-chart-keyboard";
|
|
86
|
+
import { createValueStore, useCursorScene, useValueStore, type CompositeCursorSource, type ValueStore } from "./cursor-source";
|
|
86
87
|
|
|
87
88
|
const webFrame = globalThis as typeof globalThis & {
|
|
88
89
|
requestAnimationFrame?: (callback: () => void) => number;
|
|
@@ -98,7 +99,9 @@ function pointerRow(event: ChartMouseEvent): number {
|
|
|
98
99
|
|
|
99
100
|
interface CompositePanelSurfaceProps {
|
|
100
101
|
panel: CompositePanelScene;
|
|
102
|
+
/** The chart's scene, without its cursor: the crosshair comes from `cursor`. */
|
|
101
103
|
scene: CompositeChartScene;
|
|
104
|
+
cursor: CompositeCursorSource;
|
|
102
105
|
plotWidth: number;
|
|
103
106
|
leftAxisWidth: number;
|
|
104
107
|
rightAxisWidth: number;
|
|
@@ -178,6 +181,7 @@ const PANEL_DIVIDER_STYLE = {
|
|
|
178
181
|
export function CompositePanelSurface({
|
|
179
182
|
panel,
|
|
180
183
|
scene,
|
|
184
|
+
cursor,
|
|
181
185
|
plotWidth,
|
|
182
186
|
leftAxisWidth,
|
|
183
187
|
rightAxisWidth,
|
|
@@ -222,22 +226,16 @@ export function CompositePanelSurface({
|
|
|
222
226
|
const { cellHeightPx = 18, cellWidthPx = 8, fractionalViewport = false } = useUiCapabilities();
|
|
223
227
|
const renderer = useNativeRenderer();
|
|
224
228
|
const plotRef = useRef<BoxRenderable | null>(null);
|
|
225
|
-
|
|
229
|
+
// The pointer's height over the plot, 0 at the top and 1 at the bottom. It
|
|
230
|
+
// moves with the pointer without rendering the panel: only what draws the
|
|
231
|
+
// crosshair reads it.
|
|
232
|
+
const [pointerY] = useState(() => createValueStore<number | null>(null));
|
|
226
233
|
const [toolDrag, setToolDrag] = useState<ChartToolDrag | null>(null);
|
|
227
234
|
// A pointer drag owns the plot while it lasts; otherwise a tool placed from
|
|
228
235
|
// the keyboard draws and reads out exactly like one.
|
|
229
236
|
const keyboardDrag = toolDrag ? null : keyboardToolDrag;
|
|
230
237
|
const activeDrag = toolDrag ?? keyboardDrag?.drag ?? null;
|
|
231
|
-
|
|
232
|
-
// draws a level line where otherwise only the pointer would.
|
|
233
|
-
const heldCursorYRatio = keyboardDrag ? keyboardDrag.drag.endYRatio : sharedCursor ? null : cursorYRatio;
|
|
234
|
-
const seriesCursorYRatio = useMemo(
|
|
235
|
-
() => resolveSeriesCursorYRatio(panel, scene),
|
|
236
|
-
[panel, scene],
|
|
237
|
-
);
|
|
238
|
-
const activeCursorYRatio = scene.cursorXRatio === null
|
|
239
|
-
? null
|
|
240
|
-
: heldCursorYRatio ?? seriesCursorYRatio;
|
|
238
|
+
const cursorView = { panel, cursor, pointerY, keyboardDrag, sharedCursor };
|
|
241
239
|
// The last press on bare plot, for a double press where the host does not count clicks.
|
|
242
240
|
const lastPlotPressRef = useRef<{ at: number; x: number; y: number } | null>(null);
|
|
243
241
|
const dragRef = useRef<
|
|
@@ -265,16 +263,6 @@ export function CompositePanelSurface({
|
|
|
265
263
|
const plotSpanFactor = 1 + compositeRightOffsetRatio(scene.timeScale);
|
|
266
264
|
const bitmapSize = useStaticChartBitmapSize(plotSize.width, plotSize.height);
|
|
267
265
|
const bitmap = useCompositePanelBitmap({ panel, bitmapSize, colors, isDesktopWeb, revealed: plotSize.revealed === true });
|
|
268
|
-
// The chart under the pointer draws both lines: the level line follows the
|
|
269
|
-
// pointer, and its value sits on the axes, beside each series' own tag on
|
|
270
|
-
// the desktop and the web. A keyboard or shared cursor knows its column
|
|
271
|
-
// only, so a chart following another chart's cursor draws the time line
|
|
272
|
-
// alone. A tool placed from the keyboard is the exception: its end is a level.
|
|
273
|
-
const pointerCursorYRatio = scene.cursorXRatio === null ? null : heldCursorYRatio;
|
|
274
|
-
const crosshair = useMemo(
|
|
275
|
-
() => resolvePanelCrosshair(panel, bitmap, scene, pointerCursorYRatio, colors.crosshair),
|
|
276
|
-
[bitmap, colors.crosshair, panel, pointerCursorYRatio, scene],
|
|
277
|
-
);
|
|
278
266
|
const measureDomain = useMemo(() => resolveMeasureAxisDomain(panel), [panel]);
|
|
279
267
|
const toolReadout = useMemo(() => {
|
|
280
268
|
if (!activeDrag) return null;
|
|
@@ -356,13 +344,16 @@ export function CompositePanelSurface({
|
|
|
356
344
|
() => levels && levelDomain ? projectLevels(levels.items, levelDomain, levelDraft) : NO_LEVELS,
|
|
357
345
|
[levelDomain, levelDraft, levels],
|
|
358
346
|
);
|
|
359
|
-
// Over a line a plain drag moves, and while one moves, the pointer says it
|
|
360
|
-
|
|
347
|
+
// Over a line a plain drag moves, and while one moves, the pointer says it
|
|
348
|
+
// goes up and down. Where the pointer is, the plot reads (see `PanelPlotSurface`).
|
|
349
|
+
const levelGrab = useMemo<LevelGrab>(() => {
|
|
361
350
|
if (levelDraft) return true;
|
|
362
|
-
if (!levels?.onEdit ||
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
351
|
+
if (!levels?.onEdit || onPickTime || onPickPrice || (armedTool && armedTool !== "level")) return false;
|
|
352
|
+
return (cursorYRatio) => {
|
|
353
|
+
const hit = hitTestLevel(projectedLevels, cursorYRatio, levelGrabRatio(panel.height));
|
|
354
|
+
return !!hit?.editable && !!hit.draggable;
|
|
355
|
+
};
|
|
356
|
+
}, [armedTool, levelDraft, levels?.onEdit, onPickPrice, onPickTime, panel.height, projectedLevels]);
|
|
366
357
|
// Drawings project through the time scale alone: the crosshair moving,
|
|
367
358
|
// here or on a linked chart, must not repaint the plot, which the terminal's
|
|
368
359
|
// kitty surface would upload whole again.
|
|
@@ -432,16 +423,6 @@ export function CompositePanelSurface({
|
|
|
432
423
|
selectedLevelId,
|
|
433
424
|
toolReadout?.direction,
|
|
434
425
|
]);
|
|
435
|
-
const textLines = useMemo(
|
|
436
|
-
() => isDesktopWeb || !showTextFallback
|
|
437
|
-
? []
|
|
438
|
-
: writeLevelText(
|
|
439
|
-
renderCompositePanelText(panel, plotWidth, scene.cursorXRatio, pointerCursorYRatio),
|
|
440
|
-
projectedLevels,
|
|
441
|
-
selectedLevelId,
|
|
442
|
-
),
|
|
443
|
-
[isDesktopWeb, panel, plotWidth, pointerCursorYRatio, projectedLevels, scene.cursorXRatio, selectedLevelId, showTextFallback],
|
|
444
|
-
);
|
|
445
426
|
const leftAxisLabels = useMemo(
|
|
446
427
|
() => axisLabelRows(
|
|
447
428
|
renderCompositeAxisText(panel.axes.left, panel.height, leftAxisWidth, "left", formatAxisValue),
|
|
@@ -462,17 +443,6 @@ export function CompositePanelSurface({
|
|
|
462
443
|
() => compositeAxisTickLabels(panel.axes.right, rightAxisWidth, formatAxisValue),
|
|
463
444
|
[formatAxisValue, panel, rightAxisWidth],
|
|
464
445
|
);
|
|
465
|
-
const cursorRow = activeCursorYRatio === null
|
|
466
|
-
? null
|
|
467
|
-
: Math.round(activeCursorYRatio * Math.max(panel.height - 1, 0));
|
|
468
|
-
const cursorPixelY = activeCursorYRatio === null
|
|
469
|
-
? null
|
|
470
|
-
: activeCursorYRatio * Math.max(panel.height * cellHeightPx - 1, 0);
|
|
471
|
-
// The pointer's value on the axes follows the level line it belongs to.
|
|
472
|
-
const axisCursorYRatio = isDesktopWeb ? pointerCursorYRatio : activeCursorYRatio;
|
|
473
|
-
const leftCursorLabel = cursorAxisLabel(panel, "left", axisCursorYRatio, formatAxisValue);
|
|
474
|
-
const rightCursorLabel = cursorAxisLabel(panel, "right", axisCursorYRatio, formatAxisValue);
|
|
475
|
-
const seriesAxisTags = useMemo(() => isDesktopWeb ? resolveSeriesAxisTags(panel, scene, formatAxisValue) : [], [formatAxisValue, isDesktopWeb, panel, scene]);
|
|
476
446
|
const measureReadout = useMemo(() => {
|
|
477
447
|
if (!activeDrag || !toolReadout?.summary) return null;
|
|
478
448
|
const text = toolReadout.summary;
|
|
@@ -614,15 +584,15 @@ export function CompositePanelSurface({
|
|
|
614
584
|
const nextYRatio = panel.height <= 1
|
|
615
585
|
? 0.5
|
|
616
586
|
: Math.max(0, Math.min(1, pointer.cellY / (panel.height - 1)));
|
|
617
|
-
|
|
587
|
+
pointerY.set(nextYRatio);
|
|
618
588
|
onCursorDateChange(nextDate);
|
|
619
589
|
consumeChartMouseEvent(event);
|
|
620
590
|
return true;
|
|
621
|
-
}, [onCursorDateChange, panel.height, plotPointer, scene]);
|
|
591
|
+
}, [onCursorDateChange, panel.height, plotPointer, pointerY, scene]);
|
|
622
592
|
const clearCursor = useCallback(() => {
|
|
623
|
-
|
|
593
|
+
pointerY.set(null);
|
|
624
594
|
onCursorDateChange(null);
|
|
625
|
-
}, [onCursorDateChange]);
|
|
595
|
+
}, [onCursorDateChange, pointerY]);
|
|
626
596
|
const startDrag = useCallback((event: ChartMouseEvent) => {
|
|
627
597
|
onActivate?.();
|
|
628
598
|
onPointerPress();
|
|
@@ -1196,21 +1166,19 @@ export function CompositePanelSurface({
|
|
|
1196
1166
|
) : null}
|
|
1197
1167
|
{leftAxisWidth > 0 ? (
|
|
1198
1168
|
<>
|
|
1199
|
-
<
|
|
1169
|
+
<PanelValueAxis
|
|
1170
|
+
view={cursorView}
|
|
1171
|
+
formatAxisValue={formatAxisValue}
|
|
1200
1172
|
axisLabels={leftAxisLabels}
|
|
1201
1173
|
axisTicks={leftAxisTicks}
|
|
1202
1174
|
axisWidth={leftAxisWidth}
|
|
1203
1175
|
axisSectionWidth={leftAxisWidth}
|
|
1204
1176
|
side="left"
|
|
1205
1177
|
height={panel.height}
|
|
1206
|
-
cursorRow={cursorRow}
|
|
1207
|
-
cursorPixelY={cursorPixelY}
|
|
1208
|
-
cursorLabel={leftCursorLabel}
|
|
1209
1178
|
cursorColor={colors.crosshair}
|
|
1210
1179
|
cursorBackgroundColor={colors.background}
|
|
1211
1180
|
axisColor={colors.textDim}
|
|
1212
1181
|
extraMarkers={leftAxisMarkers}
|
|
1213
|
-
seriesTags={isDesktopWeb ? seriesAxisTags.filter((tag) => tag.side === "left") : undefined}
|
|
1214
1182
|
measuredPixelHeight={plotSize.height * cellHeightPx}
|
|
1215
1183
|
gestures={leftAxisGestures}
|
|
1216
1184
|
footButton={manualSide === "left"}
|
|
@@ -1218,16 +1186,24 @@ export function CompositePanelSurface({
|
|
|
1218
1186
|
<Box width={axisGap} />
|
|
1219
1187
|
</>
|
|
1220
1188
|
) : null}
|
|
1221
|
-
<
|
|
1222
|
-
|
|
1189
|
+
<PanelPlotSurface
|
|
1190
|
+
view={cursorView}
|
|
1191
|
+
plotRef={plotRef}
|
|
1192
|
+
bitmap={bitmap}
|
|
1193
|
+
crosshairColor={colors.crosshair}
|
|
1194
|
+
textColor={colors.text}
|
|
1195
|
+
textFallback={!isDesktopWeb && showTextFallback}
|
|
1196
|
+
plotWidth={plotWidth}
|
|
1197
|
+
projectedLevels={projectedLevels}
|
|
1198
|
+
selectedLevelId={selectedLevelId}
|
|
1199
|
+
levelGrab={levelGrab}
|
|
1223
1200
|
// Its measured box on the desktop, where pointer bounds read it; CSS lays it out.
|
|
1224
1201
|
width={plotSize.width}
|
|
1225
1202
|
height={plotSize.height}
|
|
1226
1203
|
// Desktop: the width the axes leave, and the row's height.
|
|
1227
|
-
style={isDesktopWeb ?
|
|
1204
|
+
style={isDesktopWeb ? onPickPrice ? DESKTOP_PLOT_PICK_STYLE : DESKTOP_PLOT_STYLE : undefined}
|
|
1228
1205
|
flexDirection="column"
|
|
1229
1206
|
bitmaps={bitmapLayers}
|
|
1230
|
-
crosshair={crosshair}
|
|
1231
1207
|
vectors={vectors}
|
|
1232
1208
|
onMouseMove={interactive ? handleMouseMove : undefined}
|
|
1233
1209
|
onMouseDown={interactive ? navigable ? pressPlot : pressCursor : undefined}
|
|
@@ -1236,54 +1212,55 @@ export function CompositePanelSurface({
|
|
|
1236
1212
|
onMouseDragEnd={interactive && navigable ? releasePlot : undefined}
|
|
1237
1213
|
onMouseScroll={interactive && navigable ? panFromWheel : undefined}
|
|
1238
1214
|
onMouseOut={interactive ? clearCursor : undefined}
|
|
1239
|
-
cursor={interactive ?
|
|
1215
|
+
cursor={interactive ? toolDrag || !navigable || onPickTime || onPickPrice ? "crosshair" : "grab" : undefined}
|
|
1240
1216
|
data-gloom-interactive={interactive ? "true" : undefined}
|
|
1241
1217
|
data-gloom-role={COMPOSITE_PANEL_ROLE}
|
|
1242
1218
|
data-gloom-remote-kind={remoteKind}
|
|
1243
1219
|
data-gloom-label={panel.label ?? panel.id}
|
|
1244
1220
|
data-gloom-value-scale={manuallyScaled ? "manual" : undefined}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1221
|
+
/>
|
|
1222
|
+
{projectedLevels.length > 0 ? (
|
|
1223
|
+
// A level's label leaves its value to the axis, unless the cursor's covers it there.
|
|
1224
|
+
<PanelLevelLabels view={cursorView}>
|
|
1225
|
+
{(activeCursorYRatio) => (isDesktopWeb
|
|
1226
|
+
? layoutLevelLabels(projectedLevels, plotSize.height * cellHeightPx, cellHeightPx)
|
|
1227
|
+
: fitAxisLabels(projectedLevels.filter((entry) => entry.level.label), [], (entry) => entry.yRatio * Math.max(1, panel.height - 1))
|
|
1228
|
+
).map((entry) => {
|
|
1229
|
+
const { level, yRatio } = entry;
|
|
1230
|
+
const axisWidth = levelDomain?.side === "left" ? leftAxisWidth : rightAxisWidth;
|
|
1231
|
+
const axisMarkers = levelDomain?.side === "left" ? leftAxisMarkers : rightAxisMarkers;
|
|
1232
|
+
const cursorCovers = activeCursorYRatio !== null && Math.abs(activeCursorYRatio - yRatio) * panel.height < 1;
|
|
1233
|
+
const axisVisible = !cursorCovers && (level.axisLabel?.length ?? 0) <= axisWidth && !!axisMarkers?.some((marker) => marker.id === level.id);
|
|
1234
|
+
const label = levelLabelText(level, axisVisible);
|
|
1235
|
+
const labelStyle = isDesktopWeb ? {
|
|
1236
|
+
...levelLabelStyle(entry, colors.background), left: "auto", right: (rightAxisWidth + (rightAxisWidth ? axisGap : 0) + 1) * cellWidthPx,
|
|
1237
|
+
maxWidth: Math.max(1, plotWidth - 2) * cellWidthPx,
|
|
1238
|
+
} : undefined;
|
|
1239
|
+
const labelWidth = Math.min(plotWidth - 2, label.length + 2);
|
|
1240
|
+
return <Box key={`annotation:${level.id}`} position="absolute" left={leftAxisWidth + (leftAxisWidth ? axisGap : 0) + plotWidth - labelWidth - 1} top={yRatio * Math.max(0, panel.height - 1)} height={1}
|
|
1241
|
+
width={labelWidth} flexDirection="row" justifyContent="flex-end" backgroundColor={colors.background} zIndex={20}
|
|
1242
|
+
style={labelStyle} data-gloom-role="chart-level-label">
|
|
1243
|
+
<Text fg={labelStyle?.color ?? level.color} wrapMode="none" style={isDesktopWeb ? { lineHeight: 1 } : undefined}>{label}</Text>
|
|
1244
|
+
</Box>;
|
|
1245
|
+
})}
|
|
1246
|
+
</PanelLevelLabels>
|
|
1247
|
+
) : null}
|
|
1269
1248
|
{rightAxisWidth > 0 ? (
|
|
1270
1249
|
<>
|
|
1271
1250
|
<Box width={axisGap} />
|
|
1272
|
-
<
|
|
1251
|
+
<PanelValueAxis
|
|
1252
|
+
view={cursorView}
|
|
1253
|
+
formatAxisValue={formatAxisValue}
|
|
1273
1254
|
axisLabels={rightAxisLabels}
|
|
1274
1255
|
axisTicks={rightAxisTicks}
|
|
1275
1256
|
axisWidth={rightAxisWidth}
|
|
1276
1257
|
axisSectionWidth={rightAxisWidth}
|
|
1277
1258
|
side="right"
|
|
1278
1259
|
height={panel.height}
|
|
1279
|
-
cursorRow={cursorRow}
|
|
1280
|
-
cursorPixelY={cursorPixelY}
|
|
1281
|
-
cursorLabel={rightCursorLabel}
|
|
1282
1260
|
cursorColor={colors.crosshair}
|
|
1283
1261
|
cursorBackgroundColor={colors.background}
|
|
1284
1262
|
axisColor={colors.textDim}
|
|
1285
1263
|
extraMarkers={rightAxisMarkers}
|
|
1286
|
-
seriesTags={isDesktopWeb ? seriesAxisTags.filter((tag) => tag.side === "right") : undefined}
|
|
1287
1264
|
measuredPixelHeight={plotSize.height * cellHeightPx}
|
|
1288
1265
|
gestures={rightAxisGestures}
|
|
1289
1266
|
footButton={manualSide === "right"}
|
|
@@ -1326,3 +1303,135 @@ export function CompositePanelSurface({
|
|
|
1326
1303
|
</Box>
|
|
1327
1304
|
);
|
|
1328
1305
|
}
|
|
1306
|
+
|
|
1307
|
+
/** Over a level a drag moves: always while one moves, never, or at the pointer's height. */
|
|
1308
|
+
type LevelGrab = boolean | ((cursorYRatio: number) => boolean);
|
|
1309
|
+
|
|
1310
|
+
/** What a panel's crosshair is read from: everything else in the panel holds still while it moves. */
|
|
1311
|
+
interface PanelCursorView {
|
|
1312
|
+
panel: CompositePanelScene;
|
|
1313
|
+
cursor: CompositeCursorSource;
|
|
1314
|
+
pointerY: ValueStore<number | null>;
|
|
1315
|
+
keyboardDrag: KeyboardToolDrag | null;
|
|
1316
|
+
sharedCursor: boolean;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/** The crosshair over a panel, read by the parts that draw it, so a pointer move renders only them. */
|
|
1320
|
+
function usePanelCursor({ panel, cursor, pointerY, keyboardDrag, sharedCursor }: PanelCursorView) {
|
|
1321
|
+
const scene = useCursorScene(cursor);
|
|
1322
|
+
const cursorYRatio = useValueStore(pointerY);
|
|
1323
|
+
// A keyboard placement's end sits at the level the user put it, so it
|
|
1324
|
+
// draws a level line where otherwise only the pointer would.
|
|
1325
|
+
const heldCursorYRatio = keyboardDrag ? keyboardDrag.drag.endYRatio : sharedCursor ? null : cursorYRatio;
|
|
1326
|
+
const seriesCursorYRatio = useMemo(
|
|
1327
|
+
() => resolveSeriesCursorYRatio(panel, scene),
|
|
1328
|
+
[panel, scene],
|
|
1329
|
+
);
|
|
1330
|
+
return {
|
|
1331
|
+
scene,
|
|
1332
|
+
cursorYRatio,
|
|
1333
|
+
activeCursorYRatio: scene.cursorXRatio === null ? null : heldCursorYRatio ?? seriesCursorYRatio,
|
|
1334
|
+
// The chart under the pointer draws both lines: the level line follows the
|
|
1335
|
+
// pointer, and its value sits on the axes, beside each series' own tag on
|
|
1336
|
+
// the desktop and the web. A keyboard or shared cursor knows its column
|
|
1337
|
+
// only, so a chart following another chart's cursor draws the time line
|
|
1338
|
+
// alone. A tool placed from the keyboard is the exception: its end is a level.
|
|
1339
|
+
pointerCursorYRatio: scene.cursorXRatio === null ? null : heldCursorYRatio,
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/** The plot, with the crosshair over it and, in a terminal without graphics, the text that draws both. */
|
|
1344
|
+
function PanelPlotSurface({
|
|
1345
|
+
view,
|
|
1346
|
+
plotRef,
|
|
1347
|
+
bitmap,
|
|
1348
|
+
crosshairColor,
|
|
1349
|
+
textColor,
|
|
1350
|
+
textFallback,
|
|
1351
|
+
plotWidth,
|
|
1352
|
+
projectedLevels,
|
|
1353
|
+
selectedLevelId,
|
|
1354
|
+
levelGrab,
|
|
1355
|
+
...surface
|
|
1356
|
+
}: Omit<ComponentProps<typeof ChartSurface>, "ref" | "crosshair" | "children"> & {
|
|
1357
|
+
view: PanelCursorView;
|
|
1358
|
+
plotRef: RefObject<BoxRenderable | null>;
|
|
1359
|
+
bitmap: ReturnType<typeof useCompositePanelBitmap>;
|
|
1360
|
+
crosshairColor: string;
|
|
1361
|
+
textColor: string;
|
|
1362
|
+
textFallback: boolean;
|
|
1363
|
+
plotWidth: number;
|
|
1364
|
+
projectedLevels: readonly ProjectedLevel[];
|
|
1365
|
+
selectedLevelId: string | null;
|
|
1366
|
+
levelGrab: LevelGrab;
|
|
1367
|
+
}) {
|
|
1368
|
+
const { panel } = view;
|
|
1369
|
+
const { scene, cursorYRatio, pointerCursorYRatio } = usePanelCursor(view);
|
|
1370
|
+
const crosshair = useMemo(
|
|
1371
|
+
() => resolvePanelCrosshair(panel, bitmap, scene, pointerCursorYRatio, crosshairColor),
|
|
1372
|
+
[bitmap, crosshairColor, panel, pointerCursorYRatio, scene],
|
|
1373
|
+
);
|
|
1374
|
+
const textLines = useMemo(
|
|
1375
|
+
() => textFallback
|
|
1376
|
+
? writeLevelText(
|
|
1377
|
+
renderCompositePanelText(panel, plotWidth, scene.cursorXRatio, pointerCursorYRatio),
|
|
1378
|
+
projectedLevels,
|
|
1379
|
+
selectedLevelId,
|
|
1380
|
+
)
|
|
1381
|
+
: [],
|
|
1382
|
+
[panel, plotWidth, pointerCursorYRatio, projectedLevels, scene.cursorXRatio, selectedLevelId, textFallback],
|
|
1383
|
+
);
|
|
1384
|
+
const grab = typeof levelGrab === "function" ? cursorYRatio !== null && levelGrab(cursorYRatio) : levelGrab;
|
|
1385
|
+
return (
|
|
1386
|
+
<ChartSurface
|
|
1387
|
+
ref={plotRef}
|
|
1388
|
+
{...surface}
|
|
1389
|
+
style={grab && surface.style ? DESKTOP_PLOT_LEVEL_STYLE : surface.style}
|
|
1390
|
+
cursor={grab && surface.cursor ? "ns-resize" : surface.cursor}
|
|
1391
|
+
crosshair={crosshair}
|
|
1392
|
+
>
|
|
1393
|
+
{textLines.map((line, index) => <Text key={index} fg={textColor}>{line}</Text>)}
|
|
1394
|
+
</ChartSurface>
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/** A value axis, with the cursor's value on it and, on the desktop, each series' value at the cursor. */
|
|
1399
|
+
function PanelValueAxis({
|
|
1400
|
+
view,
|
|
1401
|
+
formatAxisValue,
|
|
1402
|
+
side,
|
|
1403
|
+
...axis
|
|
1404
|
+
}: Omit<ComponentProps<typeof PriceAxisLabels>, "cursorRow" | "cursorPixelY" | "cursorLabel" | "seriesTags" | "side"> & {
|
|
1405
|
+
view: PanelCursorView;
|
|
1406
|
+
formatAxisValue?: CompositeAxisValueFormatter;
|
|
1407
|
+
side: CompositeAxisSide;
|
|
1408
|
+
}) {
|
|
1409
|
+
const { panel } = view;
|
|
1410
|
+
const isDesktopWeb = useUiCapabilities().nativePaneChrome === true;
|
|
1411
|
+
const { cellHeightPx = 18 } = useUiCapabilities();
|
|
1412
|
+
const { scene, activeCursorYRatio, pointerCursorYRatio } = usePanelCursor(view);
|
|
1413
|
+
// The pointer's value on the axes follows the level line it belongs to.
|
|
1414
|
+
const axisCursorYRatio = isDesktopWeb ? pointerCursorYRatio : activeCursorYRatio;
|
|
1415
|
+
const seriesTags = useMemo(
|
|
1416
|
+
() => isDesktopWeb ? resolveSeriesAxisTags(panel, scene, formatAxisValue).filter((tag) => tag.side === side) : undefined,
|
|
1417
|
+
[formatAxisValue, isDesktopWeb, panel, scene, side],
|
|
1418
|
+
);
|
|
1419
|
+
return (
|
|
1420
|
+
<PriceAxisLabels
|
|
1421
|
+
{...axis}
|
|
1422
|
+
side={side}
|
|
1423
|
+
cursorRow={activeCursorYRatio === null ? null : Math.round(activeCursorYRatio * Math.max(panel.height - 1, 0))}
|
|
1424
|
+
cursorPixelY={activeCursorYRatio === null ? null : activeCursorYRatio * Math.max(panel.height * cellHeightPx - 1, 0)}
|
|
1425
|
+
cursorLabel={cursorAxisLabel(panel, side, axisCursorYRatio, formatAxisValue)}
|
|
1426
|
+
seriesTags={seriesTags}
|
|
1427
|
+
/>
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/** A panel's level labels, which step aside where the cursor's label covers theirs on the axis. */
|
|
1432
|
+
function PanelLevelLabels({ view, children }: {
|
|
1433
|
+
view: PanelCursorView;
|
|
1434
|
+
children: (activeCursorYRatio: number | null) => ReactNode;
|
|
1435
|
+
}) {
|
|
1436
|
+
return <>{children(usePanelCursor(view).activeCursorYRatio)}</>;
|
|
1437
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { memo, useMemo } from "react";
|
|
2
2
|
import { Box, Text, useUiCapabilities } from "../../../ui";
|
|
3
3
|
import { colors } from "../../../theme/colors";
|
|
4
4
|
import { clamp } from "../../../utils/math";
|
|
@@ -173,7 +173,10 @@ export function PriceAxisLabels({
|
|
|
173
173
|
// Row-snapped labels drift up to a row off the gridlines they name.
|
|
174
174
|
const usePixelTicks = fractionalViewport && axisTicks !== undefined;
|
|
175
175
|
const pixelHeight = Math.max(measuredPixelHeight ?? height * cellHeightPx, 1);
|
|
176
|
-
const placedSeriesTags =
|
|
176
|
+
const placedSeriesTags = useMemo(
|
|
177
|
+
() => seriesTags ? placeSeriesAxisTags(seriesTags, pixelHeight, cellHeightPx) : [],
|
|
178
|
+
[cellHeightPx, pixelHeight, seriesTags],
|
|
179
|
+
);
|
|
177
180
|
const lanes = Math.max(1, ...placedSeriesTags.map((tag) => tag.lane + 1));
|
|
178
181
|
// Fixed reference labels yield to observations, never the other way round.
|
|
179
182
|
const visibleMarkers = extraMarkers?.filter((marker) => placedSeriesTags.every((tag) => Math.abs(tag.centerY - marker.pixelY) >= cellHeightPx));
|
|
@@ -198,22 +201,6 @@ export function PriceAxisLabels({
|
|
|
198
201
|
: fractionalViewport
|
|
199
202
|
? "flex-start"
|
|
200
203
|
: "flex-end";
|
|
201
|
-
const formatLabel = (label: string | null) => {
|
|
202
|
-
const formatted = formatAxisCell(label, axisWidth);
|
|
203
|
-
return side === "right" ? formatted.trimStart().padEnd(axisWidth) : formatted;
|
|
204
|
-
};
|
|
205
|
-
const renderAxisLabel = (label: string | null, fg: string) => (
|
|
206
|
-
fractionalViewport ? (
|
|
207
|
-
<Box flexDirection="row" width={axisSectionWidth} height={1}>
|
|
208
|
-
<Box flexDirection="row" width={axisWidth} justifyContent={axisLabelJustify} overflow="hidden">
|
|
209
|
-
{label ? <Text fg={fg} selectable={false}>{formatLabel(label).trim()}</Text> : null}
|
|
210
|
-
</Box>
|
|
211
|
-
{axisPaddingWidth > 0 ? <Box width={axisPaddingWidth} /> : null}
|
|
212
|
-
</Box>
|
|
213
|
-
) : (
|
|
214
|
-
<Text fg={fg} selectable={false}>{formatLabel(label).padEnd(axisSectionWidth)}</Text>
|
|
215
|
-
)
|
|
216
|
-
);
|
|
217
204
|
|
|
218
205
|
const placedStyle = usePixelOverlay || usePixelTicks ? { position: "relative", height: "auto", alignSelf: "stretch" } : undefined;
|
|
219
206
|
return (
|
|
@@ -239,36 +226,29 @@ export function PriceAxisLabels({
|
|
|
239
226
|
? cursorLabel
|
|
240
227
|
: marker?.label ?? (usePixelTicks || (footButton && row === height - 1) ? null : axisLabels.get(row) ?? null);
|
|
241
228
|
return (
|
|
242
|
-
<
|
|
243
|
-
{
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
229
|
+
<AxisRow
|
|
230
|
+
key={row}
|
|
231
|
+
label={label}
|
|
232
|
+
fg={isCursorRow ? cursorColor : marker ? marker.color : axisColor}
|
|
233
|
+
side={side}
|
|
234
|
+
axisWidth={axisWidth}
|
|
235
|
+
axisSectionWidth={axisSectionWidth}
|
|
236
|
+
fractional={fractionalViewport}
|
|
237
|
+
justify={axisLabelJustify}
|
|
238
|
+
/>
|
|
248
239
|
);
|
|
249
240
|
})}
|
|
250
|
-
{placedTicks ? placedTicks.map((tick) =>
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
whiteSpace: "pre",
|
|
262
|
-
pointerEvents: "none",
|
|
263
|
-
}}
|
|
264
|
-
>
|
|
265
|
-
<Box flexDirection="row" width={axisWidth} justifyContent={axisLabelJustify} overflow="hidden">
|
|
266
|
-
<Text fg={axisColor} selectable={false}>{tick.label}</Text>
|
|
267
|
-
</Box>
|
|
268
|
-
{axisPaddingWidth > 0 ? <Box width={axisPaddingWidth} /> : null}
|
|
269
|
-
</Box>
|
|
270
|
-
);
|
|
271
|
-
}) : null}
|
|
241
|
+
{placedTicks ? placedTicks.map((tick) => (
|
|
242
|
+
<AxisTick
|
|
243
|
+
key={`${tick.label}:${tick.ratio}`}
|
|
244
|
+
label={tick.label}
|
|
245
|
+
topPercent={tick.topPercent}
|
|
246
|
+
color={axisColor}
|
|
247
|
+
axisWidth={axisWidth}
|
|
248
|
+
axisSectionWidth={axisSectionWidth}
|
|
249
|
+
justify={axisLabelJustify}
|
|
250
|
+
/>
|
|
251
|
+
)) : null}
|
|
272
252
|
{usePixelOverlay || usePixelTicks ? visibleMarkers?.map((marker) => (
|
|
273
253
|
<Box
|
|
274
254
|
key={`${marker.label}:${marker.pixelY}`}
|
|
@@ -318,3 +298,69 @@ export function PriceAxisLabels({
|
|
|
318
298
|
</Box>
|
|
319
299
|
);
|
|
320
300
|
}
|
|
301
|
+
|
|
302
|
+
type AxisLabelJustify = "flex-start" | "flex-end";
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* One row of the axis, with its label or none. A row only renders when its
|
|
306
|
+
* label does: the cursor's moving down the axis renders the rows it leaves
|
|
307
|
+
* and lands on, not the column.
|
|
308
|
+
*/
|
|
309
|
+
const AxisRow = memo(function AxisRow({ label, fg, side, axisWidth, axisSectionWidth, fractional, justify }: {
|
|
310
|
+
label: string | null;
|
|
311
|
+
fg: string;
|
|
312
|
+
side: "left" | "right" | undefined;
|
|
313
|
+
axisWidth: number;
|
|
314
|
+
axisSectionWidth: number;
|
|
315
|
+
fractional: boolean;
|
|
316
|
+
justify: AxisLabelJustify;
|
|
317
|
+
}) {
|
|
318
|
+
const formatted = formatAxisCell(label, axisWidth);
|
|
319
|
+
const text = side === "right" ? formatted.trimStart().padEnd(axisWidth) : formatted;
|
|
320
|
+
const axisPaddingWidth = Math.max(0, axisSectionWidth - axisWidth);
|
|
321
|
+
return (
|
|
322
|
+
<Box height={1}>
|
|
323
|
+
{fractional ? (
|
|
324
|
+
<Box flexDirection="row" width={axisSectionWidth} height={1}>
|
|
325
|
+
<Box flexDirection="row" width={axisWidth} justifyContent={justify} overflow="hidden">
|
|
326
|
+
{label ? <Text fg={fg} selectable={false}>{text.trim()}</Text> : null}
|
|
327
|
+
</Box>
|
|
328
|
+
{axisPaddingWidth > 0 ? <Box width={axisPaddingWidth} /> : null}
|
|
329
|
+
</Box>
|
|
330
|
+
) : (
|
|
331
|
+
<Text fg={fg} selectable={false}>{text.padEnd(axisSectionWidth)}</Text>
|
|
332
|
+
)}
|
|
333
|
+
</Box>
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
/** A tick label at its exact height, which holds still while the cursor moves past. */
|
|
338
|
+
const AxisTick = memo(function AxisTick({ label, topPercent, color, axisWidth, axisSectionWidth, justify }: {
|
|
339
|
+
label: string;
|
|
340
|
+
topPercent: number;
|
|
341
|
+
color: string;
|
|
342
|
+
axisWidth: number;
|
|
343
|
+
axisSectionWidth: number;
|
|
344
|
+
justify: AxisLabelJustify;
|
|
345
|
+
}) {
|
|
346
|
+
const axisPaddingWidth = Math.max(0, axisSectionWidth - axisWidth);
|
|
347
|
+
return (
|
|
348
|
+
<Box
|
|
349
|
+
width={axisSectionWidth}
|
|
350
|
+
flexDirection="row"
|
|
351
|
+
style={{
|
|
352
|
+
position: "absolute",
|
|
353
|
+
left: 0,
|
|
354
|
+
top: `${topPercent}%`,
|
|
355
|
+
transform: "translateY(-50%)",
|
|
356
|
+
whiteSpace: "pre",
|
|
357
|
+
pointerEvents: "none",
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
<Box flexDirection="row" width={axisWidth} justifyContent={justify} overflow="hidden">
|
|
361
|
+
<Text fg={color} selectable={false}>{label}</Text>
|
|
362
|
+
</Box>
|
|
363
|
+
{axisPaddingWidth > 0 ? <Box width={axisPaddingWidth} /> : null}
|
|
364
|
+
</Box>
|
|
365
|
+
);
|
|
366
|
+
});
|
|
@@ -51,17 +51,40 @@ function normalizePricePointUncached(point: PricePoint, providerId?: string): Ti
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
/** The points one per instant in time order, the later of two at one instant kept. */
|
|
55
|
+
function uniqueTimeOrderedPoints(points: readonly PricePoint[], providerId: string | undefined): TimeSeriesPoint[] {
|
|
56
|
+
// A history comes in time order: kept as it is, it needs no keyed sort.
|
|
57
|
+
const ordered: TimeSeriesPoint[] = [];
|
|
58
|
+
let previous = Number.NEGATIVE_INFINITY;
|
|
59
|
+
for (const point of points) {
|
|
60
|
+
const normalized = normalizePricePoint(point, providerId);
|
|
61
|
+
if (!normalized) continue;
|
|
62
|
+
const time = normalized.date.getTime();
|
|
63
|
+
if (time <= previous) return keyedTimeOrderedPoints(points, providerId);
|
|
64
|
+
previous = time;
|
|
65
|
+
ordered.push(normalized);
|
|
66
|
+
}
|
|
67
|
+
return ordered;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function keyedTimeOrderedPoints(points: readonly PricePoint[], providerId: string | undefined): TimeSeriesPoint[] {
|
|
59
71
|
const byTimestamp = new Map<number, TimeSeriesPoint>();
|
|
60
72
|
for (const point of points) {
|
|
61
|
-
const normalized = normalizePricePoint(point,
|
|
73
|
+
const normalized = normalizePricePoint(point, providerId);
|
|
62
74
|
if (!normalized) continue;
|
|
63
75
|
byTimestamp.set(normalized.date.getTime(), normalized);
|
|
64
76
|
}
|
|
77
|
+
return [...byTimestamp.values()].sort((left, right) => left.date.getTime() - right.date.getTime());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Converts the app's canonical price history into the generic chart-series boundary. */
|
|
81
|
+
export function pricePointsToResolvedSeries(
|
|
82
|
+
points: readonly PricePoint[],
|
|
83
|
+
options: PricePointsToResolvedSeriesOptions,
|
|
84
|
+
): ResolvedSeries {
|
|
85
|
+
const resolved = uniqueTimeOrderedPoints(points, options.providerId);
|
|
86
|
+
let rejected = 0;
|
|
87
|
+
for (const point of resolved) if (point.provenance?.priceHistoryIntegrity) rejected += 1;
|
|
65
88
|
|
|
66
89
|
return {
|
|
67
90
|
id: options.id,
|
|
@@ -77,7 +100,7 @@ export function pricePointsToResolvedSeries(
|
|
|
77
100
|
panelId: options.panelId ?? "main",
|
|
78
101
|
interpolation: "none",
|
|
79
102
|
timeBasis: options.timeBasis,
|
|
80
|
-
points:
|
|
81
|
-
warning: [options.warning, priceHistoryIntegrityNotice(
|
|
103
|
+
points: resolved,
|
|
104
|
+
warning: [options.warning, priceHistoryIntegrityNotice(rejected)].filter(Boolean).join(" ") || undefined,
|
|
82
105
|
};
|
|
83
106
|
}
|