我想知道是否可以像这样将“字符串”传递到D3Plus散点图的X轴:
// sample data array
var sample_data = [
{"value": 100, "weight": .45, "type": "alpha"},
{"value": 70, "weight": .60, "type": "beta"},
{"value": 40, "weight": -.2, "type": "gamma"},
{"value": 15, "weight": .1, "type": "delta"}
]
// instantiate d3plus
var visualization = d3plus.viz()
.container("#viz") // container DIV to hold the visualization
.data(sample_data) // data to use with the visualization
.type("scatter") // visualization type
.id("type") // key for which our data is unique on
.x("type") // key for x-axis
.y("weight") // key for y-axis
.draw() // finally, draw the visualization!
在此配置下,我遇到此错误 未捕获的TypeError:testScale.invert不是函数
谢谢!
答案 0 :(得分:0)
尝试以下代码:
// instantiate d3plus
var visualization = d3plus.viz()
.container("#viz") // container DIV to hold the visualization
.data(sample_data) // data to use with the visualization
.type("scatter") // visualization type
.id("type") // key for which our data is unique on
.x("value") // key for x-axis
.y("weight") // key for y-axis
.draw() // finally, draw the visualization!