apache / echarts

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

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

Open buhichan opened 5 years ago

buhichan commented 5 years ago

General Questions

In this issue, I have provided information with: 在这个 issue 中我提供了以下信息:

Issue Type

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

Current Behavior

image

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

Anything Else We Need to Know

Environment

Ovilia commented 5 years ago

Because the x value of the two series are not the same. The first one is 1544770701 and the second one is 1544770702. But I think this should be improved so that all series are shown in tooltip when trigger is set to be axis.

100pah commented 5 years ago

As @Ovilia mentioned, I think if you intent to display both series in a tooltip, the x value should be the same.

If we make all of the series displayed in tooltip mandatorily in this case, when a axisPointer is on a X value and some series do not have Y value corresponding to that x value, which data item should be selected to show on tooltip? I think it is not reasonable enough to choose a closest item to show on tooltip, because it may miss leading the readers.

buhichan commented 5 years ago

I don't see it's a misleading. The difference is only 1 second, it is ignorable. It's very common when you have multiple sourced time series data and their sampling rate are not synchronized. If I don't have the option to do this (show the closest point), I am forced to modify the x value so that they are at the same x, but that would be misleading the viewers.

IkerZamora commented 4 years ago

Any update on this?

Ovilia commented 4 years ago

I think it's reasonable to display the two series if x axis has snap setting to be true. Let's see what we can do after we fix #7651.

Wintermute79 commented 2 years ago

Maybe same as #15488 ?