如何在 vega-lite 中隐藏重叠折线图的工具提示?

How to hide tooltip of overlapped line charts in vega-lite?

我有多个带工具提示的折线图显示数据,折线图看起来像

我配置为仅显示在图例中单击的行及其悬停在点上时的工具提示

由于有很多参数线在某些点重叠,工具提示有时会显示隐藏的不同参数,例如,在上图中,我从图例中选择了 PRAUC 线并将鼠标悬停在其工具提示上,但是对于同一条线,如果我悬停在不同的点上,它显示不同的参数值,因为那条线重叠在这条线上,如下所示,但它的线是隐藏的

我已经将该行的不透明度值设置为 0.02,但是即使我将鼠标悬停也可以看到工具提示,是否可以只显示所选行的工具提示,我的完整代码如下

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.6.0.json",
  "title": "Model Dashboard",
  "data": {
    "url" : {
        "%context%": true,
        "index": "creditloan.ml_models_v2.comparison",
        "body": {
          "size":10000,
          "_source": ["Metrics","Value","modelName","modelAlgorithm","modelStartTime"],
        }
      }  
      "format": {"property": "hits.hits"},
  }, 
 "transform": [{
      "filter": "datum._source.Value <= 1.0"
     }],
 "mark": {
    "type": "line",
    "point": {
      "size": 250
    }
    "strokeWidth": 4,
    "strokeCap" : "round",
    "interpolate" :"monotone"
  },
 "selection": {
    "industry": {
      "type": "multi", "fields": ["_source.Metrics"], "bind": "legend"
    }
  },
 "encoding": {
    "x": {"field": "_source.modelStartTime", 
          "type": "nominal", 
          "title":"Models"
          "axis": {
            "labelAngle": -20,
            "labelLimit": 500,
            "labelFontSize" : 14
            },
          "sort": {"order": "descending", "field": "_source.modelStartTime"}  
          },
    "y": {"field": "_source.Value", 
          "type": "quantitative", 
          "title":"Metric Score",
          "scale": { "domain": [0.0, 1.0] }  
          },
    "color": {"field": "_source.Metrics", 
              "type": "nominal", 
              "title":"Metrics"},
    "tooltip": [
      {"field": "_source.Metrics", "type": "nominal", "title":"Metric"},
      {"field": "_source.Value", "type": "quantitative", "title":"Value"},
      {"field": "_source.modelAlgorithm", "type": "nominal", "title":"ModelAlgorithm"},
      {"field": "_source.modelStartTime", "type": "nominal", "title":"ModelStartTime"},
      {"field": "_source.modelName", "type": "nominal", "title":"ModelName"}
    ],
    "opacity": {
      "condition": {"selection": "industry", "value": 1},
      "value": 0.02
    }
  }
}

要使工具提示不显示隐藏数据,您可以根据选择过滤数据;即将此添加到您的转换列表中:

{"filter": {"selection": "industry"}}

然后移除不透明度编码。