简体   繁体   English

D3Plus标题修改

[英]D3Plus Header Modification

I am trying to change the hovertext displayed during a mouseover in D3Plus. 我试图在D3Plus中更改鼠标悬停期间显示的hovertext。 Specifically, I delete the title associated with a set of data. 具体来说,我删除了与一组数据相关的标题。 Here is a photo to describe what I mean, where the red circle denotes the area of my interest: 这是一张描述我的意思的照片,红色圆圈表示我感兴趣的区域:

在此输入图像描述

I have found that I can change all of the elements listed inside of the tooltip so far beside the main header as I would call it. 我发现我可以改变主要标题旁边的工具提示中列出的所有元素,就像我所说的那样。 I have been searching online on various resources and I have not yet found documentation on this subject. 我一直在网上搜索各种资源,我还没有找到关于这个主题的文档。 the ".tooltip(["name"])" was a test. “.tooltip([”name“])”是一个测试。 My code is as follows 我的代码如下

<script>
    var sample_data = [
        {"value": 100, "name": "alpha", "growth": 0.9},
        {"value": 70, "name": "beta", "growth": 0.4},
        {"value": 40, "name": "gamma", "growth": -0.3},
        {"value": 15, "name": "delta", "growth": -0.65},
        {"value": 5, "name": "epsilon", "growth": 0.7},
        {"value": 1, "name": "zeta", "growth": 0.2}
    ];
    var visualization = d3plus.viz()
        .container("#viz")
        .data(sample_data)
        .type("tree_map")
        .id("name")
        .value(["name"])
        .tooltip(["name"])
        .size("value")
        .color(function(d){
          return d.growth > 0 ? "#008800" : "#880000";
        })
        .draw();
</script>

You can set a specific key to be used for all labels, which includes both the tooltip titles and the labels on the tree map squares, like this: 您可以设置要用于所有标签的特定键,其中包括工具提示标题和树图方块上的标签,如下所示:

visualization.text("label")

Full documentation of the text method can be found here . 可以在此处找到文本方法的完整文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM