MCPcopy Index your code
hub / github.com/apache/echarts / _initData

Method _initData

src/component/timeline/TimelineModel.ts:248–289  ·  view source on GitHub ↗

* @private

()

Source from the content-addressed store, hash-verified

246 * @private
247 */
248 _initData() {
249 const thisOption = this.option;
250 const dataArr = thisOption.data || [];
251 const axisType = thisOption.axisType;
252 const names: string[] = this._names = [];
253
254 let processedDataArr: TimelineOption['data'];
255 if (axisType === 'category') {
256 processedDataArr = [];
257 each(dataArr, function (item, index) {
258 const value = convertOptionIdName(getDataItemValue(item), '');
259 let newItem;
260
261 if (isObject(item)) {
262 newItem = clone(item);
263 (newItem as TimelineDataItemOption).value = index;
264 }
265 else {
266 newItem = index;
267 }
268
269 processedDataArr.push(newItem);
270
271 names.push(value);
272 });
273 }
274 else {
275 processedDataArr = dataArr;
276 }
277
278 const dimType = ({
279 category: 'ordinal',
280 time: 'time',
281 value: 'number'
282 })[axisType] || 'number';
283
284 const data = this._data = new SeriesData([{
285 name: 'value', type: dimType
286 }], this);
287
288 data.initData(processedDataArr, names);
289 }
290
291 getData() {
292 return this._data;

Callers 2

initMethod · 0.95
mergeOptionMethod · 0.95

Calls 6

convertOptionIdNameFunction · 0.90
getDataItemValueFunction · 0.90
cloneFunction · 0.85
eachFunction · 0.50
isObjectFunction · 0.50
initDataMethod · 0.45

Tested by

no test coverage detected