为什么.domain,tickFormat和tickValues在维度变量中无法识别? (d3,平行坐标)

时间:2016-09-14 02:20:08

标签: javascript d3.js plot

我正在使用d3.js创建一个平行坐标图,但我正在努力按照我的意愿格式化轴标记。

例如,我的一个轴“缓冲浓度”是在对数刻度上绘制的,我已经通过维度变量指定了它,就像这样。

var dimensions = [
  ...
  {
    key: "b.Conc",
    description: "Buffer Concentration",
    type: types["Number"],
    scale: d3.scale.log().domain([.1, 100]).range([innerHeight, 0]),
    tickValues: [.1,.2,.4,.6,.8,1,2,4,6,8,10,20,40,60],
    tickFormat: d3.format(4,d3.format(",d"))
  },
  ...
];

但是,正如您从下面的结果图中可以看到的,我尝试指定显示哪些刻度标签(通过tickValues)并且它们显示为普通数字而不是10的幂(通过{{1 }}不工作。此外,轴不会跨越tickFormat中指定的域;它应该是[0.1,100],而不是[0.1,60]。

为什么会这样?

Section of Parallel Coordinates Plot

代码

我的情节的data.csv,index.html和style.css文件可以找到here。在本地打开时,它[仅]在Firefox中运行。

提前感谢您的帮助,如果我遗漏了一些基本的东西,我会道歉 - 我是d3的新手。

1 个答案:

答案 0 :(得分:3)

您似乎忘记将自定义刻度和刻度值应用于此行中生成的比例:https://gist.github.com/LThorburn/5f2ce7d9328496b5f4c123affee8672f#file-index-html-L189

不确定,但这样的事情会有所帮助。

    if (d.tickValues) {
      renderAxis.tickValues(d.tickValues);
    }

    if (d.tickFormat) {
      renderAxis.tickFormat(d.tickFormat);
    }