How to do wordwrap for chart labels using d3.js

后端 未结 5 453
灰色年华
灰色年华 2020-12-15 23:41

I am trying to implement the horizontal bar chart using d3.js.Some of the chart labels are too long. How to do word wrap for the chart labels on y aixs?

Source code:

5条回答
  •  一整个雨季
    2020-12-16 00:05

    Here's some code to plumb Mike Bostock's chart() function into angular-nvd3. For background, see https://github.com/krispo/angular-nvd3/issues/36.

            discretebar: {
                dispatch: {
                    renderEnd: function(e){
                        d3.selectAll(".tick text").call(wrap,_chart.xAxis.rangeBand());
                    }
                }
            },
            callback: function(chart){
                _chart = chart; //global var
            }
        }
    

提交回复
热议问题