2016-10-01 8 views
1

を動作するようにカスタム色としきい値を取得: https://cdn.rawgit.com/hkelly93/d3-relationshipGraph/master/examples/index.htmlこの例に基づき、D3 RelationshipGraphで

D3は私がこのチャートを作成し、値が色を変更したときの色としきい値を定義できるようにする必要があります。この関数はいくつかのカスタム設定を受け入れます:

var graph = d3.select('#graph').relationshipGraph({ 
    maxChildCount: 10, 
    valueKeyName: 'Story title', 
    thresholds: [6, 8, 10], 
    colors: ['red', 'yellow', 'green'], 
    showTooltips: true 
}) 

しかし、3つの範囲すべてにデータフィッティングをロードすると、3色のグラフが表示されません。私は0-6が赤、7-8が黄色、9-10が緑色に見えるようにします。ここでロードされたデータ(抜粋)があります:他に

[ 
{"parent": "2012-October", "organization": "WEWASAFO", "value": 10, "Story title": "NUTRITION"}, 
{"parent": "2012-April", "organization": "Jitegemee", "value": 5, "Story title": "Life in the street"}, 
{"parent": "2011-May", "organization": "KENYA YOUTH BUSINESS TRUST (KYBT)", "value": 2, "Story title": "BUSINESS"} 
] 

すべてが同じチャート上のカスタムカラーカスタムしきい値を組み合わせることを除いて、正しく解析します。いずれか一方だけで動作しますが、両方では動作しません。

ソースレポは、いくつかのドキュメントとここにある:その文書から https://github.com/hkelly93/d3-relationshipgraph

thresholds: [100, 200, 300], // The thresholds for the color changes. If the values are strings, the colors are determined by the value of the child being equal to the threshold. If the thresholds are numbers, the color is determined by the value being less than the threshold. 
colors: ['red', 'green', 'blue'], // The custom color set to use for the child blocks. These can be color names, HEX values, or RGBA values. 

これは、明示的に子供の色はしきい値が表示される順序に対応する状態はありません。この例では、すべてのブロックが赤く表示されています。

私はここのコードをテストした:https://jsfiddle.net/cgrx3e9m/

答えて

1

これは、モジュール自体のバグであることが判明しました。私は著者に通知し、スレッシュホールドをソートする方法を修正して、対応する色と今一致させました。

+1

彼は私の要求の数分以内にバグ修正をプッシュしました!すばらしいオープンソースのカスタマーサービス! –

関連する問題