我用平行坐标库(基于 d3.js)表示一些数据(https://github.com/syntagmatic/parallel-coordinates#parallel-coordinates)
代码的主要功能部分如下:
var parcoords = d3.parcoords()("#example") //#example is the div for the drowing
.data(eingabe) // eingabe is the var, which contains the data
.render()
.reorderable()
.shadows()
.brushMode("1D-axes")
到目前为止一切正常:)
但现在我想隐藏平行坐标的一个特定轴;我只是不想展示它。
我希望轴被完全移除,这样它就不会占据任何位置,并且线条不会受到该维度值的影响,但我不想通过操纵数据来做到这一点。我只想操纵情节(这就是我称之为隐藏的原因)。
我搜索了 api 描述,但没有找到任何内容。我在互联网上搜索但也没有找到任何东西。但是我想我记得我看过一段代码,第一个轴被隐藏了,但我找不到了。
谁能告诉我如何隐藏轴或在哪里可以找到解决方案?
谢谢你,问候
琼斯
最佳答案
您缺少 .hideAxis(array)
方法调用,其中数组是数据集中要隐藏的确切列名的键列表。这个方法完全按照你说的做:
- “...隐藏平行坐标的一个特定轴;我只是不想显示它。”
- “我希望轴完全 [原文如此] 被移除,这样它就不会出现”
- “线条不会 [原文如此] 受到此维度值的影响,但我不想通过操纵 [原文如此] 数据来做到这一点。我只想操纵情节。”
要实现此方法,您的代码需要
var parcoords = d3.parcoords()("#example") //#example is the div for the drowing
.data(eingabe) // eingabe is the var, which contains the data
.hideAxis(["col1", "col2"])
.render()
.reorderable()
.shadows()
.brushMode("1D-axes")
注意:如果您不想隐藏任何轴,.hideAxis
可以接受一个空白数组,即 .hideAxis([])
如果你想让用户指定要删除的轴,你可以在某种更新/重绘函数中实现这个方法;否则,不可能通过 DOM 完全删除它。 通过代码执行轴隐藏是您实现所需功能的唯一选择。
要查看此方法的实际效果,请查看 API 文档,特别是位于 http://syntagmatic.github.io/parallel-coordinates/index.html#example1 的“example1”图表和代码
关于javascript - 隐藏平行坐标图的轴之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31611646/