MCPcopy
hub / github.com/apache/echarts / createExternalSource

Function createExternalSource

src/data/helper/transform.ts:162–260  ·  view source on GitHub ↗
(internalSource: Source, externalTransform: ExternalDataTransform)

Source from the content-addressed store, hash-verified

160
161
162function createExternalSource(internalSource: Source, externalTransform: ExternalDataTransform): ExternalSource {
163 const extSource = new ExternalSource();
164
165 const data = internalSource.data;
166 const sourceFormat = extSource.sourceFormat = internalSource.sourceFormat;
167 const sourceHeaderCount = internalSource.startIndex;
168
169 let errMsg = '';
170 if (internalSource.seriesLayoutBy !== SERIES_LAYOUT_BY_COLUMN) {
171 // For the logic simplicity in transformer, only 'culumn' is
172 // supported in data transform. Otherwise, the `dimensionsDefine`
173 // might be detected by 'row', which probably confuses users.
174 if (__DEV__) {
175 errMsg = '`seriesLayoutBy` of upstream dataset can only be "column" in data transform.';
176 }
177 throwError(errMsg);
178 }
179
180 // [MEMO]
181 // Create a new dimensions structure for exposing.
182 // Do not expose all dimension info to users directly.
183 // Because the dimension is probably auto detected from data and not might reliable.
184 // Should not lead the transformers to think that is reliable and return it.
185 // See [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.
186 const dimensions = [] as ExternalDimensionDefinition[];
187 const dimsByName = {} as Dictionary<ExternalDimensionDefinition>;
188
189 const dimsDef = internalSource.dimensionsDefine;
190 if (dimsDef) {
191 each(dimsDef, function (dimDef, idx) {
192 const name = dimDef.name;
193 const dimDefExt = {
194 index: idx,
195 name: name,
196 displayName: dimDef.displayName
197 };
198 dimensions.push(dimDefExt);
199 // Users probably do not specify dimension name. For simplicity, data transform
200 // does not generate dimension name.
201 if (name != null) {
202 // Dimension name should not be duplicated.
203 // For simplicity, data transform forbids name duplication, do not generate
204 // new name like module `completeDimensions.ts` did, but just tell users.
205 let errMsg = '';
206 if (hasOwn(dimsByName, name)) {
207 if (__DEV__) {
208 errMsg = 'dimension name "' + name + '" duplicated.';
209 }
210 throwError(errMsg);
211 }
212 dimsByName[name] = dimDefExt;
213 }
214 });
215 }
216 // If dimension definitions are not defined and can not be detected.
217 // e.g., pure data `[[11, 22], ...]`.
218 else {
219 for (let i = 0; i < internalSource.dimensionsDetectedCount || 0; i++) {

Callers 1

applySingleDataTransformFunction · 0.85

Calls 6

throwErrorFunction · 0.90
getRawSourceItemGetterFunction · 0.90
getRawSourceDataCounterFunction · 0.90
getRawSourceValueGetterFunction · 0.90
eachFunction · 0.50
hasOwnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…