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

Function graphSimpleLayout

src/chart/graph/simpleLayout.ts:30–67  ·  view source on GitHub ↗
(ecModel: GlobalModel, api: ExtensionAPI)

Source from the content-addressed store, hash-verified

28export const graphSimpleLayoutStageHandler = createSimpleOverallStageHandler(SERIES_TYPE_GRAPH, graphSimpleLayout);
29
30function graphSimpleLayout(ecModel: GlobalModel, api: ExtensionAPI) {
31 ecModel.eachSeriesByType(SERIES_TYPE_GRAPH, function (seriesModel: GraphSeriesModel) {
32 const layout = seriesModel.get('layout');
33 const coordSys = seriesModel.coordinateSystem;
34 if (coordSys && coordSys.type !== 'view') {
35 const data = seriesModel.getData();
36
37 let dimensions: string[] = [];
38 each(coordSys.dimensions, function (coordDim) {
39 dimensions = dimensions.concat(data.mapDimensionsAll(coordDim));
40 });
41
42 for (let dataIndex = 0; dataIndex < data.count(); dataIndex++) {
43 const value = [];
44 let hasValue = false;
45 for (let i = 0; i < dimensions.length; i++) {
46 const val = data.get(dimensions[i], dataIndex) as number;
47 if (!isNaN(val)) {
48 hasValue = true;
49 }
50 value.push(val);
51 }
52 if (hasValue) {
53 data.setItemLayout(dataIndex, coordSys.dataToPoint(value));
54 }
55 else {
56 // Also {Array.<number>}, not undefined to avoid if...else... statement
57 data.setItemLayout(dataIndex, [NaN, NaN]);
58 }
59 }
60
61 simpleLayoutEdge(data.graph, seriesModel);
62 }
63 else if (!layout || layout === 'none') {
64 simpleLayout(seriesModel);
65 }
66 });
67}

Callers

nothing calls this directly

Calls 10

simpleLayoutEdgeFunction · 0.90
simpleLayoutFunction · 0.90
eachSeriesByTypeMethod · 0.80
mapDimensionsAllMethod · 0.80
setItemLayoutMethod · 0.80
getDataMethod · 0.65
countMethod · 0.65
dataToPointMethod · 0.65
eachFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…