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

Function init

src/index.ts:92–115  ·  view source on GitHub ↗

* Init chart instance * @param ds * @param options * @returns {Chart}

(ds: HTMLElement | string, options?: Options)

Source from the content-addressed store, hash-verified

90 * @returns {Chart}
91 */
92function init (ds: HTMLElement | string, options?: Options): Nullable<Chart> {
93 logTag()
94 let dom: Nullable<HTMLElement> = null
95 if (isString(ds)) {
96 dom = document.getElementById(ds)
97 } else {
98 dom = ds
99 }
100 if (dom === null) {
101 logError('', '', 'The chart cannot be initialized correctly. Please check the parameters. The chart container cannot be null and child elements need to be added!!!')
102 return null
103 }
104 let chart = charts.get(dom.id)
105 if (isValid(chart)) {
106 logWarn('', '', 'The chart has been initialized on the dom!!!')
107 return chart
108 }
109 const id = `k_line_chart_${chartBaseId++}`
110 chart = new ChartImp(dom, options)
111 chart.id = id
112 dom.setAttribute('k-line-chart-id', id)
113 charts.set(id, chart)
114 return chart
115}
116
117/**
118 * Destroy chart instance

Callers 15

mountChartFunction · 0.90
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85
index.jsFile · 0.85

Calls 5

logTagFunction · 0.90
isStringFunction · 0.90
logErrorFunction · 0.90
isValidFunction · 0.90
logWarnFunction · 0.90

Tested by

no test coverage detected