ecomfe / echarts-stat

Statistics tool for Apache ECharts
588 stars 309 forks source link

Tooltip integration on regression lines #37

Closed dvago closed 3 years ago

dvago commented 3 years ago

Hi there,

I'm currently looking into displaying a tooltip showing the regression calculation when the user goes on hover the regression line.

As far as I can tell there is no way to achieve it.

given a series of objects such as:

series: [
    {
     type: 'scatter',
     xAxisIndex: 0,
     yAxisIndex: 0, 
     emphasis: {
        focus: 'series',
      },
     data: [
        {
         name: 'point',
         value: [
            0.69,
            97.843, '...'
          ]
        }
      ]
    },
    {
     type: 'scatter',
     xAxisIndex: 0,
     yAxisIndex: 0,
     emphasis: {
        focus: 'series',
      },
     data: [
        {
         name: 'point',
         value: [
            0.89,
            107.343, '...'
          ]
        }
      ]
    },
    {
     name: 'Regression',
     type: 'line',
     datasetIndex: 1,
     symbolSize: 0,
    }
]

The tooltip works for the datasetIndex: 0 which is the list of dots but doesn't show for the index 1

tooltip parameter is set at the root of the configuration as:

tooltip: {
    trigger: 'item'
}

Looking forward to find a solution Thanks in advance.

dvago commented 3 years ago

Further investigation seems to drive this issue into the main Echarts library, as far I can tell the tooltip triggers on hover of a data point only rather than on hovering the entire regression line.

The regression lines seem to have the last point as single way to trigger the tooltip therefore if the symbolSize is equal to 0 no datapoint are visible so no tooltip gets generated.

It's not ideal but I believe it's not even your fault.