user3422637
user3422637

Reputation: 4229

How to Set Color of Column Graph On Click in amCharts?

I am trying to change color of selected column in a column graph (built using amCharts).

I have an event listener in place like this:

function handleClick(event) {

        event.item.graph.backgroundColor = "#3C3C3C"; // NOT WORKING
        display_value = event.item.graph.valueField + ": " + event.item.category + ": "  + event.item.values.value;
        console.log(display_value);

}
chart.addListener('clickGraphItem', handleClick);

This didn't work and I couldn't find any related example. I saw an example for Maps, but chart objects work differently.

Please siggest

Upvotes: 1

Views: 2699

Answers (1)

Maertz
Maertz

Reputation: 4952

you need to access the SVG element directly and change it's fill/stroke color, access like following within your event callback

event.item.bulletGraphics.node

http://codepen.io/amcharts/pen/3abea07c9fd4c1f44d3523d3dd80d489

Upvotes: 2

Related Questions