Angular nvd3 圆环图 - 如何添加静态或动态标题? -

Angular nvd3 donut chart - how to add a static or dynamic title? -

我正在使用 angular nvd3-pie-chart。任何想法或建议如何在圆环图的中心添加静态或动态标题?

这是代码块。

 <nvd3-pie-chart 
    data="exampleData" id="exampleId" showLabels="true" x="xFunction()" y="yFunction()" donut="true" donutRatio=".5" donutLabelsOutside="true">

</nvd3-pie-chart>

function ExampleCtrl($scope){
            $scope.exampleData = [
                {
                    key: "One",
                    y: 5
                },
                {
                    key: "Two",
                    y: 2
                }
            ];

            $scope.xFunction = function(){
                return function(d) {
                    return d.key;
                };
            }
            $scope.yFunction = function(){
                return function(d) {
                    return d.y;
                };
            }

        }

您可以简单地使用以下内容:

title: {
enable: true,
text: 'Chart Title'
}

参考下面link: NVD3 Docs