amchart一切元素都需要由 amchart 参数控制
CSS可以控制
#chartdiv {
width: 100%;
height: 100%;
font-size: px;
}
div内不可有任何CSS元素
<div id="chartdiv"></div>
否则会出现闪烁问题
原始代碼如下
AmCharts.ready(function () {
var aj = $.ajax({
type: "GET",
dataType: "json",
contentType: "application/json;charset=utf-8",
url: "UR",
success: function (data) {
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "none",
"useGraphSettings": true,
"legend": {
"horizontalGap": 0,
"maxColumns": 2,
"position": "bottom",
"useGraphSettings": true,
"markerSize": 20,
"align": "center",
"fontSize": 20
},
"allLabels": [{
"text": "頭標題",
"align": "center",
"bold": true,
"size": 20,
"y": 10
}],
"marginTop": 50,
"dataProvider": data,
"valueAxes": [{
"axisAlpha": 0,
"position": "left"
}],
"startDuration": 0,
"graphs": [{
"balloonText": "(ajax json獲取元素)",
"lineColor": "#4472C4",
"fillAlphas": 0.9,
"lineAlpha": 0.2,
"type": "column",
"valueField": "(ajax json獲取元素)",
"title": "title",
"columnWidth": 0.4
}, {
"balloonText": "(ajax json獲取元素)",
"lineColor": "#ED7D31",
"fillAlphas": 0.9,
"lineAlpha": 0.2,
"type": "column",
"valueField": "(ajax json獲取元素)",
"title": "title",
"columnWidth": 0.4
}],
"categoryField": "date",
"categoryAxis": {
"gridPosition": "start",
"labelRotation": 45
},
"export": {
"enabled": true
}
});
},
error: function () {
alert("");
}
});