Justin-ZS opened a new pull request, #21378: URL: https://github.com/apache/echarts/pull/21378
<!-- Please fill in the following information to help us review your PR more efficiently. --> ## Brief Information This pull request is in the type of: - [ ] bug fixing - [x] new feature - [ ] others ### What does this PR do? Enhances polar coordinate system to enable line series to simulate radar chart functionality with single category + single metric use cases. <img width="1294" height="682" alt="截屏2025-11-18 18 02 57" src="https://github.com/user-attachments/assets/9b777b15-fb05-4161-b6d8-19938e06c40a" /> ### Fixed issues N/A ## Details ### Before: What was the problem? The traditional radar chart in ECharts has several limitations: 1. **Limited Data Structure Support**: The original radar chart only works well with multiple metrics + single category structure. When dealing with single metric + single category data (which is common), it becomes difficult to use effectively. 2. **Implementation Inconsistencies**: The radar chart was implemented as a standalone component with its own logic, separate from the polar coordinate system. This resulted in: - Many features available in polar line charts being unavailable in radar charts - Several unresolved bugs and missing functionality - Duplicated code and inconsistent API design 3. **Industry Standard Mismatch**: Most other charting libraries implement radar charts as an extension of polar line charts, which provides better flexibility and feature consistency. ECharts lacked the necessary features to support this approach. ### After: How does it behave after the fixing? This PR enhances the polar coordinate system with two new features that enable line series to simulate radar chart behavior: **1. Added `connectEnds` option to line series** - Connects the end point back to the start point, creating a closed shape - Only effective in polar coordinate system - Works seamlessly with smooth curves (automatically adds control points for smooth closure) - Supports both polyline and polygon (with area fill) **2. Added `splitLine.shape` option to radius axis** - New option: `'arc'` (default, original behavior) or `'polygon'` - When set to `'polygon'` with category angle axis, creates polygon-shaped grid lines by connecting angle tick points - Perfectly simulates the radar chart's web-like grid appearance **Benefits:** - Users can now use polar line charts for single category + single metric scenarios - Inherits all line series features: smooth curves, sampling, custom styles, etc. - More flexible than the traditional radar chart - Consistent with industry standards and other popular charting libraries - Unified API design with the rest of ECharts ## Document Info One of the following should be checked. - [ ] This PR doesn't relate to document changes - [x] The document should be updated later - [ ] The document changes have been made in apache/echarts-doc#xxx **Documentation needed:** - New `connectEnds` option for line series in polar coordinate system - New `splitLine.shape` option for radius axis - Usage examples showing how to create radar-like charts using enhanced polar line ## Misc ### Security Checking - [ ] This PR uses security-sensitive Web APIs. <!-- PLEASE CHECK IT AGAINST: <https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors> --> **Note:** This PR only uses standard canvas drawing APIs for rendering geometry (polygons, lines). No security-sensitive Web APIs are involved. ### ZRender Changes - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx). ### Related test cases or examples to use the new APIs **Basic usage example:** ```javascript const option = { polar: { radius: '70%' }, radiusAxis: { type: 'value', min: 0, max: 10, splitLine: { show: true, shape: 'polygon' // New option } }, angleAxis: { type: 'category', data: ['A', 'B', 'C', 'D', 'E', 'F'], boundaryGap: false, startAngle: 90, axisLine: { show: false }, }, series: [{ type: 'line', coordinateSystem: 'polar', connectEnds: true, // New option data: [[8, 'A'], [6, 'B'], [7, 'C'], [5, 'D'], [8, 'E'], [6, 'F']], areaStyle: {} }] }; ``` ### Merging options - [x] Please squash the commits into a single one when merging. ### Other information -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
