javascript - 在 amCharts 中隐藏我的 balloonText 旁边显示的值

标签 javascript html css amcharts

我将首先向您展示我的问题的图片:

当我将鼠标放在我的实时 amChart 的任何一点上时,如图片右侧所示,不仅会显示气球文本,还会显示其标签旁边的 x 轴值! 但我不希望数字显示在那里。 我该如何解决?

这是我的代码:

                    "graphs": [{
                        "id": "g1",
                        "balloonText": "<img src='javascripts/images/info.png' style='vertical-align:bottom; margin-right: 5px; width:28px; height:21px;'><span style='font-size:10px; color:#000000;'><b>[[value]]</b></span><img src='javascripts/images/time.png' style='vertical-align:bottom; margin-right: 5px; width:28px; height:21px;'><span style='font-size:10px; color:#000000;'><b>[[category]]</b></span>",
                        "lineColor": colors[c++],
                        "lineThickness": 1.5,
                        "negativeLineColor": "#637bb6",
                        "type": "smoothedLine",
                        "valueField": "value",
                        "title": Ctitle[num] + "_a"
                    }, {
                        "id": "g2",
                        "balloonText": "<img src='javascripts/images/info.png' style='vertical-align:bottom; margin-right: 5px; width:28px; height:21px;'><span style='font-size:10px; color:#000000;'><b>[[value]]</b></span><img src='javascripts/images/time.png' style='vertical-align:bottom; margin-right: 5px; width:28px; height:21px;'><span style='font-size:10px; color:#000000;'><b>[[category]]</b></span>",
                        "lineColor": colors[c++],
                        "lineThickness": 1.5,
                        "negativeLineColor": "#637bb6",
                        "type": "smoothedLine",
                        "valueField": "value2",
                        "title": Ctitle[num] + "_b"
                    }, {
                        "id": "g3",
                        "balloonText": "<img src='javascripts/images/info.png' style='vertical-align:bottom; margin-right: 5px; width:28px; height:21px;'><span style='font-size:10px; color:#000000;'><b>[[value]]</b></span><img src='javascripts/images/time.png' style='vertical-align:bottom; margin-right: 5px; width:28px; height:21px;'><span style='font-size:10px; color:#000000;'><b>[[category]]" + new Date().toJSON().slice(0, 10).replace(/-/g, '/') + "</b></span>",
                        "lineColor": colors[c++],
                        "lineThickness": 1.5,
                        "negativeLineColor": "#637bb6",
                        "type": "smoothedLine",
                        "valueField": "value3",
                        "title": Ctitle[num] + "_c"
                    }],

                    "legend": {
                        "position": "right",
                        "marginLeft": 20,
                        "autoMargins": false,
                        "marginBottom": 40,
                    },

                })

提前谢谢你。

最佳答案

要在鼠标悬停时隐藏图例中的值,请设置图例的 valueText属性为空字符串:

legend: {
  // ...
  valueText: ""
}

下面的演示:

var chart = AmCharts.makeChart("chartdiv", {
  "type": "serial",
  "legend": {
    "valueText": ""
  },
  "dataProvider": [{
    "date": "2017-06-23",
    "value": 4
  }, {
    "date": "2017-06-24",
    "value": 12
  }, {
    "date": "2017-06-25",
    "value": 7
  }, {
    "date": "2017-06-26",
    "value": 13
  }, {
    "date": "2017-06-27",
    "value": 2
  }, {
    "date": "2017-06-28",
    "value": 14
  }, {
    "date": "2017-06-29",
    "value": 12
  }, {
    "date": "2017-06-30",
    "value": 9
  }, {
    "date": "2017-07-01",
    "value": 16
  }, {
    "date": "2017-07-02",
    "value": 1
  }, {
    "date": "2017-07-03",
    "value": 9
  }, {
    "date": "2017-07-04",
    "value": 10
  }, {
    "date": "2017-07-05",
    "value": 16
  }, {
    "date": "2017-07-06",
    "value": 10
  }, {
    "date": "2017-07-07",
    "value": 8
  }, {
    "date": "2017-07-08",
    "value": 17
  }, {
    "date": "2017-07-09",
    "value": 15
  }, {
    "date": "2017-07-10",
    "value": 9
  }, {
    "date": "2017-07-11",
    "value": 16
  }, {
    "date": "2017-07-12",
    "value": 4
  }],
  "graphs": [{
    "valueField": "value",
    "title": "graph",
    "bullet": "round"
  }],
  "chartCursor": {},
  "categoryField": "date",
  "dataDateFormat": "YYYY-MM-DD",
  "categoryAxis": {
    "parseDates": true
  }
})
<script type="text/javascript" src="//www.amcharts.com/lib/3/amcharts.js"></script>
<script type="text/javascript" src="//www.amcharts.com/lib/3/serial.js"></script>
<div id="chartdiv" style="width: 100%; height: 200px"></div>

关于javascript - 在 amCharts 中隐藏我的 balloonText 旁边显示的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45862247/

相关文章:

javascript - 从另一个页面上的 HTML 表单访问值

javascript - 访问 angularjs 中自定义指令内 Controller 中定义的函数

Javascript 和 onbeforeunload?

javascript - 尝试创建一个简单的函数来更改我页面的背景颜色

jquery - 如何使用CSS设置元素的响应式背景图像?

javascript - 侧导航无法后退

javascript - 错误 TS2339 : Property 'imageID' does not exist on type 'HTMLElement'

javascript - Meteor动态创建对象并引用它们?//有没有简单的方法来做到这一点

javascript - CSS对齐被推到页面底部

javascript - 如何像 Windows 资源管理器一样并排调整两个 div 的大小