如何为 amChart 设置 x-axis 的标题和 y-axis 的名称?

How to set title of x-axis and y-axis name for amChart?

在 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",
  } ],
} );

不过,您可以对图表配置使用 title parameters for each of the axis. You will need to add 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"
  } ]
} );