【问题标题】:Removing total from angular nvd3 stacked area chart tooltip从角度 nvd3 堆积面积图工具提示中删除总数
【发布时间】:2016-05-18 05:30:25
【问题描述】:

我在我的网站上使用 angular-nvd3 的堆积面积图。在图形工具提示上,除了数据点之外,所有点的总和也被渲染。 如何禁用它? 我正在附上我设置的快照和图表选项。

$scope.graphOptions = {
        chart: {
            type: 'stackedAreaChart',
            height: 300,
            margin: {
                top: 20,
                bottom: 30,
                left: 40
            },
            useVoronoi: false,
            clipEdge: true,
            duration: 10,
            showLegend:false,
            useInteractiveGuideline: true,
            x: function(d){return d[0];},
            y: function(d){return d[1];},
            xAxis:{
                    //mode: 'time'
                timeformat: '',
                    showMaxMin: false,
                   position: 'bottom',
                tickFormat: function(d) {
                    return d3.time.format('%b %d')(new Date(d))
                }
            },
            yAxis: {
                tickFormat: function (val) {
                    if (val > 1000000000)
                        return Math.round(val / 1000000000) + 'Bil';
                    else if (val > 1000000)
                        return Math.round(val / 1000000) + 'Mil';
                    else if (val > 1000)
                        return Math.round(val / 1000) + 'K';
                    else
                        return Math.round(100 * val) / 100;
                }
            },
            showControls: false
                }
            }
        };

快照

【问题讨论】:

  • 最近在另一个问题中针对不同类型的图表回答了这个问题,但您可以使用$scope.graphOptions.chart.tooltip.contentGenerator 方法自定义工具提示。希望这能让你到达你需要去的地方,但如果没有,如果你设置一个显示问题的 plunker,我可以进一步帮助你。
  • 非常感谢...解决了我的问题

标签: angularjs tooltip angular-nvd3


【解决方案1】:

您只需将showTotalInTooltip: false添加到您的图表选项中

【讨论】:

    【解决方案2】:

    无需完全自定义工具提示,只需将 showTotalInTooltip: false 添加到您的配置中即可。

    $scope.graphOptions = {
            chart: {
                type: 'stackedAreaChart',
                height: 300,
                margin: {
                    top: 20,
                    bottom: 30,
                    left: 40
                },
                useVoronoi: false,
                clipEdge: true,
                duration: 10,
                showTotalInTooltip: false,
                ...
    

    【讨论】:

      猜你喜欢
      • 2014-03-21
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多