12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import * as zrUtil from 'zrender/lib/core/util.js';
- export default function radarLayout(ecModel) {
- ecModel.eachSeriesByType('radar', function (seriesModel) {
- var data = seriesModel.getData();
- var points = [];
- var coordSys = seriesModel.coordinateSystem;
- if (!coordSys) {
- return;
- }
- var axes = coordSys.getIndicatorAxes();
- zrUtil.each(axes, function (axis, axisIndex) {
- data.each(data.mapDimension(axes[axisIndex].dim), function (val, dataIndex) {
- points[dataIndex] = points[dataIndex] || [];
- var point = coordSys.dataToPoint(val, axisIndex);
- points[dataIndex][axisIndex] = isValidPoint(point) ? point : getValueMissingPoint(coordSys);
- });
- });
-
- data.each(function (idx) {
-
-
-
- var firstPoint = zrUtil.find(points[idx], function (point) {
- return isValidPoint(point);
- }) || getValueMissingPoint(coordSys);
-
- points[idx].push(firstPoint.slice());
- data.setItemLayout(idx, points[idx]);
- });
- });
- }
- function isValidPoint(point) {
- return !isNaN(point[0]) && !isNaN(point[1]);
- }
- function getValueMissingPoint(coordSys) {
-
-
- return [coordSys.cx, coordSys.cy];
- }
|