(series, opts, config, context)
| 3417 | } |
| 3418 | |
| 3419 | function drawRadarDataPoints(series, opts, config, context) { |
| 3420 | var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1; |
| 3421 | var radarOption = assign({},{ |
| 3422 | gridColor: '#cccccc', |
| 3423 | labelColor: '#666666', |
| 3424 | opacity: 0.2 |
| 3425 | },opts.extra.radar); |
| 3426 | |
| 3427 | var coordinateAngle = getRadarCoordinateSeries(opts.categories.length); |
| 3428 | |
| 3429 | var centerPosition = { |
| 3430 | x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2, |
| 3431 | y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2 |
| 3432 | }; |
| 3433 | |
| 3434 | var radius = Math.min(centerPosition.x - (getMaxTextListLength(opts.categories) + config.radarLabelTextMargin), |
| 3435 | centerPosition.y - config.radarLabelTextMargin); |
| 3436 | //TODO逻辑不对 |
| 3437 | radius -= opts.padding[1]; |
| 3438 | |
| 3439 | // draw grid |
| 3440 | context.beginPath(); |
| 3441 | context.setLineWidth(1 * opts.pixelRatio); |
| 3442 | context.setStrokeStyle(radarOption.gridColor); |
| 3443 | coordinateAngle.forEach(function(angle) { |
| 3444 | var pos = convertCoordinateOrigin(radius * Math.cos(angle), radius * Math.sin(angle), centerPosition); |
| 3445 | context.moveTo(centerPosition.x, centerPosition.y); |
| 3446 | context.lineTo(pos.x, pos.y); |
| 3447 | }); |
| 3448 | context.stroke(); |
| 3449 | context.closePath(); |
| 3450 | // draw split line grid |
| 3451 | |
| 3452 | var _loop = function _loop(i) { |
| 3453 | var startPos = {}; |
| 3454 | context.beginPath(); |
| 3455 | context.setLineWidth(1 * opts.pixelRatio); |
| 3456 | context.setStrokeStyle(radarOption.gridColor); |
| 3457 | coordinateAngle.forEach(function(angle, index) { |
| 3458 | var pos = convertCoordinateOrigin(radius / config.radarGridCount * i * Math.cos(angle), radius / config.radarGridCount * |
| 3459 | i * Math.sin(angle), centerPosition); |
| 3460 | if (index === 0) { |
| 3461 | startPos = pos; |
| 3462 | context.moveTo(pos.x, pos.y); |
| 3463 | } else { |
| 3464 | context.lineTo(pos.x, pos.y); |
| 3465 | } |
| 3466 | }); |
| 3467 | context.lineTo(startPos.x, startPos.y); |
| 3468 | context.stroke(); |
| 3469 | context.closePath(); |
| 3470 | }; |
| 3471 | |
| 3472 | for (var i = 1; i <= config.radarGridCount; i++) { |
| 3473 | _loop(i); |
| 3474 | } |
| 3475 | |
| 3476 | var radarDataPoints = getRadarDataPoints(coordinateAngle, centerPosition, radius, series, opts, process); |
no test coverage detected