hyperprop-charting-library 0.1.140 → 0.1.141
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/hyperprop-charting-library.cjs +130 -0
- package/dist/hyperprop-charting-library.d.ts +52 -1
- package/dist/hyperprop-charting-library.js +128 -0
- package/dist/index.cjs +130 -0
- package/dist/index.d.cts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +128 -0
- package/package.json +1 -1
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
CHART_THEMES: () => CHART_THEMES,
|
|
24
|
+
CHART_THEME_NAMES: () => CHART_THEME_NAMES,
|
|
23
25
|
FIB_DEFAULT_PALETTE: () => FIB_DEFAULT_PALETTE,
|
|
24
26
|
POSITION_DEFAULT_COLORS: () => POSITION_DEFAULT_COLORS,
|
|
25
27
|
SCRIPT_SOURCE_INPUT_VALUES: () => SCRIPT_SOURCE_INPUT_VALUES,
|
|
@@ -2655,6 +2657,88 @@ var compileScriptIndicator = (definition) => {
|
|
|
2655
2657
|
return plugin;
|
|
2656
2658
|
};
|
|
2657
2659
|
|
|
2660
|
+
// src/themes.ts
|
|
2661
|
+
var CHART_THEMES = {
|
|
2662
|
+
dark: {
|
|
2663
|
+
name: "dark",
|
|
2664
|
+
background: "#0f0f0f",
|
|
2665
|
+
upColor: "#089981",
|
|
2666
|
+
downColor: "#f23645",
|
|
2667
|
+
lineColor: "#2962ff",
|
|
2668
|
+
gridColor: "#3c3c3c",
|
|
2669
|
+
gridOpacity: 0.5,
|
|
2670
|
+
axisTextColor: "#dbdbdb",
|
|
2671
|
+
axisLineColor: "#424242",
|
|
2672
|
+
crosshairColor: "#9598a1",
|
|
2673
|
+
crosshairLabelBackground: "#3c3c3c",
|
|
2674
|
+
crosshairLabelText: "#dbdbdb",
|
|
2675
|
+
crosshairLabelBorder: "#5d5d5d",
|
|
2676
|
+
watermarkColor: "rgba(219,219,219,0.06)",
|
|
2677
|
+
indicatorTextColor: "#b2b5be",
|
|
2678
|
+
labelTextColor: "#ffffff",
|
|
2679
|
+
labelBackground: "#1a1a1a"
|
|
2680
|
+
},
|
|
2681
|
+
light: {
|
|
2682
|
+
name: "light",
|
|
2683
|
+
background: "#ffffff",
|
|
2684
|
+
upColor: "#089981",
|
|
2685
|
+
downColor: "#f23645",
|
|
2686
|
+
lineColor: "#2962ff",
|
|
2687
|
+
gridColor: "#d5d5d5",
|
|
2688
|
+
gridOpacity: 0.9,
|
|
2689
|
+
axisTextColor: "#0f0f0f",
|
|
2690
|
+
axisLineColor: "#c3c3c3",
|
|
2691
|
+
crosshairColor: "#787b86",
|
|
2692
|
+
crosshairLabelBackground: "#4b4b4b",
|
|
2693
|
+
crosshairLabelText: "#ffffff",
|
|
2694
|
+
crosshairLabelBorder: "#878787",
|
|
2695
|
+
watermarkColor: "rgba(15,15,15,0.06)",
|
|
2696
|
+
indicatorTextColor: "#4b4b4b",
|
|
2697
|
+
labelTextColor: "#ffffff",
|
|
2698
|
+
labelBackground: "#f0f3fa"
|
|
2699
|
+
},
|
|
2700
|
+
midnight: {
|
|
2701
|
+
name: "midnight",
|
|
2702
|
+
background: "#171717",
|
|
2703
|
+
upColor: "#22ab94",
|
|
2704
|
+
downColor: "#f23645",
|
|
2705
|
+
lineColor: "#2563eb",
|
|
2706
|
+
gridColor: "#2b2f38",
|
|
2707
|
+
gridOpacity: 0.38,
|
|
2708
|
+
axisTextColor: "#dbe4f0",
|
|
2709
|
+
axisLineColor: "#5f646d",
|
|
2710
|
+
crosshairColor: "#94a3b8",
|
|
2711
|
+
crosshairLabelBackground: "#6b6f76",
|
|
2712
|
+
crosshairLabelText: "#e2e8f0",
|
|
2713
|
+
crosshairLabelBorder: "#e2e8f0",
|
|
2714
|
+
watermarkColor: "rgba(226,232,240,0.05)",
|
|
2715
|
+
indicatorTextColor: "#cbd5e1",
|
|
2716
|
+
labelTextColor: "#dbeafe",
|
|
2717
|
+
labelBackground: "#0b1220"
|
|
2718
|
+
},
|
|
2719
|
+
"high-contrast": {
|
|
2720
|
+
name: "high-contrast",
|
|
2721
|
+
background: "#000000",
|
|
2722
|
+
upColor: "#00e5a0",
|
|
2723
|
+
downColor: "#ff4d5e",
|
|
2724
|
+
lineColor: "#4d9fff",
|
|
2725
|
+
gridColor: "#5a5a5a",
|
|
2726
|
+
gridOpacity: 0.7,
|
|
2727
|
+
axisTextColor: "#ffffff",
|
|
2728
|
+
axisLineColor: "#8a8a8a",
|
|
2729
|
+
crosshairColor: "#ffffff",
|
|
2730
|
+
crosshairLabelBackground: "#ffffff",
|
|
2731
|
+
crosshairLabelText: "#000000",
|
|
2732
|
+
crosshairLabelBorder: "#ffffff",
|
|
2733
|
+
watermarkColor: "rgba(255,255,255,0.08)",
|
|
2734
|
+
indicatorTextColor: "#ffffff",
|
|
2735
|
+
labelTextColor: "#000000",
|
|
2736
|
+
labelBackground: "#1a1a1a"
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
var CHART_THEME_NAMES = Object.keys(CHART_THEMES);
|
|
2740
|
+
var resolveTheme = (theme) => typeof theme === "string" ? CHART_THEMES[theme] ?? CHART_THEMES.dark : theme;
|
|
2741
|
+
|
|
2658
2742
|
// src/options.ts
|
|
2659
2743
|
var DEFAULT_GRID_OPTIONS = {
|
|
2660
2744
|
color: "#2b2f38",
|
|
@@ -3097,6 +3181,7 @@ function createChart(element, options = {}) {
|
|
|
3097
3181
|
let keyboardShortcutHandler = null;
|
|
3098
3182
|
let lastSelectionSignature = null;
|
|
3099
3183
|
let magnetMode = "none";
|
|
3184
|
+
let activeThemeName = null;
|
|
3100
3185
|
let priceScaleMode = "linear";
|
|
3101
3186
|
let priceScaleInverted = false;
|
|
3102
3187
|
const PRICE_SCALE_LOG_FLOOR = 1e-9;
|
|
@@ -9609,6 +9694,23 @@ function createChart(element, options = {}) {
|
|
|
9609
9694
|
window.addEventListener("blur", onWindowBlurMagnet);
|
|
9610
9695
|
}
|
|
9611
9696
|
const updateOptions = (nextOptions) => {
|
|
9697
|
+
const THEMED_OPTION_KEYS = [
|
|
9698
|
+
"backgroundColor",
|
|
9699
|
+
"upColor",
|
|
9700
|
+
"downColor",
|
|
9701
|
+
"lineColor",
|
|
9702
|
+
"gridColor",
|
|
9703
|
+
"axisColor",
|
|
9704
|
+
"grid",
|
|
9705
|
+
"axis",
|
|
9706
|
+
"xAxis",
|
|
9707
|
+
"yAxis",
|
|
9708
|
+
"crosshair",
|
|
9709
|
+
"watermark"
|
|
9710
|
+
];
|
|
9711
|
+
if (THEMED_OPTION_KEYS.some((key) => nextOptions[key] !== void 0) || nextOptions.labels?.indicatorTextColor !== void 0) {
|
|
9712
|
+
activeThemeName = null;
|
|
9713
|
+
}
|
|
9612
9714
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
9613
9715
|
const previousWidth = width;
|
|
9614
9716
|
const previousHeight = height;
|
|
@@ -9637,6 +9739,30 @@ function createChart(element, options = {}) {
|
|
|
9637
9739
|
}
|
|
9638
9740
|
scheduleDraw();
|
|
9639
9741
|
};
|
|
9742
|
+
const setTheme = (theme) => {
|
|
9743
|
+
const resolved = resolveTheme(theme);
|
|
9744
|
+
updateOptions({
|
|
9745
|
+
backgroundColor: resolved.background,
|
|
9746
|
+
upColor: resolved.upColor,
|
|
9747
|
+
downColor: resolved.downColor,
|
|
9748
|
+
lineColor: resolved.lineColor,
|
|
9749
|
+
gridColor: resolved.gridColor,
|
|
9750
|
+
grid: { color: resolved.gridColor, opacity: resolved.gridOpacity },
|
|
9751
|
+
axis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9752
|
+
xAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9753
|
+
yAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9754
|
+
crosshair: {
|
|
9755
|
+
color: resolved.crosshairColor,
|
|
9756
|
+
labelBackgroundColor: resolved.crosshairLabelBackground,
|
|
9757
|
+
labelTextColor: resolved.crosshairLabelText,
|
|
9758
|
+
labelBorderColor: resolved.crosshairLabelBorder
|
|
9759
|
+
},
|
|
9760
|
+
watermark: { color: resolved.watermarkColor },
|
|
9761
|
+
labels: { indicatorTextColor: resolved.indicatorTextColor }
|
|
9762
|
+
});
|
|
9763
|
+
activeThemeName = resolved.name;
|
|
9764
|
+
};
|
|
9765
|
+
const getTheme = () => activeThemeName;
|
|
9640
9766
|
const setChartType = (type) => {
|
|
9641
9767
|
if (mergedOptions.chartType === type) {
|
|
9642
9768
|
return;
|
|
@@ -10165,6 +10291,8 @@ function createChart(element, options = {}) {
|
|
|
10165
10291
|
getMagnetMode,
|
|
10166
10292
|
setPriceScale,
|
|
10167
10293
|
getPriceScale,
|
|
10294
|
+
setTheme,
|
|
10295
|
+
getTheme,
|
|
10168
10296
|
setCompareSeries,
|
|
10169
10297
|
addCompareSeries,
|
|
10170
10298
|
removeCompareSeries,
|
|
@@ -10195,6 +10323,8 @@ function createChart(element, options = {}) {
|
|
|
10195
10323
|
}
|
|
10196
10324
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10197
10325
|
0 && (module.exports = {
|
|
10326
|
+
CHART_THEMES,
|
|
10327
|
+
CHART_THEME_NAMES,
|
|
10198
10328
|
FIB_DEFAULT_PALETTE,
|
|
10199
10329
|
POSITION_DEFAULT_COLORS,
|
|
10200
10330
|
SCRIPT_SOURCE_INPUT_VALUES,
|
|
@@ -607,6 +607,35 @@ interface CompareSeriesOptions {
|
|
|
607
607
|
/** Let this series widen the price scale. Default true. */
|
|
608
608
|
includeInAutoScale?: boolean;
|
|
609
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* A complete chart palette. Hosts otherwise configure a dozen colors one by
|
|
612
|
+
* one and re-push them on every light/dark toggle; a theme is that same set as
|
|
613
|
+
* one object, so `setTheme` is a single call.
|
|
614
|
+
*/
|
|
615
|
+
interface ChartTheme {
|
|
616
|
+
name: string;
|
|
617
|
+
background: string;
|
|
618
|
+
upColor: string;
|
|
619
|
+
downColor: string;
|
|
620
|
+
/** Line/area/baseline series color. */
|
|
621
|
+
lineColor: string;
|
|
622
|
+
gridColor: string;
|
|
623
|
+
gridOpacity: number;
|
|
624
|
+
axisTextColor: string;
|
|
625
|
+
axisLineColor: string;
|
|
626
|
+
crosshairColor: string;
|
|
627
|
+
crosshairLabelBackground: string;
|
|
628
|
+
crosshairLabelText: string;
|
|
629
|
+
crosshairLabelBorder: string;
|
|
630
|
+
watermarkColor: string;
|
|
631
|
+
/** Indicator names/values drawn inside the plot and pane legends. */
|
|
632
|
+
indicatorTextColor: string;
|
|
633
|
+
/** Text drawn on colored order/preview pills. */
|
|
634
|
+
labelTextColor: string;
|
|
635
|
+
/** Background for preview labels and pills. */
|
|
636
|
+
labelBackground: string;
|
|
637
|
+
}
|
|
638
|
+
type ChartThemeName = "dark" | "light" | "midnight" | "high-contrast";
|
|
610
639
|
/** Touch ergonomics. Fingers are blunter than a mouse cursor. */
|
|
611
640
|
interface TouchOptions {
|
|
612
641
|
/**
|
|
@@ -818,6 +847,15 @@ interface ChartInstance {
|
|
|
818
847
|
*/
|
|
819
848
|
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
820
849
|
getPriceScale: () => PriceScaleOptions;
|
|
850
|
+
/**
|
|
851
|
+
* Apply a whole palette at once — a built-in preset name or your own
|
|
852
|
+
* `ChartTheme`. Replaces the per-color `updateOptions` juggling hosts do on
|
|
853
|
+
* every light/dark toggle. Anything the theme doesn't cover (order-line
|
|
854
|
+
* colors, drawing defaults) is left alone.
|
|
855
|
+
*/
|
|
856
|
+
setTheme: (theme: ChartThemeName | ChartTheme) => void;
|
|
857
|
+
/** Name of the last applied theme, or null if colors were set by hand. */
|
|
858
|
+
getTheme: () => string | null;
|
|
821
859
|
/**
|
|
822
860
|
* Overlay other instruments on the main pane for comparison. Series are
|
|
823
861
|
* aligned to the main series by timestamp (last known value carries forward
|
|
@@ -1025,6 +1063,19 @@ declare const validateScriptSource: (source: string) => string | null;
|
|
|
1025
1063
|
*/
|
|
1026
1064
|
declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) => IndicatorPlugin;
|
|
1027
1065
|
|
|
1066
|
+
/**
|
|
1067
|
+
* Built-in palettes.
|
|
1068
|
+
*
|
|
1069
|
+
* `dark` and `light` mirror TradingView's own chart colors (sampled from their
|
|
1070
|
+
* rendered canvas), which is what most traders' eyes are calibrated to: the
|
|
1071
|
+
* candle colors stay the same across both and only the surface changes.
|
|
1072
|
+
* `midnight` is Hyperprop's long-standing default, kept as a named preset so
|
|
1073
|
+
* existing setups have something to go back to. `high-contrast` trades
|
|
1074
|
+
* prettiness for legibility on projectors and for low-vision users.
|
|
1075
|
+
*/
|
|
1076
|
+
declare const CHART_THEMES: Record<ChartThemeName, ChartTheme>;
|
|
1077
|
+
declare const CHART_THEME_NAMES: ChartThemeName[];
|
|
1078
|
+
|
|
1028
1079
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
1029
1080
|
|
|
1030
|
-
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
|
1081
|
+
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
|
@@ -2623,6 +2623,88 @@ var compileScriptIndicator = (definition) => {
|
|
|
2623
2623
|
return plugin;
|
|
2624
2624
|
};
|
|
2625
2625
|
|
|
2626
|
+
// src/themes.ts
|
|
2627
|
+
var CHART_THEMES = {
|
|
2628
|
+
dark: {
|
|
2629
|
+
name: "dark",
|
|
2630
|
+
background: "#0f0f0f",
|
|
2631
|
+
upColor: "#089981",
|
|
2632
|
+
downColor: "#f23645",
|
|
2633
|
+
lineColor: "#2962ff",
|
|
2634
|
+
gridColor: "#3c3c3c",
|
|
2635
|
+
gridOpacity: 0.5,
|
|
2636
|
+
axisTextColor: "#dbdbdb",
|
|
2637
|
+
axisLineColor: "#424242",
|
|
2638
|
+
crosshairColor: "#9598a1",
|
|
2639
|
+
crosshairLabelBackground: "#3c3c3c",
|
|
2640
|
+
crosshairLabelText: "#dbdbdb",
|
|
2641
|
+
crosshairLabelBorder: "#5d5d5d",
|
|
2642
|
+
watermarkColor: "rgba(219,219,219,0.06)",
|
|
2643
|
+
indicatorTextColor: "#b2b5be",
|
|
2644
|
+
labelTextColor: "#ffffff",
|
|
2645
|
+
labelBackground: "#1a1a1a"
|
|
2646
|
+
},
|
|
2647
|
+
light: {
|
|
2648
|
+
name: "light",
|
|
2649
|
+
background: "#ffffff",
|
|
2650
|
+
upColor: "#089981",
|
|
2651
|
+
downColor: "#f23645",
|
|
2652
|
+
lineColor: "#2962ff",
|
|
2653
|
+
gridColor: "#d5d5d5",
|
|
2654
|
+
gridOpacity: 0.9,
|
|
2655
|
+
axisTextColor: "#0f0f0f",
|
|
2656
|
+
axisLineColor: "#c3c3c3",
|
|
2657
|
+
crosshairColor: "#787b86",
|
|
2658
|
+
crosshairLabelBackground: "#4b4b4b",
|
|
2659
|
+
crosshairLabelText: "#ffffff",
|
|
2660
|
+
crosshairLabelBorder: "#878787",
|
|
2661
|
+
watermarkColor: "rgba(15,15,15,0.06)",
|
|
2662
|
+
indicatorTextColor: "#4b4b4b",
|
|
2663
|
+
labelTextColor: "#ffffff",
|
|
2664
|
+
labelBackground: "#f0f3fa"
|
|
2665
|
+
},
|
|
2666
|
+
midnight: {
|
|
2667
|
+
name: "midnight",
|
|
2668
|
+
background: "#171717",
|
|
2669
|
+
upColor: "#22ab94",
|
|
2670
|
+
downColor: "#f23645",
|
|
2671
|
+
lineColor: "#2563eb",
|
|
2672
|
+
gridColor: "#2b2f38",
|
|
2673
|
+
gridOpacity: 0.38,
|
|
2674
|
+
axisTextColor: "#dbe4f0",
|
|
2675
|
+
axisLineColor: "#5f646d",
|
|
2676
|
+
crosshairColor: "#94a3b8",
|
|
2677
|
+
crosshairLabelBackground: "#6b6f76",
|
|
2678
|
+
crosshairLabelText: "#e2e8f0",
|
|
2679
|
+
crosshairLabelBorder: "#e2e8f0",
|
|
2680
|
+
watermarkColor: "rgba(226,232,240,0.05)",
|
|
2681
|
+
indicatorTextColor: "#cbd5e1",
|
|
2682
|
+
labelTextColor: "#dbeafe",
|
|
2683
|
+
labelBackground: "#0b1220"
|
|
2684
|
+
},
|
|
2685
|
+
"high-contrast": {
|
|
2686
|
+
name: "high-contrast",
|
|
2687
|
+
background: "#000000",
|
|
2688
|
+
upColor: "#00e5a0",
|
|
2689
|
+
downColor: "#ff4d5e",
|
|
2690
|
+
lineColor: "#4d9fff",
|
|
2691
|
+
gridColor: "#5a5a5a",
|
|
2692
|
+
gridOpacity: 0.7,
|
|
2693
|
+
axisTextColor: "#ffffff",
|
|
2694
|
+
axisLineColor: "#8a8a8a",
|
|
2695
|
+
crosshairColor: "#ffffff",
|
|
2696
|
+
crosshairLabelBackground: "#ffffff",
|
|
2697
|
+
crosshairLabelText: "#000000",
|
|
2698
|
+
crosshairLabelBorder: "#ffffff",
|
|
2699
|
+
watermarkColor: "rgba(255,255,255,0.08)",
|
|
2700
|
+
indicatorTextColor: "#ffffff",
|
|
2701
|
+
labelTextColor: "#000000",
|
|
2702
|
+
labelBackground: "#1a1a1a"
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
var CHART_THEME_NAMES = Object.keys(CHART_THEMES);
|
|
2706
|
+
var resolveTheme = (theme) => typeof theme === "string" ? CHART_THEMES[theme] ?? CHART_THEMES.dark : theme;
|
|
2707
|
+
|
|
2626
2708
|
// src/options.ts
|
|
2627
2709
|
var DEFAULT_GRID_OPTIONS = {
|
|
2628
2710
|
color: "#2b2f38",
|
|
@@ -3065,6 +3147,7 @@ function createChart(element, options = {}) {
|
|
|
3065
3147
|
let keyboardShortcutHandler = null;
|
|
3066
3148
|
let lastSelectionSignature = null;
|
|
3067
3149
|
let magnetMode = "none";
|
|
3150
|
+
let activeThemeName = null;
|
|
3068
3151
|
let priceScaleMode = "linear";
|
|
3069
3152
|
let priceScaleInverted = false;
|
|
3070
3153
|
const PRICE_SCALE_LOG_FLOOR = 1e-9;
|
|
@@ -9577,6 +9660,23 @@ function createChart(element, options = {}) {
|
|
|
9577
9660
|
window.addEventListener("blur", onWindowBlurMagnet);
|
|
9578
9661
|
}
|
|
9579
9662
|
const updateOptions = (nextOptions) => {
|
|
9663
|
+
const THEMED_OPTION_KEYS = [
|
|
9664
|
+
"backgroundColor",
|
|
9665
|
+
"upColor",
|
|
9666
|
+
"downColor",
|
|
9667
|
+
"lineColor",
|
|
9668
|
+
"gridColor",
|
|
9669
|
+
"axisColor",
|
|
9670
|
+
"grid",
|
|
9671
|
+
"axis",
|
|
9672
|
+
"xAxis",
|
|
9673
|
+
"yAxis",
|
|
9674
|
+
"crosshair",
|
|
9675
|
+
"watermark"
|
|
9676
|
+
];
|
|
9677
|
+
if (THEMED_OPTION_KEYS.some((key) => nextOptions[key] !== void 0) || nextOptions.labels?.indicatorTextColor !== void 0) {
|
|
9678
|
+
activeThemeName = null;
|
|
9679
|
+
}
|
|
9580
9680
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
9581
9681
|
const previousWidth = width;
|
|
9582
9682
|
const previousHeight = height;
|
|
@@ -9605,6 +9705,30 @@ function createChart(element, options = {}) {
|
|
|
9605
9705
|
}
|
|
9606
9706
|
scheduleDraw();
|
|
9607
9707
|
};
|
|
9708
|
+
const setTheme = (theme) => {
|
|
9709
|
+
const resolved = resolveTheme(theme);
|
|
9710
|
+
updateOptions({
|
|
9711
|
+
backgroundColor: resolved.background,
|
|
9712
|
+
upColor: resolved.upColor,
|
|
9713
|
+
downColor: resolved.downColor,
|
|
9714
|
+
lineColor: resolved.lineColor,
|
|
9715
|
+
gridColor: resolved.gridColor,
|
|
9716
|
+
grid: { color: resolved.gridColor, opacity: resolved.gridOpacity },
|
|
9717
|
+
axis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9718
|
+
xAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9719
|
+
yAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9720
|
+
crosshair: {
|
|
9721
|
+
color: resolved.crosshairColor,
|
|
9722
|
+
labelBackgroundColor: resolved.crosshairLabelBackground,
|
|
9723
|
+
labelTextColor: resolved.crosshairLabelText,
|
|
9724
|
+
labelBorderColor: resolved.crosshairLabelBorder
|
|
9725
|
+
},
|
|
9726
|
+
watermark: { color: resolved.watermarkColor },
|
|
9727
|
+
labels: { indicatorTextColor: resolved.indicatorTextColor }
|
|
9728
|
+
});
|
|
9729
|
+
activeThemeName = resolved.name;
|
|
9730
|
+
};
|
|
9731
|
+
const getTheme = () => activeThemeName;
|
|
9608
9732
|
const setChartType = (type) => {
|
|
9609
9733
|
if (mergedOptions.chartType === type) {
|
|
9610
9734
|
return;
|
|
@@ -10133,6 +10257,8 @@ function createChart(element, options = {}) {
|
|
|
10133
10257
|
getMagnetMode,
|
|
10134
10258
|
setPriceScale,
|
|
10135
10259
|
getPriceScale,
|
|
10260
|
+
setTheme,
|
|
10261
|
+
getTheme,
|
|
10136
10262
|
setCompareSeries,
|
|
10137
10263
|
addCompareSeries,
|
|
10138
10264
|
removeCompareSeries,
|
|
@@ -10162,6 +10288,8 @@ function createChart(element, options = {}) {
|
|
|
10162
10288
|
};
|
|
10163
10289
|
}
|
|
10164
10290
|
export {
|
|
10291
|
+
CHART_THEMES,
|
|
10292
|
+
CHART_THEME_NAMES,
|
|
10165
10293
|
FIB_DEFAULT_PALETTE,
|
|
10166
10294
|
POSITION_DEFAULT_COLORS,
|
|
10167
10295
|
SCRIPT_SOURCE_INPUT_VALUES,
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
CHART_THEMES: () => CHART_THEMES,
|
|
24
|
+
CHART_THEME_NAMES: () => CHART_THEME_NAMES,
|
|
23
25
|
FIB_DEFAULT_PALETTE: () => FIB_DEFAULT_PALETTE,
|
|
24
26
|
POSITION_DEFAULT_COLORS: () => POSITION_DEFAULT_COLORS,
|
|
25
27
|
SCRIPT_SOURCE_INPUT_VALUES: () => SCRIPT_SOURCE_INPUT_VALUES,
|
|
@@ -2655,6 +2657,88 @@ var compileScriptIndicator = (definition) => {
|
|
|
2655
2657
|
return plugin;
|
|
2656
2658
|
};
|
|
2657
2659
|
|
|
2660
|
+
// src/themes.ts
|
|
2661
|
+
var CHART_THEMES = {
|
|
2662
|
+
dark: {
|
|
2663
|
+
name: "dark",
|
|
2664
|
+
background: "#0f0f0f",
|
|
2665
|
+
upColor: "#089981",
|
|
2666
|
+
downColor: "#f23645",
|
|
2667
|
+
lineColor: "#2962ff",
|
|
2668
|
+
gridColor: "#3c3c3c",
|
|
2669
|
+
gridOpacity: 0.5,
|
|
2670
|
+
axisTextColor: "#dbdbdb",
|
|
2671
|
+
axisLineColor: "#424242",
|
|
2672
|
+
crosshairColor: "#9598a1",
|
|
2673
|
+
crosshairLabelBackground: "#3c3c3c",
|
|
2674
|
+
crosshairLabelText: "#dbdbdb",
|
|
2675
|
+
crosshairLabelBorder: "#5d5d5d",
|
|
2676
|
+
watermarkColor: "rgba(219,219,219,0.06)",
|
|
2677
|
+
indicatorTextColor: "#b2b5be",
|
|
2678
|
+
labelTextColor: "#ffffff",
|
|
2679
|
+
labelBackground: "#1a1a1a"
|
|
2680
|
+
},
|
|
2681
|
+
light: {
|
|
2682
|
+
name: "light",
|
|
2683
|
+
background: "#ffffff",
|
|
2684
|
+
upColor: "#089981",
|
|
2685
|
+
downColor: "#f23645",
|
|
2686
|
+
lineColor: "#2962ff",
|
|
2687
|
+
gridColor: "#d5d5d5",
|
|
2688
|
+
gridOpacity: 0.9,
|
|
2689
|
+
axisTextColor: "#0f0f0f",
|
|
2690
|
+
axisLineColor: "#c3c3c3",
|
|
2691
|
+
crosshairColor: "#787b86",
|
|
2692
|
+
crosshairLabelBackground: "#4b4b4b",
|
|
2693
|
+
crosshairLabelText: "#ffffff",
|
|
2694
|
+
crosshairLabelBorder: "#878787",
|
|
2695
|
+
watermarkColor: "rgba(15,15,15,0.06)",
|
|
2696
|
+
indicatorTextColor: "#4b4b4b",
|
|
2697
|
+
labelTextColor: "#ffffff",
|
|
2698
|
+
labelBackground: "#f0f3fa"
|
|
2699
|
+
},
|
|
2700
|
+
midnight: {
|
|
2701
|
+
name: "midnight",
|
|
2702
|
+
background: "#171717",
|
|
2703
|
+
upColor: "#22ab94",
|
|
2704
|
+
downColor: "#f23645",
|
|
2705
|
+
lineColor: "#2563eb",
|
|
2706
|
+
gridColor: "#2b2f38",
|
|
2707
|
+
gridOpacity: 0.38,
|
|
2708
|
+
axisTextColor: "#dbe4f0",
|
|
2709
|
+
axisLineColor: "#5f646d",
|
|
2710
|
+
crosshairColor: "#94a3b8",
|
|
2711
|
+
crosshairLabelBackground: "#6b6f76",
|
|
2712
|
+
crosshairLabelText: "#e2e8f0",
|
|
2713
|
+
crosshairLabelBorder: "#e2e8f0",
|
|
2714
|
+
watermarkColor: "rgba(226,232,240,0.05)",
|
|
2715
|
+
indicatorTextColor: "#cbd5e1",
|
|
2716
|
+
labelTextColor: "#dbeafe",
|
|
2717
|
+
labelBackground: "#0b1220"
|
|
2718
|
+
},
|
|
2719
|
+
"high-contrast": {
|
|
2720
|
+
name: "high-contrast",
|
|
2721
|
+
background: "#000000",
|
|
2722
|
+
upColor: "#00e5a0",
|
|
2723
|
+
downColor: "#ff4d5e",
|
|
2724
|
+
lineColor: "#4d9fff",
|
|
2725
|
+
gridColor: "#5a5a5a",
|
|
2726
|
+
gridOpacity: 0.7,
|
|
2727
|
+
axisTextColor: "#ffffff",
|
|
2728
|
+
axisLineColor: "#8a8a8a",
|
|
2729
|
+
crosshairColor: "#ffffff",
|
|
2730
|
+
crosshairLabelBackground: "#ffffff",
|
|
2731
|
+
crosshairLabelText: "#000000",
|
|
2732
|
+
crosshairLabelBorder: "#ffffff",
|
|
2733
|
+
watermarkColor: "rgba(255,255,255,0.08)",
|
|
2734
|
+
indicatorTextColor: "#ffffff",
|
|
2735
|
+
labelTextColor: "#000000",
|
|
2736
|
+
labelBackground: "#1a1a1a"
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
var CHART_THEME_NAMES = Object.keys(CHART_THEMES);
|
|
2740
|
+
var resolveTheme = (theme) => typeof theme === "string" ? CHART_THEMES[theme] ?? CHART_THEMES.dark : theme;
|
|
2741
|
+
|
|
2658
2742
|
// src/options.ts
|
|
2659
2743
|
var DEFAULT_GRID_OPTIONS = {
|
|
2660
2744
|
color: "#2b2f38",
|
|
@@ -3097,6 +3181,7 @@ function createChart(element, options = {}) {
|
|
|
3097
3181
|
let keyboardShortcutHandler = null;
|
|
3098
3182
|
let lastSelectionSignature = null;
|
|
3099
3183
|
let magnetMode = "none";
|
|
3184
|
+
let activeThemeName = null;
|
|
3100
3185
|
let priceScaleMode = "linear";
|
|
3101
3186
|
let priceScaleInverted = false;
|
|
3102
3187
|
const PRICE_SCALE_LOG_FLOOR = 1e-9;
|
|
@@ -9609,6 +9694,23 @@ function createChart(element, options = {}) {
|
|
|
9609
9694
|
window.addEventListener("blur", onWindowBlurMagnet);
|
|
9610
9695
|
}
|
|
9611
9696
|
const updateOptions = (nextOptions) => {
|
|
9697
|
+
const THEMED_OPTION_KEYS = [
|
|
9698
|
+
"backgroundColor",
|
|
9699
|
+
"upColor",
|
|
9700
|
+
"downColor",
|
|
9701
|
+
"lineColor",
|
|
9702
|
+
"gridColor",
|
|
9703
|
+
"axisColor",
|
|
9704
|
+
"grid",
|
|
9705
|
+
"axis",
|
|
9706
|
+
"xAxis",
|
|
9707
|
+
"yAxis",
|
|
9708
|
+
"crosshair",
|
|
9709
|
+
"watermark"
|
|
9710
|
+
];
|
|
9711
|
+
if (THEMED_OPTION_KEYS.some((key) => nextOptions[key] !== void 0) || nextOptions.labels?.indicatorTextColor !== void 0) {
|
|
9712
|
+
activeThemeName = null;
|
|
9713
|
+
}
|
|
9612
9714
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
9613
9715
|
const previousWidth = width;
|
|
9614
9716
|
const previousHeight = height;
|
|
@@ -9637,6 +9739,30 @@ function createChart(element, options = {}) {
|
|
|
9637
9739
|
}
|
|
9638
9740
|
scheduleDraw();
|
|
9639
9741
|
};
|
|
9742
|
+
const setTheme = (theme) => {
|
|
9743
|
+
const resolved = resolveTheme(theme);
|
|
9744
|
+
updateOptions({
|
|
9745
|
+
backgroundColor: resolved.background,
|
|
9746
|
+
upColor: resolved.upColor,
|
|
9747
|
+
downColor: resolved.downColor,
|
|
9748
|
+
lineColor: resolved.lineColor,
|
|
9749
|
+
gridColor: resolved.gridColor,
|
|
9750
|
+
grid: { color: resolved.gridColor, opacity: resolved.gridOpacity },
|
|
9751
|
+
axis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9752
|
+
xAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9753
|
+
yAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9754
|
+
crosshair: {
|
|
9755
|
+
color: resolved.crosshairColor,
|
|
9756
|
+
labelBackgroundColor: resolved.crosshairLabelBackground,
|
|
9757
|
+
labelTextColor: resolved.crosshairLabelText,
|
|
9758
|
+
labelBorderColor: resolved.crosshairLabelBorder
|
|
9759
|
+
},
|
|
9760
|
+
watermark: { color: resolved.watermarkColor },
|
|
9761
|
+
labels: { indicatorTextColor: resolved.indicatorTextColor }
|
|
9762
|
+
});
|
|
9763
|
+
activeThemeName = resolved.name;
|
|
9764
|
+
};
|
|
9765
|
+
const getTheme = () => activeThemeName;
|
|
9640
9766
|
const setChartType = (type) => {
|
|
9641
9767
|
if (mergedOptions.chartType === type) {
|
|
9642
9768
|
return;
|
|
@@ -10165,6 +10291,8 @@ function createChart(element, options = {}) {
|
|
|
10165
10291
|
getMagnetMode,
|
|
10166
10292
|
setPriceScale,
|
|
10167
10293
|
getPriceScale,
|
|
10294
|
+
setTheme,
|
|
10295
|
+
getTheme,
|
|
10168
10296
|
setCompareSeries,
|
|
10169
10297
|
addCompareSeries,
|
|
10170
10298
|
removeCompareSeries,
|
|
@@ -10195,6 +10323,8 @@ function createChart(element, options = {}) {
|
|
|
10195
10323
|
}
|
|
10196
10324
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10197
10325
|
0 && (module.exports = {
|
|
10326
|
+
CHART_THEMES,
|
|
10327
|
+
CHART_THEME_NAMES,
|
|
10198
10328
|
FIB_DEFAULT_PALETTE,
|
|
10199
10329
|
POSITION_DEFAULT_COLORS,
|
|
10200
10330
|
SCRIPT_SOURCE_INPUT_VALUES,
|
package/dist/index.d.cts
CHANGED
|
@@ -607,6 +607,35 @@ interface CompareSeriesOptions {
|
|
|
607
607
|
/** Let this series widen the price scale. Default true. */
|
|
608
608
|
includeInAutoScale?: boolean;
|
|
609
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* A complete chart palette. Hosts otherwise configure a dozen colors one by
|
|
612
|
+
* one and re-push them on every light/dark toggle; a theme is that same set as
|
|
613
|
+
* one object, so `setTheme` is a single call.
|
|
614
|
+
*/
|
|
615
|
+
interface ChartTheme {
|
|
616
|
+
name: string;
|
|
617
|
+
background: string;
|
|
618
|
+
upColor: string;
|
|
619
|
+
downColor: string;
|
|
620
|
+
/** Line/area/baseline series color. */
|
|
621
|
+
lineColor: string;
|
|
622
|
+
gridColor: string;
|
|
623
|
+
gridOpacity: number;
|
|
624
|
+
axisTextColor: string;
|
|
625
|
+
axisLineColor: string;
|
|
626
|
+
crosshairColor: string;
|
|
627
|
+
crosshairLabelBackground: string;
|
|
628
|
+
crosshairLabelText: string;
|
|
629
|
+
crosshairLabelBorder: string;
|
|
630
|
+
watermarkColor: string;
|
|
631
|
+
/** Indicator names/values drawn inside the plot and pane legends. */
|
|
632
|
+
indicatorTextColor: string;
|
|
633
|
+
/** Text drawn on colored order/preview pills. */
|
|
634
|
+
labelTextColor: string;
|
|
635
|
+
/** Background for preview labels and pills. */
|
|
636
|
+
labelBackground: string;
|
|
637
|
+
}
|
|
638
|
+
type ChartThemeName = "dark" | "light" | "midnight" | "high-contrast";
|
|
610
639
|
/** Touch ergonomics. Fingers are blunter than a mouse cursor. */
|
|
611
640
|
interface TouchOptions {
|
|
612
641
|
/**
|
|
@@ -818,6 +847,15 @@ interface ChartInstance {
|
|
|
818
847
|
*/
|
|
819
848
|
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
820
849
|
getPriceScale: () => PriceScaleOptions;
|
|
850
|
+
/**
|
|
851
|
+
* Apply a whole palette at once — a built-in preset name or your own
|
|
852
|
+
* `ChartTheme`. Replaces the per-color `updateOptions` juggling hosts do on
|
|
853
|
+
* every light/dark toggle. Anything the theme doesn't cover (order-line
|
|
854
|
+
* colors, drawing defaults) is left alone.
|
|
855
|
+
*/
|
|
856
|
+
setTheme: (theme: ChartThemeName | ChartTheme) => void;
|
|
857
|
+
/** Name of the last applied theme, or null if colors were set by hand. */
|
|
858
|
+
getTheme: () => string | null;
|
|
821
859
|
/**
|
|
822
860
|
* Overlay other instruments on the main pane for comparison. Series are
|
|
823
861
|
* aligned to the main series by timestamp (last known value carries forward
|
|
@@ -1025,6 +1063,19 @@ declare const validateScriptSource: (source: string) => string | null;
|
|
|
1025
1063
|
*/
|
|
1026
1064
|
declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) => IndicatorPlugin;
|
|
1027
1065
|
|
|
1066
|
+
/**
|
|
1067
|
+
* Built-in palettes.
|
|
1068
|
+
*
|
|
1069
|
+
* `dark` and `light` mirror TradingView's own chart colors (sampled from their
|
|
1070
|
+
* rendered canvas), which is what most traders' eyes are calibrated to: the
|
|
1071
|
+
* candle colors stay the same across both and only the surface changes.
|
|
1072
|
+
* `midnight` is Hyperprop's long-standing default, kept as a named preset so
|
|
1073
|
+
* existing setups have something to go back to. `high-contrast` trades
|
|
1074
|
+
* prettiness for legibility on projectors and for low-vision users.
|
|
1075
|
+
*/
|
|
1076
|
+
declare const CHART_THEMES: Record<ChartThemeName, ChartTheme>;
|
|
1077
|
+
declare const CHART_THEME_NAMES: ChartThemeName[];
|
|
1078
|
+
|
|
1028
1079
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
1029
1080
|
|
|
1030
|
-
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
|
1081
|
+
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -607,6 +607,35 @@ interface CompareSeriesOptions {
|
|
|
607
607
|
/** Let this series widen the price scale. Default true. */
|
|
608
608
|
includeInAutoScale?: boolean;
|
|
609
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* A complete chart palette. Hosts otherwise configure a dozen colors one by
|
|
612
|
+
* one and re-push them on every light/dark toggle; a theme is that same set as
|
|
613
|
+
* one object, so `setTheme` is a single call.
|
|
614
|
+
*/
|
|
615
|
+
interface ChartTheme {
|
|
616
|
+
name: string;
|
|
617
|
+
background: string;
|
|
618
|
+
upColor: string;
|
|
619
|
+
downColor: string;
|
|
620
|
+
/** Line/area/baseline series color. */
|
|
621
|
+
lineColor: string;
|
|
622
|
+
gridColor: string;
|
|
623
|
+
gridOpacity: number;
|
|
624
|
+
axisTextColor: string;
|
|
625
|
+
axisLineColor: string;
|
|
626
|
+
crosshairColor: string;
|
|
627
|
+
crosshairLabelBackground: string;
|
|
628
|
+
crosshairLabelText: string;
|
|
629
|
+
crosshairLabelBorder: string;
|
|
630
|
+
watermarkColor: string;
|
|
631
|
+
/** Indicator names/values drawn inside the plot and pane legends. */
|
|
632
|
+
indicatorTextColor: string;
|
|
633
|
+
/** Text drawn on colored order/preview pills. */
|
|
634
|
+
labelTextColor: string;
|
|
635
|
+
/** Background for preview labels and pills. */
|
|
636
|
+
labelBackground: string;
|
|
637
|
+
}
|
|
638
|
+
type ChartThemeName = "dark" | "light" | "midnight" | "high-contrast";
|
|
610
639
|
/** Touch ergonomics. Fingers are blunter than a mouse cursor. */
|
|
611
640
|
interface TouchOptions {
|
|
612
641
|
/**
|
|
@@ -818,6 +847,15 @@ interface ChartInstance {
|
|
|
818
847
|
*/
|
|
819
848
|
setPriceScale: (options: Partial<PriceScaleOptions>) => void;
|
|
820
849
|
getPriceScale: () => PriceScaleOptions;
|
|
850
|
+
/**
|
|
851
|
+
* Apply a whole palette at once — a built-in preset name or your own
|
|
852
|
+
* `ChartTheme`. Replaces the per-color `updateOptions` juggling hosts do on
|
|
853
|
+
* every light/dark toggle. Anything the theme doesn't cover (order-line
|
|
854
|
+
* colors, drawing defaults) is left alone.
|
|
855
|
+
*/
|
|
856
|
+
setTheme: (theme: ChartThemeName | ChartTheme) => void;
|
|
857
|
+
/** Name of the last applied theme, or null if colors were set by hand. */
|
|
858
|
+
getTheme: () => string | null;
|
|
821
859
|
/**
|
|
822
860
|
* Overlay other instruments on the main pane for comparison. Series are
|
|
823
861
|
* aligned to the main series by timestamp (last known value carries forward
|
|
@@ -1025,6 +1063,19 @@ declare const validateScriptSource: (source: string) => string | null;
|
|
|
1025
1063
|
*/
|
|
1026
1064
|
declare const compileScriptIndicator: (definition: ScriptIndicatorDefinition) => IndicatorPlugin;
|
|
1027
1065
|
|
|
1066
|
+
/**
|
|
1067
|
+
* Built-in palettes.
|
|
1068
|
+
*
|
|
1069
|
+
* `dark` and `light` mirror TradingView's own chart colors (sampled from their
|
|
1070
|
+
* rendered canvas), which is what most traders' eyes are calibrated to: the
|
|
1071
|
+
* candle colors stay the same across both and only the surface changes.
|
|
1072
|
+
* `midnight` is Hyperprop's long-standing default, kept as a named preset so
|
|
1073
|
+
* existing setups have something to go back to. `high-contrast` trades
|
|
1074
|
+
* prettiness for legibility on projectors and for low-vision users.
|
|
1075
|
+
*/
|
|
1076
|
+
declare const CHART_THEMES: Record<ChartThemeName, ChartTheme>;
|
|
1077
|
+
declare const CHART_THEME_NAMES: ChartThemeName[];
|
|
1078
|
+
|
|
1028
1079
|
declare function createChart(element: HTMLElement, options?: ChartOptions): ChartInstance;
|
|
1029
1080
|
|
|
1030
|
-
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
|
1081
|
+
export { type AccessibilityOptions, type AxisOptions, type BuiltInIndicatorInfo, CHART_THEMES, CHART_THEME_NAMES, type ChartClickEvent, type ChartContextMenuEvent, type ChartContextMenuRegion, type ChartDatafeed, type ChartInstance, type ChartKeyboardAction, type ChartKeyboardShortcutEvent, type ChartLongPressEvent, type ChartOptions, type ChartSavedState, type ChartTheme, type ChartThemeName, type ChartType, type CompareSeriesOptions, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairPriceActionEvent, type DashPatternOptions, type DatafeedBarsRequest, type DatafeedOptions, type DownsamplingOptions, type DrawingBounds, type DrawingDefaults, type DrawingHoverEvent, type DrawingObjectOptions, type DrawingPoint, type DrawingSelectEvent, type DrawingSelectionChangeEvent, type DrawingToolType, FIB_DEFAULT_PALETTE, type GridOptions, type IndicatorInstanceOptions, type IndicatorPane, type IndicatorPaneActionEvent, type IndicatorPaneAxisOptions, type IndicatorPaneGuideLine, type IndicatorPaneHeightChangeEvent, type IndicatorPaneRenderInfo, type IndicatorPaneValue, type IndicatorPaneValueLabel, type IndicatorPlugin, type IndicatorRenderContext, type KeyboardOptions, type LabelsOptions, type OhlcDataPoint, type OrderActionButton, type OrderActionEvent, type OrderLineOptions, POSITION_DEFAULT_COLORS, type PriceLineOptions, type PriceScaleMode, type PriceScaleOptions, SCRIPT_SOURCE_INPUT_VALUES, type ScriptComputeResult, type ScriptIndicatorDefinition, type ScriptIndicatorInputDef, type ScriptInputHelper, type ScriptInputOptions, type ScriptPlotSpec, type TickerLineOptions, type TouchOptions, type TradeMarkerOptions, type ViewportState, type WatermarkOptions, compileScriptIndicator, createChart, extractScriptInputs, validateScriptSource };
|
package/dist/index.js
CHANGED
|
@@ -2623,6 +2623,88 @@ var compileScriptIndicator = (definition) => {
|
|
|
2623
2623
|
return plugin;
|
|
2624
2624
|
};
|
|
2625
2625
|
|
|
2626
|
+
// src/themes.ts
|
|
2627
|
+
var CHART_THEMES = {
|
|
2628
|
+
dark: {
|
|
2629
|
+
name: "dark",
|
|
2630
|
+
background: "#0f0f0f",
|
|
2631
|
+
upColor: "#089981",
|
|
2632
|
+
downColor: "#f23645",
|
|
2633
|
+
lineColor: "#2962ff",
|
|
2634
|
+
gridColor: "#3c3c3c",
|
|
2635
|
+
gridOpacity: 0.5,
|
|
2636
|
+
axisTextColor: "#dbdbdb",
|
|
2637
|
+
axisLineColor: "#424242",
|
|
2638
|
+
crosshairColor: "#9598a1",
|
|
2639
|
+
crosshairLabelBackground: "#3c3c3c",
|
|
2640
|
+
crosshairLabelText: "#dbdbdb",
|
|
2641
|
+
crosshairLabelBorder: "#5d5d5d",
|
|
2642
|
+
watermarkColor: "rgba(219,219,219,0.06)",
|
|
2643
|
+
indicatorTextColor: "#b2b5be",
|
|
2644
|
+
labelTextColor: "#ffffff",
|
|
2645
|
+
labelBackground: "#1a1a1a"
|
|
2646
|
+
},
|
|
2647
|
+
light: {
|
|
2648
|
+
name: "light",
|
|
2649
|
+
background: "#ffffff",
|
|
2650
|
+
upColor: "#089981",
|
|
2651
|
+
downColor: "#f23645",
|
|
2652
|
+
lineColor: "#2962ff",
|
|
2653
|
+
gridColor: "#d5d5d5",
|
|
2654
|
+
gridOpacity: 0.9,
|
|
2655
|
+
axisTextColor: "#0f0f0f",
|
|
2656
|
+
axisLineColor: "#c3c3c3",
|
|
2657
|
+
crosshairColor: "#787b86",
|
|
2658
|
+
crosshairLabelBackground: "#4b4b4b",
|
|
2659
|
+
crosshairLabelText: "#ffffff",
|
|
2660
|
+
crosshairLabelBorder: "#878787",
|
|
2661
|
+
watermarkColor: "rgba(15,15,15,0.06)",
|
|
2662
|
+
indicatorTextColor: "#4b4b4b",
|
|
2663
|
+
labelTextColor: "#ffffff",
|
|
2664
|
+
labelBackground: "#f0f3fa"
|
|
2665
|
+
},
|
|
2666
|
+
midnight: {
|
|
2667
|
+
name: "midnight",
|
|
2668
|
+
background: "#171717",
|
|
2669
|
+
upColor: "#22ab94",
|
|
2670
|
+
downColor: "#f23645",
|
|
2671
|
+
lineColor: "#2563eb",
|
|
2672
|
+
gridColor: "#2b2f38",
|
|
2673
|
+
gridOpacity: 0.38,
|
|
2674
|
+
axisTextColor: "#dbe4f0",
|
|
2675
|
+
axisLineColor: "#5f646d",
|
|
2676
|
+
crosshairColor: "#94a3b8",
|
|
2677
|
+
crosshairLabelBackground: "#6b6f76",
|
|
2678
|
+
crosshairLabelText: "#e2e8f0",
|
|
2679
|
+
crosshairLabelBorder: "#e2e8f0",
|
|
2680
|
+
watermarkColor: "rgba(226,232,240,0.05)",
|
|
2681
|
+
indicatorTextColor: "#cbd5e1",
|
|
2682
|
+
labelTextColor: "#dbeafe",
|
|
2683
|
+
labelBackground: "#0b1220"
|
|
2684
|
+
},
|
|
2685
|
+
"high-contrast": {
|
|
2686
|
+
name: "high-contrast",
|
|
2687
|
+
background: "#000000",
|
|
2688
|
+
upColor: "#00e5a0",
|
|
2689
|
+
downColor: "#ff4d5e",
|
|
2690
|
+
lineColor: "#4d9fff",
|
|
2691
|
+
gridColor: "#5a5a5a",
|
|
2692
|
+
gridOpacity: 0.7,
|
|
2693
|
+
axisTextColor: "#ffffff",
|
|
2694
|
+
axisLineColor: "#8a8a8a",
|
|
2695
|
+
crosshairColor: "#ffffff",
|
|
2696
|
+
crosshairLabelBackground: "#ffffff",
|
|
2697
|
+
crosshairLabelText: "#000000",
|
|
2698
|
+
crosshairLabelBorder: "#ffffff",
|
|
2699
|
+
watermarkColor: "rgba(255,255,255,0.08)",
|
|
2700
|
+
indicatorTextColor: "#ffffff",
|
|
2701
|
+
labelTextColor: "#000000",
|
|
2702
|
+
labelBackground: "#1a1a1a"
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
var CHART_THEME_NAMES = Object.keys(CHART_THEMES);
|
|
2706
|
+
var resolveTheme = (theme) => typeof theme === "string" ? CHART_THEMES[theme] ?? CHART_THEMES.dark : theme;
|
|
2707
|
+
|
|
2626
2708
|
// src/options.ts
|
|
2627
2709
|
var DEFAULT_GRID_OPTIONS = {
|
|
2628
2710
|
color: "#2b2f38",
|
|
@@ -3065,6 +3147,7 @@ function createChart(element, options = {}) {
|
|
|
3065
3147
|
let keyboardShortcutHandler = null;
|
|
3066
3148
|
let lastSelectionSignature = null;
|
|
3067
3149
|
let magnetMode = "none";
|
|
3150
|
+
let activeThemeName = null;
|
|
3068
3151
|
let priceScaleMode = "linear";
|
|
3069
3152
|
let priceScaleInverted = false;
|
|
3070
3153
|
const PRICE_SCALE_LOG_FLOOR = 1e-9;
|
|
@@ -9577,6 +9660,23 @@ function createChart(element, options = {}) {
|
|
|
9577
9660
|
window.addEventListener("blur", onWindowBlurMagnet);
|
|
9578
9661
|
}
|
|
9579
9662
|
const updateOptions = (nextOptions) => {
|
|
9663
|
+
const THEMED_OPTION_KEYS = [
|
|
9664
|
+
"backgroundColor",
|
|
9665
|
+
"upColor",
|
|
9666
|
+
"downColor",
|
|
9667
|
+
"lineColor",
|
|
9668
|
+
"gridColor",
|
|
9669
|
+
"axisColor",
|
|
9670
|
+
"grid",
|
|
9671
|
+
"axis",
|
|
9672
|
+
"xAxis",
|
|
9673
|
+
"yAxis",
|
|
9674
|
+
"crosshair",
|
|
9675
|
+
"watermark"
|
|
9676
|
+
];
|
|
9677
|
+
if (THEMED_OPTION_KEYS.some((key) => nextOptions[key] !== void 0) || nextOptions.labels?.indicatorTextColor !== void 0) {
|
|
9678
|
+
activeThemeName = null;
|
|
9679
|
+
}
|
|
9580
9680
|
const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
|
|
9581
9681
|
const previousWidth = width;
|
|
9582
9682
|
const previousHeight = height;
|
|
@@ -9605,6 +9705,30 @@ function createChart(element, options = {}) {
|
|
|
9605
9705
|
}
|
|
9606
9706
|
scheduleDraw();
|
|
9607
9707
|
};
|
|
9708
|
+
const setTheme = (theme) => {
|
|
9709
|
+
const resolved = resolveTheme(theme);
|
|
9710
|
+
updateOptions({
|
|
9711
|
+
backgroundColor: resolved.background,
|
|
9712
|
+
upColor: resolved.upColor,
|
|
9713
|
+
downColor: resolved.downColor,
|
|
9714
|
+
lineColor: resolved.lineColor,
|
|
9715
|
+
gridColor: resolved.gridColor,
|
|
9716
|
+
grid: { color: resolved.gridColor, opacity: resolved.gridOpacity },
|
|
9717
|
+
axis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9718
|
+
xAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9719
|
+
yAxis: { textColor: resolved.axisTextColor, lineColor: resolved.axisLineColor },
|
|
9720
|
+
crosshair: {
|
|
9721
|
+
color: resolved.crosshairColor,
|
|
9722
|
+
labelBackgroundColor: resolved.crosshairLabelBackground,
|
|
9723
|
+
labelTextColor: resolved.crosshairLabelText,
|
|
9724
|
+
labelBorderColor: resolved.crosshairLabelBorder
|
|
9725
|
+
},
|
|
9726
|
+
watermark: { color: resolved.watermarkColor },
|
|
9727
|
+
labels: { indicatorTextColor: resolved.indicatorTextColor }
|
|
9728
|
+
});
|
|
9729
|
+
activeThemeName = resolved.name;
|
|
9730
|
+
};
|
|
9731
|
+
const getTheme = () => activeThemeName;
|
|
9608
9732
|
const setChartType = (type) => {
|
|
9609
9733
|
if (mergedOptions.chartType === type) {
|
|
9610
9734
|
return;
|
|
@@ -10133,6 +10257,8 @@ function createChart(element, options = {}) {
|
|
|
10133
10257
|
getMagnetMode,
|
|
10134
10258
|
setPriceScale,
|
|
10135
10259
|
getPriceScale,
|
|
10260
|
+
setTheme,
|
|
10261
|
+
getTheme,
|
|
10136
10262
|
setCompareSeries,
|
|
10137
10263
|
addCompareSeries,
|
|
10138
10264
|
removeCompareSeries,
|
|
@@ -10162,6 +10288,8 @@ function createChart(element, options = {}) {
|
|
|
10162
10288
|
};
|
|
10163
10289
|
}
|
|
10164
10290
|
export {
|
|
10291
|
+
CHART_THEMES,
|
|
10292
|
+
CHART_THEME_NAMES,
|
|
10165
10293
|
FIB_DEFAULT_PALETTE,
|
|
10166
10294
|
POSITION_DEFAULT_COLORS,
|
|
10167
10295
|
SCRIPT_SOURCE_INPUT_VALUES,
|