简体   繁体   English

工具提示未在 Vue echarts 上显示

[英]Tooltip not showing on Vue echarts

I have a simple line chart built using vue-echarts, it works fine but I want to show a tooltip on each white dot on hover: https://imgur.com/a/2aUPkXf我有一个使用 vue-echarts 构建的简单折线图,它工作正常,但我想在 hover 上的每个白点上显示一个工具提示: https://imgur.com/a/2aUPkXf

and for some reason the tooltip does not show when I hover on the dots, despite the fact that I have added it as a property to my configuration.并且由于某种原因,当我在点上使用 hover 时,工具提示没有显示,尽管我已将其作为属性添加到我的配置中。 Why and how can I make my tooltip show?为什么以及如何使我的工具提示显示? Here is my code:这是我的代码:

       <div class="chart-wrapper">
          <chart  :options="chartOptionsLine "></chart>
        </div>
</script>

and my js:和我的js:

<script>
export default {
  name: "BalanceCard",
  props: ["title", "heading"],
  data() {
    return {
      chartOptionsLine: {
        xAxis: {
          data: [
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
            "9",
            "10",
            "11",
            "12",
            "13",
            "14",
            "15",
            "16",
            "17",
            "18",
            "19",
            "20",
            "21",
            "22",
            "23",
            "24",
            "25",
            "26",
            "27",
            "28",
            "29",
            "30",
            "31"
          ]
        },
        yAxis: {
          type: "value",
          axisLabel: {
            formatter: function(value) {
              return value / 1000 + "k";
            }
          }
        },
        series: [
          {
            type: "line",
            data: [
              10000,
              5000,
              1000,
              800,
              7000,
              6000,
              9000,
              7,
              9,
              900,
              120,
              170,
              670,
              7000,
              20
            ]
          }
        ],

        color: ["#76B1C5"]
      },
        tooltip: {
          show: true,
          trigger: 'item',
          },
    };
  }
};

See left margin, you inserted tooltip into zero level, ie out of scope.见左边距,您将工具提示插入零级,即在 scope 之外。

强文本

Change to below and will work:更改为以下内容即可:

 var myChart = echarts.init(document.getElementById('chart')); var option = { xAxis: { data: [ "1", "2", "3", "4", "5", "6", "7", "8", "9", ] }, yAxis: { type: "value", axisLabel: { formatter: function(value) { return value / 1000 + "k"; } } }, series: [{ type: "line", data: [10000, 5000, 1000, 800, 7000, 6000, 9000, 7, 9] }], color: ["#76B1C5"], tooltip: { show: true, trigger: 'item', } }; myChart.setOption(option);
 <script src="https://cdn.jsdelivr.net/npm/echarts@5.0.0/dist/echarts.min.js"></script> <div id="chart" style="width: 600px;height:400px;"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM