如何使用amcharts创建多环甜甜饼饼图?

时间:2015-08-31 13:44:08

标签: javascript charts amcharts

我想用AMCharts制作多环甜甜饼饼图。例如:

PreferenceFragmentCompat

1 个答案:

答案 0 :(得分:1)

我想说制作这种图表你最好使用Gauge图表类型,你可以在你的例子中定义单独的bands

这是一个有效的代码:

var gaugeChart = AmCharts.makeChart("chartdiv", {
  "type": "gauge",
  "axes": [{
    "axisAlpha": 0,
    "tickAlpha": 0,
    "labelsEnabled": false,
    "startAngle": -150,
    "endAngle": 150,
    "bands": [{
      "color": "#8da44c",
      "endValue": 50,
      "startValue": 0,
      "radius": "100%",
      "innerRadius": "95%",
      "balloonText": "Lime one"
    }, {
      "color": "#ce0004",
      "endValue": 30,
      "startValue": 0,
      "radius": "90%",
      "innerRadius": "85%",
      "balloonText": "Red one"
    }],
    "endValue": 100
  }],
  "allLabels": [{
    "text": "3,000",
    "align": "center",
    "y": "45%",
    "size": 35
  }]
});
<script src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="http://www.amcharts.com/lib/3/gauge.js"></script>
<div id="chartdiv" style="width: 100%; height: 300px;"></div>