2015-11-04 317 views
1

在amChart中如何爲圖表的X軸和Y軸標題設置自定義名稱(字符串)?如何設置amChart的x軸和y軸名稱的標題?

(水平軸和垂直軸)

var chart = AmCharts.makeChart("chartdiv", { 
    "type": "xy", 
    "pathToImages": "http://www.amcharts.com/lib/3/images/", 
    "dataProvider": chartData, 
    "mouseWheelZoomEnabled": true, 
    "graphs": [ { 
    /*"bullet": "circle", 
    "bulletSize": 8,*/ 
    "lineAlpha": 1, 
    "lineThickness": 2, 
    "fillAlphas": 0, 
    "xField": "x", 
    "yField": "y", 
    } ], 
}); 

回答

1

可以使用title參數用於每個軸的範圍。不過,您需要將valueAxes定義添加到圖表配置中。即使它們只包含title參數。

var chart = AmCharts.makeChart("chartdiv", { 
    "type": "xy", 
    "pathToImages": "http://www.amcharts.com/lib/3/images/", 
    "dataProvider": chartData, 
    "mouseWheelZoomEnabled": true, 
    "graphs": [ { 
    /*"bullet": "circle", 
    "bulletSize": 8,*/ 
    "lineAlpha": 1, 
    "lineThickness": 2, 
    "fillAlphas": 0, 
    "xField": "x", 
    "yField": "y", 
    } ], 
    "valueAxes": [ { 
    "position": "left", 
    "title": "Y axis" 
    }, { 
    "position": "bottom", 
    "title": "X axis" 
    } ] 
});