Amcharts没有显示具有最高价值的balloonText

时间:2017-09-18 16:03:31

标签: javascript amcharts

我正在使用Amcharts插件中的3D Stacked Column Chart。输出正确但无法在条形图上查看最高值。Amchart Of Bench

当我尝试将鼠标悬停在最高值时,标签不会显示。 下面是amcharts脚本。

__eq__

2 个答案:

答案 0 :(得分:1)

默认行为是,如果没有空间,则不显示气球(3d图表有点需要)。您可以通过将值轴中的minMaxMultiplier设置为小因子来增加值轴的最大值来解决此问题;如果您的数据始终为正数以避免负轴,则您希望强制minimum为0。



var chart = AmCharts.makeChart("chartdiv", {
  "theme": "light",
  "labelText": "[[title]]: [[value]]",
  "type": "serial",
  "dataProvider": [{
      "backed": 113,
      "backless": 56,
      "Borough": "Manhattan"
    },
    {
      "backed": 190,
      "backless": 64,
      "Borough": "Bronx"
    },
    {
      "backed": 127,
      "backless": 38,
      "Borough": "Brooklyn"
    },
    {
      "backed": 135,
      "backless": 50,
      "Borough": "Queens"
    },
    {
      "backed": 105,
      "backless": 31,
      "Borough": "Staten Island"
    }
    //Lower Manhattan is not a separate borough ;)
  ],
  "titles": [{
    "text": "Benches Classification by Borough",
    "size": 16
  }],
  "valueAxes": [{
    "stackType": "3d",
    "unit": "",
    "position": "left",
    "title": "Bench Counts:",
    "minMaxMultiplier": 1.05,
    "minimum": 0
  }],
  "startDuration": 1,
  "graphs": [{
      "balloonText": "backless : [[value]]",
      "fillAlphas": 0.9,
      "lineAlpha": 0.2,
      "title": "backless",
      "type": "column",
      "valueField": "backless"
    },
    {
      "balloonText": "backed:[[value]]",
      "fillAlphas": 0.9,
      "lineAlpha": 0.2,
      "title": "backed",
      "type": "column",
      "valueField": "backed"
    }
  ],

  "plotAreaFillAlphas": 0.1,
  "depth3D": 73,
  "angle": 60,
  "categoryField": "Borough",
  "categoryAxis": {
    "gridPosition": "start"
  },
  "export": {
    "enabled": 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>
<script type="text/javascript" src="//www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv" style="width: 100%; height: 300px"></div>
&#13;
&#13;
&#13;

另一种方法是使用外部div创建自己的气球,并利用rollOverGraphItemrollOutGraphItem事件来触发气球。在AmCharts&#39;中就是一个例子。 knowledge base

答案 1 :(得分:0)

标签可能在视图之外。您可以右键单击以检查图表以查看标签是否存在。

尝试在顶部添加一些保证金?

chart.marginTop = 20;