2016-08-17 2 views
1

dc.js 차트에서 브러시 너비를 제한하고 싶습니다. 예를 들어 사용자가 X보다 작게 축소 할 수 없도록합니다. 반올림을 사용하여 작업 할 수도 있습니다. 월수로 반올림 한 시간 척도를 사용하면 사용자가 브러쉬를 2 개월 미만으로 축소시키지 않고 이산 월 경계로 스냅 할 수 있습니다. 그리고 저는 또한 하나의 값만 선택하고 그 값에 스냅할 수있는 브러시로 서수 규모와 비슷한 것을하고 싶습니다. 이것이 가능한가?dc.js (ordinal) 차트의 브러쉬 너비를 제한 하시겠습니까?

답변

2

dc.js 브러시에는 브러시의 두 끝을 돌려주는 extent()가 있습니다. 하나의 단위로 브러시를 유지

// grab the two ends of the brush 
var extent = brush.extent(); 
    if ((extent[1] - extent[0]) > myBiggestBrush) { 
    console.log("Extent too large"); 
extent[1] = extent[0] + myBiggestBrush; 
} 
//then use the extent in the brush 
d3.select("g.brush") 
    .call(brush.extent(extent)); 

- 체크 아웃 : 하나는 ... 브러시의 "범위"를 제한하는 조건을 사용하여 다음과 같은

뭔가 한쪽 끝을 감지 할 수 https://bl.ocks.org/nbremer/d8dff2fa37345d54f9e58eb74db460d0

+0

또한 [chart.round] (https://github.com/dc-js/dc.js/blob/develop/web/docs/api-latest.md#coordinategridmixinroundround-function--coordinategridmixin) 문서화되지는 않았지만 무시 무시한 [chart.extendBrush] (https://github.com/dc-js/dc.js/blob/develop/src/coordinate-grid-mixin.js#L1018-L1028), 두 브러시는 변경된 후에 브러시를 수정합니다. 에스. – Gordon