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

Function radarLayout

src/chart/radar/radarLayout.ts:30–64  ·  view source on GitHub ↗
(ecModel: GlobalModel)

Source from the content-addressed store, hash-verified

28export const radarLayoutStageHandler = createSimpleOverallStageHandler(SERIES_TYPE_RADAR, radarLayout);
29
30function radarLayout(ecModel: GlobalModel) {
31 ecModel.eachSeriesByType(SERIES_TYPE_RADAR, function (seriesModel: RadarSeriesModel) {
32 const data = seriesModel.getData();
33 const points: Point[][] = [];
34 const coordSys = seriesModel.coordinateSystem;
35 if (!coordSys) {
36 return;
37 }
38
39 const axes = coordSys.getIndicatorAxes();
40
41 zrUtil.each(axes, function (axis, axisIndex) {
42 data.each(data.mapDimension(axes[axisIndex].dim), function (val, dataIndex) {
43 points[dataIndex] = points[dataIndex] || [];
44 const point = coordSys.dataToPoint(val, axisIndex);
45 points[dataIndex][axisIndex] = isValidPoint(point)
46 ? point : getValueMissingPoint(coordSys);
47 });
48 });
49
50 // Close polygon
51 data.each(function (idx) {
52 // TODO
53 // Is it appropriate to connect to the next data when some data is missing?
54 // Or, should trade it like `connectNull` in line chart?
55 const firstPoint = zrUtil.find(points[idx], function (point) {
56 return isValidPoint(point);
57 }) || getValueMissingPoint(coordSys);
58
59 // Copy the first actual point to the end of the array
60 points[idx].push(firstPoint.slice());
61 data.setItemLayout(idx, points[idx]);
62 });
63 });
64}
65
66function isValidPoint(point: Point) {
67 return !isNaN(point[0]) && !isNaN(point[1]);

Callers

nothing calls this directly

Calls 9

isValidPointFunction · 0.85
getValueMissingPointFunction · 0.85
eachSeriesByTypeMethod · 0.80
getIndicatorAxesMethod · 0.80
mapDimensionMethod · 0.80
setItemLayoutMethod · 0.80
getDataMethod · 0.65
dataToPointMethod · 0.65
eachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…