Q:

Return value for x+axis - Amchart

I have one question for You. I would like to write a function that returns me to the x-axis value for the chart.
Chart for analysis
For example, when I click for example "Aug 24" in chart, my function return "Aug 24". 
Any ideas?

A:

You can use categoryAxis "clickItem" event for that. I.e.:
"categoryAxis": {
  "parseDates": true,
  "listeners": [{
    "event": "clickItem",
    "method": function(item) {
      alert(item.value);
    }
  }]
}

Here's a full working example:

var chartData = generateChartData();

var chart = AmCharts.makeChart( "chartdiv", {
  "type": "serial",
  "dataProvider": chartData,
  "graphs": [ {
    "lineColor": "#FCD202",
    "bullet": "square",
    "bulletBorderThickness": 1,
    "hideBulletsCount": 30,
    "title": "yellow line",
    "valueField": "value1",
    "fillAlphas": 0
  }, {
    "valueAxis": "v3",
    "lineColor": "#B0DE09",
    "bullet": "triangleUp",
    "bulletBorderThickness": 1,
    "hideBulletsCount": 30,
    "title": "green line",
    "valueField": "value2",
    "fillAlphas": 0
  } ],
  "chartScrollbar": {},
  "chartCursor": {
    "cursorPosition": "mouse"
  },
  "categoryField": "date",
  "categoryAxis": {
    "parseDates": true,
    "listeners": [{
      "event": "clickItem",
      "method": function(item) {
        alert(item.value);
      }
    }]
  }
} );

// generate some random data, quite different range
function generateChartData() {
  var chartData = [];
  var firstDate = new Date();
  firstDate.setDate( firstDate.getDate() - 20 );

  for ( var i = 0; i < 20; i++ ) {
    // we create date objects here. In your data, you can have date strings
    // and then set format of your dates using chart.dataDateFormat property,
    // however when possible, use date objects, as this will speed up chart rendering.
    var newDate = new Date( firstDate );
    newDate.setDate( newDate.getDate() + i );

    var value1 = Math.round( Math.random() * 80 ) + 500;
    var value2 = Math.round( Math.random() * 80 ) + 500;

    chartData.push( {
      date: newDate,
      value1: value1,
      value2: value2
    } );
  }
  return chartData;
}
<script src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="http://www.amcharts.com/lib/3/serial.js"></script>
<div id="chartdiv" style="width: 100%; height: 200px;"></div>

