0

我想知道是否可以像这样将“字符串”传递给 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!

jsfiddle

使用这个配置我有这个错误 Uncaught TypeError: testScale.invert is not a function

谢谢!!

4

1 回答 1

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!
于 2019-09-19T12:53:58.497 回答