【发布时间】:2025-12-21 02:15:07
【问题描述】:
我需要能够在图表中绘制一条垂直线,并且使用以下信息似乎很容易:http://www.amcharts.com/tutorials/vertical-or-horizontal-lines-or-fill-ranges/
但是,我没有找到将 CategoryAxis 属性添加到现有图表的方法。
【问题讨论】:
标签: amcharts
我需要能够在图表中绘制一条垂直线,并且使用以下信息似乎很容易:http://www.amcharts.com/tutorials/vertical-or-horizontal-lines-or-fill-ranges/
但是,我没有找到将 CategoryAxis 属性添加到现有图表的方法。
【问题讨论】:
标签: amcharts
如果您使用基于对象的配置,当您创建图表实例时,它已经设置了 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
// ...
};
【讨论】: