5

I am trying to work out dataContext use in recently released Gantt charts.
I want some extra information to be displayed / an event to be fired when user clicks on a bar. I saw how it can be done with a serial graph but I can't make it work for my Gantt chart.

I have:

chart.addListener("clickGraphItem", function (event) {
    console.log(event.item.dataContext.property);  
});

and my dataProvider is like this:

"dataProvider": [ {
    "category": "John",
    "property": 122,
    "segments": [ {
        "start": 7,
        "duration": 2,
        "color": "#7B742C",
        "task": "Task #1"
    }, {
        "duration": 2,
        "color": "#7E585F",
        "task": "Task #2"
    }, {
        "duration": 2,
        "color": "#CF794A",
        "task": "Task #3"
    } ]
}];

Output is always "undefined", I must be missing something. I pasted my code in this jsfiddle: http://jsfiddle.net/tholz/ah0kcxjn/1/, it's the example taken from Gantt Demo of Amcharts site.

Any tip?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
J To
  • 51
  • 2
  • It's not possible with the current version of Gantt chart, because it just reformats the values to a floating bar chart. However, the next version will have a reference to the original segment object in dataContext. Someone from amCharts will add comment here when the new version is available. – martynasma Jun 22 '15 at 16:25

2 Answers2

0

We added url property for GaugeBand which allows to add link on a band, also rollOverBand/rollOutBand/clickBand events for GaugeAxis. (version 3.14.5)

zeroin
  • 5,863
  • 6
  • 31
  • 42
  • I can't see how Gauge Bands are linked with Gantt charts. I saw in [changelog 3.14.5](http://www.amcharts.com/javascript-charts/changelog/) that _segmentData_ was added to AmGraph. (Works with AmGanttChart only and holds reference to original segment object from data provider) but it is not clear to me how this could solve my problem (I have 1 graph and several bars/graphDataItems) – J To Jun 30 '15 at 16:03
0
chart.addListener("clickGraphItem", function (event) {
    console.log(event.item.dataContext)
});

enter image description here

moh
  • 63
  • 6