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

Function getCurvenessForEdge

src/chart/helper/multipleGraphEdgeHelper.ts:173–230  ·  view source on GitHub ↗
(edge, seriesModel, index, needReverse?: boolean)

Source from the content-addressed store, hash-verified

171 * @param index
172 */
173export function getCurvenessForEdge(edge, seriesModel, index, needReverse?: boolean) {
174 const autoCurvenessParams = getAutoCurvenessParams(seriesModel);
175 const isArrayParam = zrUtil.isArray(autoCurvenessParams);
176 if (!autoCurvenessParams) {
177 return null;
178 }
179
180 const edgeArray = getEdgeFromMap(edge, seriesModel);
181 if (!edgeArray) {
182 return null;
183 }
184
185 let edgeIndex = -1;
186 for (let i = 0; i < edgeArray.length; i++) {
187 if (edgeArray[i] === index) {
188 edgeIndex = i;
189 break;
190 }
191 }
192 // if totalLen is Longer createCurveness
193 const totalLen = getTotalLengthBetweenNodes(edge, seriesModel);
194 createCurveness(seriesModel, totalLen);
195
196 edge.lineStyle = edge.lineStyle || {};
197 // if is opposite edge, must set curvenss to opposite number
198 const curKey = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
199 const curvenessList = seriesModel.__curvenessList;
200 // if pass array no need parity
201 const parityCorrection = isArrayParam ? 0 : totalLen % 2 ? 0 : 1;
202
203 if (!edgeArray.isForward) {
204 // the opposite edge show outside
205 const oppositeKey = getOppositeKey(curKey);
206 const len = getEdgeMapLengthWithKey(oppositeKey, seriesModel);
207 const resValue = curvenessList[edgeIndex + len + parityCorrection];
208 // isNeedReverse, simple, force type need reverse the curveness in the junction of the forword and the opposite
209 if (needReverse) {
210 // set as array may make the parity handle with the len of opposite
211 if (isArrayParam) {
212 if (autoCurvenessParams && autoCurvenessParams[0] === 0) {
213 return (len + parityCorrection) % 2 ? resValue : -resValue;
214 }
215 else {
216 return ((len % 2 ? 0 : 1) + parityCorrection) % 2 ? resValue : -resValue;
217 }
218 }
219 else {
220 return (len + parityCorrection) % 2 ? resValue : -resValue;
221 }
222 }
223 else {
224 return curvenessList[edgeIndex + len + parityCorrection];
225 }
226 }
227 else {
228 return curvenessList[parityCorrection + edgeIndex];
229 }
230}

Callers 3

graphForceLayoutFunction · 0.90
simpleLayoutEdgeFunction · 0.90
circularLayoutFunction · 0.90

Calls 7

getAutoCurvenessParamsFunction · 0.85
getEdgeFromMapFunction · 0.85
createCurvenessFunction · 0.85
getKeyOfEdgesFunction · 0.85
getOppositeKeyFunction · 0.85
getEdgeMapLengthWithKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…