简体   繁体   English

D3plus选项对图表没有影响

[英]D3plus options having no effect on chart

I originally posted this on the D3plus Google group but haven't recieved any response, so seeing if anyone here knows anything. 我最初将其发布在D3plus Google小组中,但未收到任何回复,因此请查看此处是否有人知道。

I've created a Treemap using D3plus and would like to edit the tooltip. 我已经使用D3plus创建了一个Treemap,并且想要编辑工具提示。 I'd like to add a % suffix to one of the values and I'd like to remove the 'share' line altogether. 我想在其中一个值中添加一个%后缀,并希望完全删除“共享”行。 I'd also like to change the global font size. 我还想更改全局字体大小。

Here are the variables I've added... 这是我添加的变量...

var visualization = d3plus.viz()
.container("#viz")
.data(sample_data)
.type("tree_map")
.id("name")
.size("value")
.font( {"size":10 } )//to change font size
.color("growth")
.format({

  "number": function(number, key) {

    var formatted = d3plus.number.format(number, key)

    if (key === "growth") {
      return formatted + " %"
    }
    else {
      return formatted
    }

  }
}) // to add prefix
.draw()


});

They seem to have no effect whatsoever 他们似乎没有任何作用

Here is a link to my chart... http://thetally.efinancialnews.com/tallyassets/pensions2/index.html Maybe I've made a mistake in the order I call the code or something but I'm really stuck, 这是指向我的图表的链接... http://thetally.efinancialnews.com/tallyassets/pensions2/index.html也许我在调用代码或某些东西的顺序上犯了一个错误,但我确实陷入困境,

Thanks in advance for any ideas 预先感谢您的任何想法

Check the key variable, that d3plus passes to the function you provide for the number formatting. 检查键变量,确保d3plus传递给您提供的用于数字格式的功能。 It's an object. 这是一个对象。 To check against your "growth" key use key.key: 要检查您的“增长”密钥,请使用key.key:

.format({

  "number": function(number, key) {

    var formatted = d3plus.number.format(number, key)

    if (key.key === "growth") {
      return formatted + " %"
    }
    else {
      return formatted
    }

  }
})

To remove the "share" line in the tooltip use the corresponding key: 要删除工具提示中的“ share”行,请使用相应的键:

.tooltip({
    "share": false
})  

Unfortunately I could not change the font size - only changing the font family seems to work ... 不幸的是,我无法更改字体大小-只有更改字体系列才行。

.font({ "family": "Times" })

I think in the place of .font( {"size":10 } ) you should put .font( {"size":10,"resize"=false } ) in your code because, By default it is true and u can't change the size if the resize is activated. 我认为应该在代码中放置.font( {"size":10 } )不是.font( {"size":10,"resize"=false } ) ,因为默认情况下,它是true,并且您可以如果激活了调整大小,则不要更改大小。
I hope that could help 希望对您有所帮助

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

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