2012-03-29 2 views
3

나는이 일을 어떻게 할 수 있었는지 여러 곳을 찾으려고 노력했다.DOJO onclick 드릴 다운을위한 원형 차트 슬라이스

요구 사항은 파이의 조각을 클릭하여 드릴 다운하는 것입니다. 나는 onclick을 얻을 수 있지만 차트에서 가치를 얻는 방법을 모르겠습니다. 어디서나 http://www.sitepen.com/blog/2008/05/27/dojo-charting-event-support-has-landed/을 가리키고 있지만 라이브 데모는 어디에도 없습니다. 지금까지 나는 onclick을 얻을 수 있었다.

chart.addSeries("Monthly Sales - 2010", chartData); 
var h = chart.connectToPlot("default", function(o){ 
if(o.type == "onclick"){ 
alert("clicked!"); 
    } 
}); 

답변

2
var store = new dojo.store.Memory({data: [ 
    { id: '2', value: 10, usedForDrillDown:'x' }, 
    { id: '3', value: 5, usedForDrillDown: 'y' }, 
    { id: '4', value: 8, usedForDrillDown:'z' } 
]}); 
// adapter needed, because the chart uses the dojo.data API 
var storeAdapter = new dojo.data.ObjectStore({ 
    objectStore: store 
}); 

var ds = new dojox.charting.DataSeries(
     storeAdapter/*, { query: { needed if the store contains more than data points } }*/); 

var chart = new dojox.charting.Chart("chart"); 
chart.addPlot("default", { type: "Pie" }); 
chart.addSeries("default", ds); 

chart.connectToPlot("default", function(evt) { 
    if(evt.type == "onclick"){ 
     var itm = evt.run.source.items[evt.index]; 
     console.dir(itm); 
    }  
}); 

chart.render(); 
+0

원형 차트 조각에서 드릴 다운을 위해 그 조각을위한 ID가 필요합니다. 그래서 내 chartData가 {id1, value1}, {id2, value2}라고 가정하면 value1을 클릭하면 id1을 얻는 방법을 알아야합니다. –

+0

데이터 저장소를 사용하여 차트 데이터를 제공합니다. 그것은 상점에서 자바 스크립트 개체이며 거기에서 내려와 드릴 필요가있는 모든 속성이 있습니다. –

+0

예가 있습니까? –