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

Function markLineTransform

src/component/marker/MarkLineView.ts:66–155  ·  view source on GitHub ↗
(
    seriesModel: SeriesModel,
    coordSys: CoordinateSystem,
    mlModel: MarkLineModel,
    item: MarkLineOption['data'][number]
)

Source from the content-addressed store, hash-verified

64}, MarkLineModel>();
65
66const markLineTransform = function (
67 seriesModel: SeriesModel,
68 coordSys: CoordinateSystem,
69 mlModel: MarkLineModel,
70 item: MarkLineOption['data'][number]
71) {
72 const data = seriesModel.getData();
73
74 let itemArray: MarkLineMergedItemOption[];
75 if (!isArray(item)) {
76 // Special type markLine like 'min', 'max', 'average', 'median'
77 const mlType = item.type;
78 if (
79 mlType === 'min' || mlType === 'max' || mlType === 'average' || mlType === 'median'
80 // In case
81 // data: [{
82 // yAxis: 10
83 // }]
84 || (item.xAxis != null || item.yAxis != null)
85 ) {
86
87 let valueAxis;
88 let value;
89
90 if (item.yAxis != null || item.xAxis != null) {
91 valueAxis = coordSys.getAxis(item.yAxis != null ? 'y' : 'x');
92 value = retrieve(item.yAxis, item.xAxis);
93 }
94 else {
95 const axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
96 valueAxis = axisInfo.valueAxis;
97 const valueDataDim = getStackedDimension(data, axisInfo.valueDataDim);
98 value = markerHelper.numCalculate(data, valueDataDim, mlType);
99 }
100 const valueIndex = valueAxis.dim === 'x' ? 0 : 1;
101 const baseIndex = 1 - valueIndex;
102
103 // Normized to 2d data with start and end point
104 const mlFrom = clone(item) as MarkLine2DDataItemOption[number];
105 const mlTo = {
106 coord: []
107 } as MarkLine2DDataItemOption[number];
108
109 mlFrom.type = null;
110
111 mlFrom.coord = [];
112 mlFrom.coord[baseIndex] = -Infinity;
113 mlTo.coord[baseIndex] = Infinity;
114
115 const precision = mlModel.get('precision');
116 if (precision >= 0 && isNumber(value)) {
117 value = +value.toFixed(Math.min(precision, 20));
118 }
119
120 mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
121
122 itemArray = [mlFrom, mlTo, { // Extra option for tooltip and label
123 type: mlType,

Callers

nothing calls this directly

Calls 11

getStackedDimensionFunction · 0.90
mergeFunction · 0.90
isArrayFunction · 0.85
retrieveFunction · 0.85
cloneFunction · 0.85
isNumberFunction · 0.85
extendFunction · 0.85
toFixedMethod · 0.80
getDataMethod · 0.65
getAxisMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…