MCPcopy Index your code
hub / github.com/dataease/SQLBot / init

Method init

frontend/src/views/chat/component/charts/Table.ts:103–249  ·  view source on GitHub ↗
(axis: Array<ChartAxis>, data: Array<ChartData>)

Source from the content-addressed store, hash-verified

101 }
102
103 init(axis: Array<ChartAxis>, data: Array<ChartData>) {
104 super.init(
105 filter(axis, (a) => !a.hidden), //隐藏多指标的other-info列
106 data
107 )
108
109 const s2DataConfig: S2DataConfig = {
110 sortParams:
111 this.axis?.map((a) => {
112 return {
113 sortFieldId: a.value,
114 }
115 }) ?? [],
116 fields: {
117 columns: this.axis?.map((a) => a.value) ?? [],
118 },
119 meta:
120 this.axis?.map((a) => {
121 return {
122 field: a.value,
123 name: a.name,
124 formatter: (value: any) => {
125 const formatted = formatNumber(value)
126 return String(formatted)
127 },
128 }
129 }) ?? [],
130 data: this.data,
131 }
132
133 const sortState: Record<string, string> = {}
134
135 const handleSortClick = (params: any) => {
136 const { meta } = params
137 const s2 = meta.spreadsheet
138 if (s2 && meta.isLeaf) {
139 const fieldId = meta.field
140 const currentMethod = sortState[fieldId] || 'none'
141 const sortOrder = ['none', 'desc', 'asc']
142 const nextMethod = sortOrder[(sortOrder.indexOf(currentMethod) + 1) % sortOrder.length]
143 sortState[fieldId] = nextMethod
144 if (nextMethod === 'none') {
145 s2.emit(S2Event.RANGE_SORT, [{ sortFieldId: fieldId, sortMethod: 'none' as SortMethod }])
146 } else {
147 s2.emit(S2Event.RANGE_SORT, [
148 {
149 sortFieldId: fieldId,
150 sortMethod: nextMethod as SortMethod,
151 sortFunc: createSmartSortFunc(nextMethod),
152 },
153 ])
154 }
155 s2.render()
156 }
157 }
158
159 const s2Options: S2Options = {
160 width: 600,

Callers

nothing calls this directly

Calls 8

formatNumberFunction · 0.90
filterFunction · 0.85
copyDataFunction · 0.85
initMethod · 0.65
onMethod · 0.65
tFunction · 0.50
mapMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected