nani
nani

Reputation: 21

how to create click event in am charts?

var chart = var chart = AmCharts.makeChart( "chartdiv", {
  "type": "pie",
  "theme": "light",
  "dataProvider": [ {
    "title": "petrol",
    "value": 3540
  }, {
    "title": "Diesel",
    "value": 1320
  } ],
  "titleField": "title",
  "valueField": "value",
  "labelRadius": 5,

  "radius": "42%",
  "innerRadius": "60%",
  "labelText": "[[title]]",
  "export": {
    "enabled": true
  }
} );.makeChart( "chartdiv", {
      "type": "pie",
      "theme": "light",
      "dataProvider": [ {
        "title": "petrol",
        "value": 3540
      }, {
        "title": "Diesel",
        "value": 1320
      } ],
      "titleField": "title",
      "valueField": "value",
      "labelRadius": 5,

      "radius": "42%",
      "innerRadius": "60%",
      "labelText": "[[title]]",
      "export": {
        "enabled": true
      }
    } );

how to create click event in am-charts using java-script event in petrol.

Upvotes: 1

Views: 1825

Answers (2)

slothluvchunk
slothluvchunk

Reputation: 412

AM Charts supports many different events and native event handlers for different Chart Objects like Legends, Value/Category Axes, Charts, etc.

For the "pie" chart type used in your example, there is a clickSlice event triggered anytime someone clicks on one of the pie slices.

First you need to add a listener to your chart object, so that you can grab that event when it fires:

// add click listener
chart.addListener("clickSlice", handle_slice_click);

And then you will need to add the actual handler for that event:

function handle_slice_click(event)
{
    // handle your event here
}

If you can add some more information about what you're trying to accomplish, we might be able to help in a more specific way.

If you'd like to see all of the events available within the v3 Pie chart, there's more info here.

Upvotes: 0

Yoplaboom
Yoplaboom

Reputation: 554

Regarding the doc, you may have an option clickGraphand clickGraphItem.

AmCharts Doc

Upvotes: 1

Related Questions