2017-09-01 42 views

回答

1

看起來像是有an option for this in d3v4,所以這會變得更容易when dc.js is upgraded

現在,我們可以猜測d3v3正在做什麼,並使用pretransition event handler在刷子渲染前修改它們。我們也可以替換視覺表示。

在D3V3,刷寬度似乎是硬6與x的偏移-3編碼:

inspect brush in devtools

我無法解釋爲什麼這似乎與右刷柄完全一致但是對於左刷柄來說似乎只有幾個像素。在實驗中,似乎偏移量應該爲左(西)句柄爲-6,右爲(東)句柄爲0,所以dc.js可能會受益於此處顯示的技術。

無論如何,讓我們加倍寬度。我們轉變前處理程序將寬度設置爲12,並設置偏移-12西部和0東部手柄:

spendHistChart.on('pretransition.bighandle', function(chart) { 
     chart.selectAll('g.brush .resize.w rect') 
      .attr('x', -12) 
      .attr('width', 12); 
     chart.selectAll('g.brush .resize.e rect') 
      .attr('x', 0) 
      .attr('width', 12); 
    }); 

現在,樂趣和獎勵積分,我們也可以使手柄更大。這裏是a previous answer where we modified the brush path

同樣,我們可以覆蓋resizeHandlePath,基本上每雙X座標,以及加倍組成手柄的頂部和底部的圓弧的高度:

dc.override(spendHistChart, 'resizeHandlePath', function (d) { 
     var e = +(d === 'e'), x = e ? 1 : -1, y = spendHistChart.effectiveHeight()/3; 
     return 'M' + (0.5 * x) + ',' + y + 
      'A12,12 0 0 ' + e + ' ' + (13 * x) + ',' + (y + 12) + 
      'V' + (2 * y - 12) + 
      'A12,12 0 0 ' + e + ' ' + (1 * x) + ',' + (2 * y) + 
      'Z' + 
      'M' + (5 * x) + ',' + (y + 14) + 
      'V' + (2 * y - 14) + 
      'M' + (9 * x) + ',' + (y + 14) + 
      'V' + (2 * y - 14); 
    }); 

,瞧!大把手可以抓住很多區域:

enter image description here