2017-03-15 11 views
6

D3 코스튬 차트에서 선택 도구로 시각화를 사용하려고합니다. SDK 설명서를 따르고 있습니다. 예제를 만들 수 없습니다.Microstrategy 시각화를 선택기로 사용 D3 costum chart

기본적으로 "나"var을 선언하고 "필터로 사용"옵션을 사용하도록 설정합니다. 추가 할 때

var data = this.dataInterface.getRawData(mstrmojo.models.template.DataInterface.ENUM_RAW_DATA_FORMAT.TREE, { 
    hasSelection: true 
}).children; 

그리고 : 데이터를 가져 오는 경우

var g = d3.select(this.domNode).append("svg") 
    .attr("width", width + margin.left + margin.right) 
    .attr("height", height + margin.top + margin.bottom) 
    .append("g") 
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")") 
    .on("click", function(d) { 
     if (event.target.classList.contains('bar')) { 
      me.clearSelections(); 
      me.endSelections(); 
      return true; 
     } else { 
      return true; 
     } 
    }); 

내가 hasSelection 속성을 사용 : 드 SVG 요소를 추가 할 때

var me = this; 
this.addUseAsFilterMenuItem(); 

그런 다음, 나는 명확하고 최종 selecion 방법을 추가 내 바의 "applyselection"메소드 :

g.selectAll(".bar") 
.data(data) 
.enter() 
.append("rect") 
.attr("class", "bar") 
.attr("x", function(d) { 
    return x(d.name); 
}) 
.attr("y", function(d) { 
    return y(d.value); 
}) 
.attr("height", function(d) { 
    return height - y(d.value); 
}) 
.attr("width", x.rangeBand()) 
.style("fill", function(d) { 

}) 
.on("click", function(d) { 
    me.applySelection(d.selection); 
}); 

하지만 작동하지 않습니다. 나는 bar click 이벤트에서 d.selection을 콘솔로 관리한다.

제발 좀 도와주세요.

감사합니다.

답변

2

많은 시간을이 코드에 쓰고 나면 내 코드가 잘못되었음을 알 수있었습니다. 선택 방법은 다음과 같이 호출해야합니다.

.on("click", function(d, i) { 
    me.applySelection(data[i].attributeSelector); 
    return true; 
});