如何使用amchart从右到左启动栏?

时间:2017-11-08 07:22:54

标签: bar-chart amcharts

我想从右侧开始水平条纹,如图所示

enter image description here

提前致谢

1 个答案:

答案 0 :(得分:0)

您需要将rotate设置为true,将类别轴“position属性设置为"right",并将值轴”reversed属性设置为{{ 1}}:

true

演示如下:

var chart = AmCharts.makeChart("chartdiv", {
  // ...
  "rotate": true,
  "categoryAxis": {
    "position": "right",
     //...
  },
  "valueAxes": [{
    "reversed": true,
    // ...
  }],
  // ...
});
var chart = AmCharts.makeChart("chartdiv", {
  "type": "serial",
  "theme": "light",
  "rotate": true,
  "categoryAxis": {
    "position": "right"
  },
  "valueAxes": [{
    "reversed": true
  }],
  "dataProvider": [{
    "country": "USA",
    "visits": 2025
  }, {
    "country": "China",
    "visits": 1882
  }, {
    "country": "Japan",
    "visits": 1809
  }, {
    "country": "Germany",
    "visits": 1322
  }, {
    "country": "UK",
    "visits": 1122
  }, {
    "country": "France",
    "visits": 1114
  }, {
    "country": "India",
    "visits": 984
  }, {
    "country": "Spain",
    "visits": 711
  }, {
    "country": "Netherlands",
    "visits": 665
  }, {
    "country": "Russia",
    "visits": 580
  }, {
    "country": "South Korea",
    "visits": 443
  }, {
    "country": "Canada",
    "visits": 441
  }, {
    "country": "Brazil",
    "visits": 395
  }],
  "graphs": [{
    "fillAlphas": 0.9,
    "lineAlpha": 0.2,
    "type": "column",
    "valueField": "visits"
  }],
  "categoryField": "country"
});
html,
body {
  width: 100%;
  height: 100%;
  margin: 0px;
}

#chartdiv {
  width: 100%;
  height: 100%;
}