Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Tooltip for Radar Chart[Feature] #16595

Closed
MNHarshitha opened this issue Feb 28, 2022 · 8 comments
Closed

Custom Tooltip for Radar Chart[Feature] #16595

MNHarshitha opened this issue Feb 28, 2022 · 8 comments
Labels
duplicate en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature.

Comments

@MNHarshitha
Copy link

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

@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. waiting-for: community labels Feb 28, 2022
@ZeekoZhu
Copy link
Contributor

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

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

@nlpsl202
Copy link

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

@MNHarshitha
Copy link
Author

@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.

@ZeekoZhu
Copy link
Contributor

ZeekoZhu commented Aug 3, 2022

Maybe this issue is related to #10537 (comment)

@MNHarshitha
Copy link
Author

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.

@Ovilia Ovilia closed this as completed Sep 29, 2022
@echarts-bot echarts-bot bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2022
@AnthonyTannous
Copy link

any updates?

@AnthonyTannous
Copy link

AnthonyTannous commented Feb 3, 2023

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

@sedatbasar
Copy link

Having same issue would be good to have this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature.
Projects
None yet
Development

No branches or pull requests

6 participants