2014-05-10 3 views
0

솔루션을 찾고 있습니다. 내 문제를 해결합니다. 참조 샘플 NVD3.ORGNVD3 파이 차트에서 ID를 찾으십시오

"삭제"버튼을 클릭 할 때 _id를 찾으려고합니다. 이 코드를 작성하고 테스트했지만 작동하지는 않습니다. 누구든지 제발 도와 줄 수 있어요.

'click #delValues': function(){ 
     var name = $("#modifyChartName").val(); 
     var findId = function (name){ 
      Pie.findOne({label: name}); 
      return _id; 
     }; 
     Pie.remove({ 
      _id: findId() 
     }); 
     $("#modifyChartName").val(""); 
     $("#modifyChartValue").val(""); 
    } 

사실 저는 파이 차트에서 병아리를 치고 _id를 가져 와서 삭제를 위해 "삭제"버튼을 누르십시오.

nv.addGraph(function() { 
    var chart = nv.models.pieChart() 
     .x(function(d) { return d.label }) 
     .y(function(d) { return d.value }) 
     .showLabels(true); 

    d3.select("#chart svg") 
     .datum(data) 
     .transition().duration(1200) 
     .call(chart); 

    return chart; 
}); 

답변

0

오래된 질문은,하지만 비슷한 일을하려고이 경우에 도움이 될 해결책을 함께했다. 원형 차트의 해당 슬라이스를 마우스로 가리키면 <table> (원형 차트와 별도로 생성 됨)에 특정 행을 강조 표시하려고합니다. 나는 툴팁에 표시되는 내용을 사용자 정의 할 수 사용하고있었습니다 tooltipContent에서 pointIndex을 (점점하여이 작업을 수행 할 수 있었다.

var chart = nv.models.pieChart() 
      .tooltipContent(function (key, y, e, graph) { 
       // Get an index number of the hovered slice 
       var sliceId = e.pointIndex; 
       // Do something with that id (separate from nvd3) 
       $("#completionRate tbody tr:nth-child("+sliceId+")").addClass("info"); 
       // Customize the actual tooltip 
       return y.substring(0,y.indexOf(".")) + " Patients<br/>" + key; 
      }); 
내가 ID/인덱스를 얻을 수있는 동일한 기술을 사용하여 상상할 수

어떤 당신이 수 후 삭제 기능에 할당하는 데 사용하십시오.

관련 문제