我正在尝试根据维度的值更改笔触颜色: 状态0 =红色,状态1 =格力,状态3 =橙色
我尝试使用并行坐标库:https://syntagmatic.github.io/parallel-coordinates/
有一个例子,但它是复杂的,我无法使它工作,有人可以告诉我如何应用这个简单的例子吗?
pcz = d3.parcoords()("#example")
.data(data)
.hideAxis([])
.composite("darken")
.render()
.alpha(0.35)
.brushMode("1D-axes") // enable brushing
.interactive() // command line mode
或者可能是那个简单例子中的那个?
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="d3.parcoords.js"></script>
<link rel="stylesheet" type="text/css" href="d3.parcoords.css">
<div id="example" class="parcoords" style="width:360px;height:150px"></div>
<script>
var data = [
[0,-0,0,0,0,3 ],
[1,-1,1,2,1,6 ],
[2,-2,4,4,0.5,2],
[3,-3,9,6,0.33,4],
[4,-4,16,8,0.25,9]
];
var pc = d3.parcoords()("#example")
.data(data)
.render()
.createAxes();
</script>
enter code here
答案 0 :(得分:0)
您需要在初始化时将函数传递给color参数,如:
var color = function(d) {
if (d['displacement (cc)'] < 100) {
return 'black';
} else if (d['displacement (cc)'] > 400) {
return 'red';
} else {
return 'yellow';
}
};
var parcoords = d3.parcoords()("#example")
.color(color)
.alpha(0.4);