我需要能够在图表中绘制一条垂直线,并且使用此信息似乎很容易 http://www.amcharts.com/tutorials/vertical-or-horizontal-lines-or-fill-ranges/
但是,我没有找到将CategoryAxis属性添加到现有图表的方法。 谢谢
答案 0 :(得分:3)
如果您使用的是基于对象的配置,则在创建图表实例时,它已经设置了categoryAxis属性:
var chart = new AmCharts.AmSerialChart();
// chart.categoryAxis is already set and populated with a reference to CategoryAxis object
// we can set its properties, including guides
chart.categoryAxis.guides = [ {
"category": "2001",
"toCategory": "2003",
"lineColor": "#CC0000",
"lineAlpha": 1,
"fillAlpha": 0.2,
"fillColor": "#CC0000",
"dashLength": 2,
"inside": true,
""label"Rotation": 90,
"label": "fines for speeding increased"
}, {
"category": "2007",
"lineColor": "#CC0000",
"lineAlpha": 1,
"dashLength": 2,
"inside": true,
""label"Rotation": 90,
"label": "motorcycle fee introduced"
} ];
如果您使用的是基于JSON的方法,则指南配置需要进入“categoryAxis”对象:
AmCharts.makeChart( "chartdiv", {
"type": "serial",
"categoryAxis": {
"guides": [ {
"category": "2001",
"toCategory": "2003",
"lineColor": "#CC0000",
"lineAlpha": 1,
"fillAlpha": 0.2,
"fillColor": "#CC0000",
"dashLength": 2,
"inside": true,
""label"Rotation": 90,
"label": "fines for speeding increased"
}, {
"category": "2007",
"lineColor": "#CC0000",
"lineAlpha": 1,
"dashLength": 2,
"inside": true,
""label"Rotation": 90,
"label": "motorcycle fee introduced"
} ]
},
// the rest of the chart config
// ...
};