apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.1k stars 19.6k forks source link

[Feature] redesign radar chart like polar #19182

Open helgasoft opened 11 months ago

helgasoft commented 11 months ago

What problem does this feature solve?

The feature could solve several current radar problems like #16605, #15339, #10750, #10537, #20109, etc. Current design is custom, unique and inconsistent with other charts. As a result, support and maintenance are more difficult.

What does the proposed API look like?

Current radar series structure treats individual series as data :

series: [{
  type: 'radar',
  data : [
    {
        value : [4300, 10000, 28000, 35000, 50000, 19000],
        name : 'Allocated Budget'
    },
    {
        value : [5000, 14000, 28000, 31000, 42000, 21000],
        name : 'Actual Spending'
    }
  ]
}]

Proposed API is having individual line series, as in polar. Radar is similar to polar but does not have its own coordinateSystem.

series: [
  {  type: 'line', name: 'Allocated Budget', coordinateSystem: 'radar',
     data : [ 4300, 10000, 28000, 35000, 50000, 19000]
  },
  {  type: 'line', name: 'Actual Spending', coordinateSystem: 'radar',
     data : [5000, 14000, 28000, 31000, 42000, 21000]
  }
]

I think radar chart could be restructured like polar. With its specific radar axis and coordinateSystem. Radar axis may also borrow characteristics from parallelAxis, which is similar. Radar series could be redesigned to imitate series-parallel, or just be replaced by series-line. As a result of those convergences radar chart will become consistent with other series in ECharts.

Demo Code - polar imitating a radar chart

image

Ovilia commented 11 months ago

Hi @helgasoft . Thanks for your suggestion. Can you be more specific about the supposed new radar series option?

As about the radar tooltip indicator, I was once trying to fix the problem and yes it's difficult because radar's indicator is a different concept than an axis. Instead, one indicator is itself one axis rather than a category in an axis.

helgasoft commented 11 months ago

@Ovilia, thank you for replying. Hope other developers would also participate in the conversation. My view is strictly API and UI driven, did not analyze source code.

The present

Radar chart is working, it's a simple chart with few customisations available. But the most important, tooltips, is flawed because of series-radar.data structure. When people try to customize tooltips (#19004), they find dataIndex unusable. See Demo Code for this and other oddities like:

A better radar chart

I consider radar an axis, like parallelAxis. There are many similarities between them, one notable difference being the layout - radar is radial, parallelAxis is horizontal. I also like polar's angleAxis for the ability to display simple line series with their points (parallelAxis doesn't do points). Please note also that both polar and parallel charts have their own coordinateSystem. So the goal would be to merge code from angleAxis and parallelAxis to get a new better radarAxis. Once this is accomplished, we would start using series-line with coordinateSystem:'radar' and radarIndex:0, and series-radar will become obsolete. Advantages:

That is my opinion, other's are readily welcome.

wozien commented 5 months ago

mark