【问题标题】:Angular nvd3 donut chart - how to add a static or dynamic title? -Angular nvd3 甜甜圈图 - 如何添加静态或动态标题? -
【发布时间】:2015-06-12 20:21:24
【问题描述】:

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

这里是代码块。

 <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;
                };
            }

        }

【问题讨论】:

  • 尝试准备plunker或fiddle,你可能会更快得到答案:)

标签: javascript angularjs nvd3.js angularjs-nvd3-directives


【解决方案1】:

你可以在下面简单地使用:

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

参考以下链接: NVD3 Docs

【讨论】:

  • 感谢 Ritesh 的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多