【问题标题】:D3Plus Scatter Plot X axix StringD3Plus 散点图 X 轴字符串
【发布时间】:2019-03-01 06:22:44
【问题描述】:

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

使用这个配置我有这个错误 未捕获的 TypeError:testScale.invert 不是函数

谢谢!!

【问题讨论】:

    标签: javascript string d3.js d3plus


    【解决方案1】:

    试试下面的代码:

      // 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!
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-01
      • 2019-09-02
      • 2017-08-24
      • 1970-01-01
      • 2019-07-07
      • 2021-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多