()
| 193 | } |
| 194 | |
| 195 | private _createSource(): void { |
| 196 | this._setLocalSource([], []); |
| 197 | |
| 198 | const sourceHost = this._sourceHost; |
| 199 | |
| 200 | const upSourceMgrList = this._getUpstreamSourceManagers(); |
| 201 | const hasUpstream = !!upSourceMgrList.length; |
| 202 | let resultSourceList: Source[]; |
| 203 | let upstreamSignList: string[]; |
| 204 | |
| 205 | if (isSeries(sourceHost)) { |
| 206 | const seriesModel = sourceHost as SeriesEncodableModel; |
| 207 | let data; |
| 208 | let sourceFormat: SourceFormat; |
| 209 | let upSource: Source; |
| 210 | |
| 211 | // Has upstream dataset |
| 212 | if (hasUpstream) { |
| 213 | const upSourceMgr = upSourceMgrList[0]; |
| 214 | upSourceMgr.prepareSource(); |
| 215 | upSource = upSourceMgr.getSource(); |
| 216 | data = upSource.data; |
| 217 | sourceFormat = upSource.sourceFormat; |
| 218 | upstreamSignList = [upSourceMgr._getVersionSign()]; |
| 219 | } |
| 220 | // Series data is from own. |
| 221 | else { |
| 222 | data = seriesModel.get('data', true) as OptionSourceData; |
| 223 | sourceFormat = isTypedArray(data) |
| 224 | ? SOURCE_FORMAT_TYPED_ARRAY : SOURCE_FORMAT_ORIGINAL; |
| 225 | upstreamSignList = []; |
| 226 | } |
| 227 | |
| 228 | // See [REQUIREMENT_MEMO], merge settings on series and parent dataset if it is root. |
| 229 | const newMetaRawOption = this._getSourceMetaRawOption() || {} as SourceMetaRawOption; |
| 230 | const upMetaRawOption = upSource && upSource.metaRawOption || {} as SourceMetaRawOption; |
| 231 | const seriesLayoutBy = retrieve2(newMetaRawOption.seriesLayoutBy, upMetaRawOption.seriesLayoutBy) || null; |
| 232 | const sourceHeader = retrieve2(newMetaRawOption.sourceHeader, upMetaRawOption.sourceHeader); |
| 233 | // Note here we should not use `upSource.dimensionsDefine`. Consider the case: |
| 234 | // `upSource.dimensionsDefine` is detected by `seriesLayoutBy: 'column'`, |
| 235 | // but series need `seriesLayoutBy: 'row'`. |
| 236 | const dimensions = retrieve2(newMetaRawOption.dimensions, upMetaRawOption.dimensions); |
| 237 | |
| 238 | // We share source with dataset as much as possible |
| 239 | // to avoid extra memory cost of high dimensional data. |
| 240 | const needsCreateSource = seriesLayoutBy !== upMetaRawOption.seriesLayoutBy |
| 241 | || !!sourceHeader !== !!upMetaRawOption.sourceHeader |
| 242 | || dimensions; |
| 243 | resultSourceList = needsCreateSource ? [createSource( |
| 244 | data, |
| 245 | { seriesLayoutBy, sourceHeader, dimensions }, |
| 246 | sourceFormat |
| 247 | )] : []; |
| 248 | } |
| 249 | else { |
| 250 | const datasetModel = sourceHost as DatasetModel; |
| 251 | |
| 252 | // Has upstream dataset. |
no test coverage detected