MCPcopy
hub / github.com/klinecharts/KLineChart / createOverlay

Method createOverlay

src/Chart.ts:997–1031  ·  view source on GitHub ↗
(value: string | OverlayCreate | Array<string | OverlayCreate>)

Source from the content-addressed store, hash-verified

995 }
996
997 createOverlay (value: string | OverlayCreate | Array<string | OverlayCreate>): Nullable<string> | Array<Nullable<string>> {
998 const overlays: OverlayCreate[] = []
999 const appointPaneFlags: boolean[] = []
1000
1001 const build: ((overlay: OverlayCreate) => void) = overlay => {
1002 if (!isValid(overlay.paneId) || this.getDrawPaneById(overlay.paneId) === null) {
1003 overlay.paneId = PaneIdConstants.CANDLE
1004 appointPaneFlags.push(false)
1005 } else {
1006 appointPaneFlags.push(true)
1007 }
1008 overlays.push(overlay)
1009 }
1010
1011 if (isString(value)) {
1012 build({ name: value })
1013 } else if (isArray<Array<string | OverlayCreate>>(value)) {
1014 (value as Array<string | OverlayCreate>).forEach(v => {
1015 let overlay: Nullable<OverlayCreate> = null
1016 if (isString(v)) {
1017 overlay = { name: v }
1018 } else {
1019 overlay = v
1020 }
1021 build(overlay)
1022 })
1023 } else {
1024 build(value as OverlayCreate)
1025 }
1026 const ids = this._chartStore.addOverlays(overlays, appointPaneFlags)
1027 if (isArray(value)) {
1028 return ids
1029 }
1030 return ids[0]
1031 }
1032
1033 getOverlays (filter?: OverlayFilter): Overlay[] {
1034 return this._chartStore.getOverlaysByFilter(filter ?? {})

Callers 13

index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
index.jsFile · 0.80
createBrushOverlayFunction · 0.80
index.jsFile · 0.80

Calls 3

isStringFunction · 0.90
isArrayFunction · 0.90
addOverlaysMethod · 0.80

Tested by

no test coverage detected