amChart total values of graphics

六月ゝ 毕业季﹏ 提交于 2019-12-13 03:51:16

问题


I want to write all of the total values in some where in graphics. My graphics may be column or stacked chart. How can I calculate all summ values in data and write?

"dataProvider": [ {
    "country": "USA",
    "visits": 2025
  }, {
    "country": "China",
    "visits": 1882
  }, {
    "country": "Japan",
    "visits": 1809
  } ]

Or stacked data

"dataProvider": [{
            "year": 2003,
            "europe": 2.5,
            "namerica": 2.5,
            "asia": 2.1,
            "lamerica": 0.3,
            "meast": 0.2,
            "africa": 0.1
        }, {
            "year": 2004,
            "europe": 2.6,
            "namerica": 2.7,
            "asia": 2.2,
            "lamerica": 0.3,
            "meast": 0.3,
            "africa": 0.1
        }, {
            "year": 2005,
            "europe": 2.8,
            "namerica": 2.9,
            "asia": 2.4,
            "lamerica": 0.3,
            "meast": 0.3,
            "africa": 0.1
        }]
  • Column chart
  • Stacked chart

Or is it possible to write in legend like this: "General Sum: 1254"


回答1:


Set totalText in the value axis to generate a sum of the stack:

AmCharts.makeChart("chartdiv", {
  // ...
  valueAxes: [{
    // ...
    totalText: "Total: [[total]]"
  }],
  // ...
});

Demo

For single columns, try periodValueText in the legend.

AmCharts.makeChart("chartdiv", {
  // ...
  legend: {
    // ...
    periodValueText: "Selection total: [[value.sum]]"
  }
  // ...
});

Note this shows the sum of the columns in selected period/zoom for a particular graph.

Demo



来源:https://stackoverflow.com/questions/47721953/amchart-total-values-of-graphics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!