apache / apache/echarts

Axis-triggered tooltip failed to display some series if x axis values are not 100% equal!

Open
#9,588 6 comments 0 reactions 0 assignees View on GitHub
enhancement priority: high
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

- [x] I am using English in this issue. 在这个 Issue 中我使用了英文(强烈建议)。

## General Questions

- [x] Required: I have read the document and examples and tried to solve it by myself. (必填)我读过了文档和教程,并且曾试图自己解决问题。
- [x] Required: I have searched for similar issues and that didn't help. (必填)我搜索过 issue 但是没有帮助。
- [x] Required: I have tried with the latest version of ECharts and still have this problem. (必填)我试过最新版本的 ECharts,还是存在这个问题。

In this issue, I have provided information with: 在这个 issue 中我提供了以下信息:
- [x] Required: issue type;(必填)issue 类型
- [x] Required: one sentence description in issue details;(必填)一句话的问题描述
- [x] Required: demo;(必填)能反映问题的例子(如果你想提问或报 bug)
- [x] Required: ECharts version;ECharts 版本

## Issue Type

- [ ] I have a question to ask about *how to use ECharts to ...*;我想提问如何使用 ECharts 实现某功能
- [x] I have a bug to report;我想要报 bug
- [ ] I have a feature to request, e.g.: *I'd like a new feature that ...*;我需要一个新功能
- [x] I have a feature to enhance, e.g.: *The current feature should be improved in the way that ...*;我希望改进某个功能
- [ ] There's something wrong with the documents;文档有些问题
- [ ] Others, or I'm not sure which issue types to choose here;其他,或我不知道应该选什么类型

## Issue Details

Axis-triggered tooltip failed to display some series if x axis values are not 100% equal!

### Expected Behavior

Axis-triggered should always show the nearest data index of all series, like this:
```
series1: 5
series2: 5
```
![image](https://user-images.githubusercontent.com/2786812/49989203-74963f80-ffb4-11e8-8dbb-3ca1ff1fc9bb.png)

### Current Behavior

![image](https://user-images.githubusercontent.com/2786812/49988589-4dd70980-ffb2-11e8-84b8-2fdb50c86326.png)

It always shows one of the series, but never both.

### Online Example

http://jsfiddle.net/sh1acjqu/3/

This is my chart options:
```
{
title: {
text: 'ECharts 入门示例'
},
tooltip: {
trigger: "axis"
},
legend: {
data:['销量']
},
xAxis: {
type: "time"
},
yAxis: {},
series: [{
name: 'series1',
type: 'line',
data: [[1544770701,5], [1544770703,20], [1544770805,36]]
},{
name: 'series2',
type: 'line',
data: [[1544770702,5], [1544770704,20], [1544770806,36]]
}]
}
```

The stated problem is caused by these lines: lib/component/axisPointer/axisTrigger.js#198-203, I don't know the purpose of these codes, but when i comment out line 198~203, the resulted behavior is what i want.

**If you guys think this is a wanted behavior, then i request an option to do this.**

```
// if (dist < minDist || diff >= 0 && minDiff < 0) {
// minDist = dist;
// minDiff = diff;
// snapToValue = seriesNestestValue;
// payloadBatch.length = 0;
// }
```

## Topics

- [ ] Legend
- [x] Tooltip
- [ ] Event
- [ ] Performance
- [ ] SVG
- [ ] Map
- [ ] ECharts GL
- [ ] Third-party libraries, e.g.: Vue.js, React

## Anything Else We Need to Know

## Environment

- ECharts version;ECharts 版本: 4.2.0-rc.2 / 3.7.2 (it happens in both version, you can try in js fiddle)

- [ ] It happens only on certain browsers or operating systems. 对于特定浏览器或操作系统才会出现的问题,请提供相应环境信息:{BROWSER_VERSION_OR_OS_INFORMATION_HERE}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.