@funnest/charts 0.6.16 → 0.6.18

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/dist/index.d.ts CHANGED
@@ -5,10 +5,11 @@ export type { ChartContextMenu, ChartEvents, ChartLayout, ChartOptions, ChartPan
5
5
  export type { PriceScaleMode } from './model/price-scale';
6
6
  export type { CrosshairInfo, PaneId } from './render/renderer';
7
7
  export type { Locale } from './model/time-format';
8
+ export { browserLocale } from './model/time-format';
8
9
  export type { IndexRange, TimeScaleOptions } from './model/time-scale';
9
10
  export type { Bar, BarsRequest, BarsResult, Datafeed, Resolution, SymbolInfo, TickSize, Unsubscribe, SymbolType, SymbolSearchResult, Quote, ConnectionState, } from './types';
10
11
  export type { DirectionPreset, ThemeTokens } from './theme';
11
- export { createTheme, darkTheme, lightTheme } from './theme';
12
+ export { createTheme, darkTheme, directionColors, lightTheme } from './theme';
12
13
  export type { FormatPriceOptions } from './price';
13
14
  export { decimalsOf, formatCompact, formatPrice, krxTickSize, resolveTickSize, roundToTick } from './price';
14
15
  export { isIntradayResolution, resolutionToMs } from './resolution';
package/dist/index.js CHANGED
@@ -679,6 +679,11 @@ function niceTicks(min, max, maxCount, minStep = 0) {
679
679
  }
680
680
 
681
681
  // src/model/time-format.ts
682
+ function browserLocale() {
683
+ const nav = typeof navigator === "undefined" ? void 0 : navigator;
684
+ const first = nav?.languages?.[0] ?? nav?.language ?? "";
685
+ return /^ko\b/i.test(first) ? "ko" : "en";
686
+ }
682
687
  var WEEKDAY_INDEX = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 };
683
688
  var WEEKDAYS = {
684
689
  ko: ["\uC77C", "\uC6D4", "\uD654", "\uC218", "\uBAA9", "\uAE08", "\uD1A0"],
@@ -2407,6 +2412,25 @@ function drawMain(layer, m) {
2407
2412
  }
2408
2413
  }
2409
2414
  if (f.settings.gridVertical) for (const tick of f.timeTicks) p.vLine(tick.x, 0, f.panesHeight, pal.grid);
2415
+ const o = m.objects;
2416
+ const rc = { painter: p, coords: o.coords, palette: pal };
2417
+ const runOverlay = (overlay) => {
2418
+ ctx.save();
2419
+ try {
2420
+ overlay.render(rc);
2421
+ } catch (error) {
2422
+ console.error("[fnc] overlay", error);
2423
+ }
2424
+ ctx.restore();
2425
+ };
2426
+ if (o.overlays.some((x) => x.layer === "below")) {
2427
+ ctx.save();
2428
+ ctx.beginPath();
2429
+ ctx.rect(0, main.top, f.plotWidth, main.height);
2430
+ ctx.clip();
2431
+ for (const overlay of o.overlays) if (overlay.layer === "below") runOverlay(overlay);
2432
+ ctx.restore();
2433
+ }
2410
2434
  const hasBars = f.range.to >= f.range.from;
2411
2435
  if (hasBars) {
2412
2436
  ctx.save();
@@ -2446,17 +2470,7 @@ function drawMain(layer, m) {
2446
2470
  ctx.beginPath();
2447
2471
  ctx.rect(0, main.top, f.plotWidth, main.height);
2448
2472
  ctx.clip();
2449
- const o = m.objects;
2450
- const rc = { painter: p, coords: o.coords, palette: pal };
2451
- for (const overlay of o.overlays) {
2452
- ctx.save();
2453
- try {
2454
- overlay.render(rc);
2455
- } catch (error) {
2456
- console.error("[fnc] overlay", error);
2457
- }
2458
- ctx.restore();
2459
- }
2473
+ for (const overlay of o.overlays) if (overlay.layer !== "below") runOverlay(overlay);
2460
2474
  o.trading.render(rc, m.bars, o.barIndexAt, (i) => m.timeScale.indexToX(i), o.tradingLabels, badges);
2461
2475
  o.drawings.render(rc, badges, m.bars, o.barIndexAt);
2462
2476
  ctx.restore();
@@ -2724,6 +2738,7 @@ var darkTheme = {
2724
2738
  border: "#2C2C35",
2725
2739
  crosshair: "#7E7E87"
2726
2740
  };
2741
+ var directionColors = (preset) => ({ ...DIRECTION_COLORS[preset] });
2727
2742
  function createTheme(base, overrides = {}, direction) {
2728
2743
  return { ...base, ...direction ? DIRECTION_COLORS[direction] : {}, ...overrides };
2729
2744
  }
@@ -2863,7 +2878,7 @@ var Chart = class {
2863
2878
  paneWeightTotal = 1;
2864
2879
  constructor(container, options = {}) {
2865
2880
  this.theme = { ...lightTheme, ...options.theme };
2866
- this.locale = options.locale ?? "ko";
2881
+ this.locale = options.locale ?? browserLocale();
2867
2882
  this.formatter = new TimeFormatter(options.timezone ?? defaultTimeZone(), this.locale);
2868
2883
  this.pricePrecision = options.pricePrecision ?? 2;
2869
2884
  this.tickSize = options.tickSize ?? 0;
@@ -4726,12 +4741,14 @@ export {
4726
4741
  SERIES_COLORS,
4727
4742
  TickAggregator,
4728
4743
  bollinger,
4744
+ browserLocale,
4729
4745
  bucketStart,
4730
4746
  combineDatafeeds,
4731
4747
  createChart,
4732
4748
  createTheme,
4733
4749
  darkTheme,
4734
4750
  decimalsOf,
4751
+ directionColors,
4735
4752
  distToSegment,
4736
4753
  ema,
4737
4754
  fallbackResolution,
@@ -1,6 +1,11 @@
1
1
  import type { Bar } from '../types';
2
2
  import type { TimeScale } from './time-scale';
3
3
  export type Locale = 'ko' | 'en';
4
+ /**
5
+ * The locale when none is given: Korean for a browser set to Korean, English for everyone else
6
+ * (and outside a browser).
7
+ */
8
+ export declare function browserLocale(): Locale;
4
9
  export interface TimeParts {
5
10
  year: number;
6
11
  /** 1–12 */
@@ -29,6 +29,11 @@ export interface ObjectRenderContext {
29
29
  */
30
30
  export interface ChartOverlay {
31
31
  render(rc: ObjectRenderContext): void;
32
+ /**
33
+ * 'below': painted right after the grid, under the candles and indicators (an order-book
34
+ * heatmap, session shading). Default 'above'.
35
+ */
36
+ layer?: 'above' | 'below';
32
37
  }
33
38
  export type ObjectHit = {
34
39
  kind: 'drawing';
package/dist/theme.d.ts CHANGED
@@ -21,4 +21,6 @@ export interface ThemeTokens {
21
21
  export type DirectionPreset = 'kr' | 'global';
22
22
  export declare const lightTheme: ThemeTokens;
23
23
  export declare const darkTheme: ThemeTokens;
24
+ /** Up/down candle colors: 'kr' red up · blue down (Korea), 'global' green up · red down. */
25
+ export declare const directionColors: (preset: DirectionPreset) => Pick<ThemeTokens, 'up' | 'down'>;
24
26
  export declare function createTheme(base: ThemeTokens, overrides?: Partial<ThemeTokens>, direction?: DirectionPreset): ThemeTokens;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts",
3
- "version": "0.6.16",
3
+ "version": "0.6.18",
4
4
  "description": "Canvas charting engine for financial charts",
5
5
  "keywords": [
6
6
  "chart",