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

Function createViewCoordSys

src/chart/graph/createView.ts:40–98  ·  view source on GitHub ↗
(ecModel: GlobalModel, api: ExtensionAPI)

Source from the content-addressed store, hash-verified

38}
39
40export default function createViewCoordSys(ecModel: GlobalModel, api: ExtensionAPI) {
41 const viewList: View[] = [];
42 ecModel.eachSeriesByType('graph', function (seriesModel: GraphSeriesModel) {
43
44 injectCoordSysByOption({
45 targetModel: seriesModel,
46 coordSysType: 'view',
47 coordSysProvider: createViewCoordSys,
48 isDefaultDataCoordSys: true,
49 });
50
51 function createViewCoordSys() {
52 const data = seriesModel.getData();
53 const positions = data.mapArray(function (idx) {
54 const itemModel = data.getItemModel<GraphNodeItemOption>(idx);
55 return [+itemModel.get('x'), +itemModel.get('y')];
56 });
57
58 let min: number[] = [];
59 let max: number[] = [];
60
61 bbox.fromPoints(positions, min, max);
62
63 // If width or height is 0
64 if (max[0] - min[0] === 0) {
65 max[0] += 1;
66 min[0] -= 1;
67 }
68 if (max[1] - min[1] === 0) {
69 max[1] += 1;
70 min[1] -= 1;
71 }
72 const aspect = (max[0] - min[0]) / (max[1] - min[1]);
73 // FIXME If get view rect after data processed?
74 const viewRect = getViewRect(seriesModel, api, aspect);
75 // Position may be NaN (e.g., in force layout), use view rect instead
76 if (isNaN(aspect)) {
77 min = [viewRect.x, viewRect.y];
78 max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
79 }
80
81 const bbWidth = max[0] - min[0];
82 const bbHeight = max[1] - min[1];
83
84 const viewCoordSys = createViewCoordSysSimply(
85 seriesModel,
86 api,
87 min[0], min[1], bbWidth, bbHeight,
88 viewRect
89 );
90
91 viewList.push(viewCoordSys);
92
93 return viewCoordSys;
94 }
95 });
96
97 return viewList;

Callers

nothing calls this directly

Calls 8

injectCoordSysByOptionFunction · 0.90
createViewCoordSysSimplyFunction · 0.90
eachSeriesByTypeMethod · 0.80
mapArrayMethod · 0.80
getItemModelMethod · 0.80
getViewRectFunction · 0.70
getDataMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…