echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Custom Tooltip for Radar Chart[Feature]

Open MNHarshitha opened this issue 3 years ago • 5 comments

What problem does this feature solve?

Hi,

We have a requirement of showing tooltips for the radar chart. The tooltip should consist of the data value and the corresponding indicator. https://echarts.apache.org/examples/en/editor.html?c=radar image

What does the proposed API look like?

Some information in tooltip callback params using which we can construct the tooltip display labels in the following way indicaterName: dataValue

MNHarshitha avatar Feb 28 '22 14:02 MNHarshitha

@MNHarshitha you can use the tooltip option, it works with radar charts.

https://echarts.apache.org/en/option.html#tooltip

ZeekoZhu avatar Mar 18 '22 09:03 ZeekoZhu

how to show only one point's tooltip that close to mouse? It always show every point, I just want show one that my mouse close to

nlpsl202 avatar Apr 27 '22 08:04 nlpsl202

@MNHarshitha you can use the tooltip option, it works with radar charts.

https://echarts.apache.org/en/option.html#tooltip

image We are able to display the tooltip using the tooltip option, but we need to modify the content of the tooltip. With reference to the above screenshot, if we are hovering on the data point of the market, we only want to display the market-related info in the tooltip. But nowhere in the formatter callback params, we are able to identify the exact data point on which the user hovered. https://codepen.io/Harshitha19/pen/eYMVXqo Please let us know the way to achieve the mentioned functionality.

MNHarshitha avatar Aug 03 '22 06:08 MNHarshitha

Maybe this issue is related to https://github.com/apache/echarts/issues/10537#issuecomment-608339356

ZeekoZhu avatar Aug 03 '22 06:08 ZeekoZhu

Maybe this issue is related to #10537 (comment)

According to my understanding in the above ticket 10537, axisPointer option is being requested. We are trying to configure the tooltip on the item. To be more precise, when tooltip is configured for line series with the trigger on item, info related to only that data point is being displayed. image When we try to configure the same i.e tooltip with the trigger on item in case of radar chart, info related to all the data points is being displayed in the tooltip. image We are requesting a similar behavior as that of the line chart. Please let me know if it is not clear.

MNHarshitha avatar Aug 03 '22 08:08 MNHarshitha

any updates?

AnthonyTannous avatar Feb 01 '23 12:02 AnthonyTannous

I made this solution to show the hovered indicator alone using costumed JS functions for radar echarts

  1. Create two global variables : var globalIndicators = new Array() var globalIndexId;

  2. initialize your chart with SVGs var echartBar = echarts.init(document.getElementById('RadarChart'),{ renderer: 'svg' });

  3. save your indices in the global variable globalIndicators = indices;

  4. add this two functions to your page

function setIndicatorEvent() { var tags = $('#RadarChart path[transform]') for (var i = 0; i < tags.length; i++) { if (tags[i].attributes?.transform.value.includes("matrix")) tags[i].addEventListener('mouseover', (event) => customEvent(event)); } }

function customEvent(event) { var tags = $('#RadarChart path[transform]') for (var i = 0; i < tags.length; i++) { if (tags[i] == event.currentTarget) globalIndexId = i } }

  1. Inside your formatter add:

var options = { tooltip: { formatter: (params) => { if (globalndexId === undefined) return var value = params.value[globalIndexId] return params.marker + " " + globalIndicators [globalIndexId].text + " " + (Number.isInteger(value) ? value : parseFloat(value).toFixed(2)) } },

  1. Init this funtion setIndicatorEvent() after rendering the chart:

    options && echartBar.setOption(options, true); echartBar.hideLoading() setIndicatorEvent()

  2. try it

AnthonyTannous avatar Feb 03 '23 12:02 AnthonyTannous

Having same issue would be good to have this

sedatbasar avatar Aug 29 '23 07:08 sedatbasar