@funnest/charts 0.6.3 → 0.6.4

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
@@ -1,6 +1,6 @@
1
1
  export { Chart, createChart, fallbackResolution } from './chart';
2
- export { DEFAULT_CHART_SETTINGS, parseChartState } from './settings';
3
- export type { ChartSettings, ChartState } from './settings';
2
+ export { CHART_THEMES, DEFAULT_CHART_SETTINGS, matchChartTheme, parseChartState } from './settings';
3
+ export type { ChartSettings, ChartState, ChartThemeColors, ChartThemePreset } from './settings';
4
4
  export type { ChartContextMenu, ChartEvents, ChartLayout, ChartOptions, ChartPaneLayout, CompareInfo, IndicatorLegendItem, ReplayStatus } from './chart';
5
5
  export type { PriceScaleMode } from './model/price-scale';
6
6
  export type { CrosshairInfo, PaneId } from './render/renderer';
package/dist/index.js CHANGED
@@ -1793,6 +1793,41 @@ function snapToOhlc(bar, y, priceToY) {
1793
1793
  }
1794
1794
 
1795
1795
  // src/settings.ts
1796
+ var FOLLOW = { upColor: null, downColor: null, background: null, gridColor: null, textColor: null };
1797
+ var CHART_THEMES = [
1798
+ { id: "default", name: { ko: "\uAE30\uBCF8", en: "Default" }, colors: FOLLOW },
1799
+ { id: "global", name: { ko: "\uCD08\uB85D\xB7\uBE68\uAC15", en: "Green \xB7 Red" }, colors: { ...FOLLOW, upColor: "#26A69A", downColor: "#EF5350" } },
1800
+ {
1801
+ id: "midnight",
1802
+ name: { ko: "\uBBF8\uB4DC\uB098\uC787", en: "Midnight" },
1803
+ colors: { upColor: "#2EBD85", downColor: "#F6465D", background: "#0E1117", gridColor: "#1A1F29", textColor: "#C9D1D9" }
1804
+ },
1805
+ {
1806
+ id: "navy",
1807
+ name: { ko: "\uB525 \uB124\uC774\uBE44", en: "Deep navy" },
1808
+ colors: { upColor: "#FF5A5F", downColor: "#4C8DFF", background: "#0F1A2E", gridColor: "#1B2A44", textColor: "#C8D3E6" }
1809
+ },
1810
+ {
1811
+ id: "mono",
1812
+ name: { ko: "\uBAA8\uB178", en: "Mono" },
1813
+ colors: { upColor: "#E4E4E7", downColor: "#6B6B75", background: "#121214", gridColor: "#1F1F23", textColor: "#D4D4D8" }
1814
+ },
1815
+ {
1816
+ id: "paper",
1817
+ name: { ko: "\uD398\uC774\uD37C", en: "Paper" },
1818
+ colors: { upColor: "#F04452", downColor: "#3182F6", background: "#FFFFFF", gridColor: "#F0F2F5", textColor: "#333D4B" }
1819
+ },
1820
+ {
1821
+ id: "sepia",
1822
+ name: { ko: "\uC138\uD53C\uC544", en: "Sepia" },
1823
+ colors: { upColor: "#C2410C", downColor: "#2F6690", background: "#F6F0E4", gridColor: "#E9DFCB", textColor: "#4A3F33" }
1824
+ }
1825
+ ];
1826
+ function matchChartTheme(settings) {
1827
+ const keys = Object.keys(FOLLOW);
1828
+ const same = (a, b) => (a ?? "").toLowerCase() === (b ?? "").toLowerCase();
1829
+ return CHART_THEMES.find((t) => keys.every((k) => same(t.colors[k], settings[k])));
1830
+ }
1796
1831
  var DEFAULT_CHART_SETTINGS = {
1797
1832
  highLowMarkers: true,
1798
1833
  lastPriceLine: true,
@@ -1803,7 +1838,10 @@ var DEFAULT_CHART_SETTINGS = {
1803
1838
  priceScale: "normal",
1804
1839
  countdown: true,
1805
1840
  upColor: null,
1806
- downColor: null
1841
+ downColor: null,
1842
+ background: null,
1843
+ gridColor: null,
1844
+ textColor: null
1807
1845
  };
1808
1846
  var CHART_TYPES = ["candles", "line", "area"];
1809
1847
  function parseChartState(input) {
@@ -4008,14 +4046,16 @@ var Chart = class {
4008
4046
  }
4009
4047
  resolvePalette() {
4010
4048
  const t = this.theme;
4049
+ const s = this.settingsValue;
4011
4050
  const c = (v) => this.colors.color(v);
4051
+ const muted = s.textColor && /^#[0-9a-f]{6}$/i.test(s.textColor) ? `${s.textColor}99` : null;
4012
4052
  return {
4013
- background: c(t.background),
4014
- text: c(t.text),
4015
- textSecondary: c(t.textSecondary),
4016
- grid: c(t.grid),
4017
- border: c(t.border),
4018
- crosshair: c(t.crosshair),
4053
+ background: c(s.background ?? t.background),
4054
+ text: c(s.textColor ?? t.text),
4055
+ textSecondary: c(muted ?? t.textSecondary),
4056
+ grid: c(s.gridColor ?? t.grid),
4057
+ border: c(s.gridColor ?? t.border),
4058
+ crosshair: c(muted ?? t.crosshair),
4019
4059
  up: c(this.settingsValue.upColor ?? t.up),
4020
4060
  down: c(this.settingsValue.downColor ?? t.down),
4021
4061
  accent: c(t.accent)
@@ -4514,6 +4554,7 @@ function combineDatafeeds(feeds) {
4514
4554
  }
4515
4555
  export {
4516
4556
  BUILTIN_DRAWINGS,
4557
+ CHART_THEMES,
4517
4558
  Chart,
4518
4559
  DEFAULT_CHART_SETTINGS,
4519
4560
  FIB_LEVELS,
@@ -4539,6 +4580,7 @@ export {
4539
4580
  lightTheme,
4540
4581
  maLines,
4541
4582
  macd,
4583
+ matchChartTheme,
4542
4584
  monitorLatency,
4543
4585
  parseChartState,
4544
4586
  priceSource,
@@ -22,7 +22,28 @@ export interface ChartSettings {
22
22
  /** Up/down candle colors; null follows the theme. */
23
23
  upColor: string | null;
24
24
  downColor: string | null;
25
+ /** Chart canvas colors (a theme from CHART_THEMES or your own); null follows the theme. `textColor` must be #rrggbb. */
26
+ background: string | null;
27
+ gridColor: string | null;
28
+ textColor: string | null;
25
29
  }
30
+ /** The settings a chart theme sets. */
31
+ export type ChartThemeColors = Pick<ChartSettings, 'upColor' | 'downColor' | 'background' | 'gridColor' | 'textColor'>;
32
+ export interface ChartThemePreset {
33
+ id: string;
34
+ name: {
35
+ ko: string;
36
+ en: string;
37
+ };
38
+ colors: ChartThemeColors;
39
+ }
40
+ /**
41
+ * Ready-made chart themes for the settings dialog. Applying one sets the five color settings;
42
+ * 'default' clears them so the chart follows the page theme again.
43
+ */
44
+ export declare const CHART_THEMES: readonly ChartThemePreset[];
45
+ /** The preset whose colors `settings` match, if any. */
46
+ export declare function matchChartTheme(settings: ChartSettings): ChartThemePreset | undefined;
26
47
  export declare const DEFAULT_CHART_SETTINGS: ChartSettings;
27
48
  /**
28
49
  * Everything needed to restore a chart layout: symbol, interval, chart type, settings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Canvas charting engine for financial charts",
5
5
  "keywords": [
6
6
  "chart",