Javascript 如何根据C3.js/D3.js图表中的阈值更改线条颜色?

Javascript 如何根据C3.js/D3.js图表中的阈值更改线条颜色?,javascript,d3.js,charts,line,c3.js,Javascript,D3.js,Charts,Line,C3.js,我有一个实际值数组,它应该只是一行,一个阈值数组,它应该是第二行。当实际值线穿过阈值线时,该部分线的颜色应改变 var图表=c3.generate({ 要点:{ r:5 }, 数据:{ x:‘x’, 栏目:[ [x',2013-01-01',2013-01-02',2013-01-03',2013-01-04'], [“实际值”,230、120、300、50], ['threshold',130280100250], ], 类型:“样条线”, 区域:{ 'threshold':[{'style'

我有一个实际值数组,它应该只是一行,一个阈值数组,它应该是第二行。当实际值线穿过阈值线时,该部分线的颜色应改变

var图表=c3.generate({
要点:{
r:5
},
数据:{
x:‘x’,
栏目:[
[x',2013-01-01',2013-01-02',2013-01-03',2013-01-04'],
[“实际值”,230、120、300、50],
['threshold',130280100250],
],
类型:“样条线”,
区域:{
'threshold':[{'style':'smash'}]
},
},
轴线:{
x:{
键入:“timeseries”,
勾选:{
格式:'%Y-%m-%d'
}
}
}
});

我不确定在
c3
中是如何完成的,但正如您在问题中提到的
d3
,您将在
d3
中使用a

见:

阈值比例中的范围始终比域多一个值

如果给定值小于域中的第一个值,则输出范围中的第一个值:

colorThresholdScale(0.02); // "#fee5d9"
colorThresholdScale(0.25); // "#fb6a4a"
colorThresholdScale(0.6); // "#a50f15"
如果输入值大于域中的第n个值,小于域中的第n+1个值,则输出范围中的第n+1个值:

colorThresholdScale(0.02); // "#fee5d9"
colorThresholdScale(0.25); // "#fb6a4a"
colorThresholdScale(0.6); // "#a50f15"
如果输入值大于域中的最后一个值,则输出范围中的最后一个值:

colorThresholdScale(0.02); // "#fee5d9"
colorThresholdScale(0.25); // "#fb6a4a"
colorThresholdScale(0.6); // "#a50f15"

我不确定在
c3
中是如何实现的,但正如您在问题中提到的
d3
,您将在
d3
中使用a

见:

阈值比例中的范围始终比域多一个值

如果给定值小于域中的第一个值,则输出范围中的第一个值:

colorThresholdScale(0.02); // "#fee5d9"
colorThresholdScale(0.25); // "#fb6a4a"
colorThresholdScale(0.6); // "#a50f15"
如果输入值大于域中的第n个值,小于域中的第n+1个值,则输出范围中的第n+1个值:

colorThresholdScale(0.02); // "#fee5d9"
colorThresholdScale(0.25); // "#fb6a4a"
colorThresholdScale(0.6); // "#a50f15"
如果输入值大于域中的最后一个值,则输出范围中的最后一个值:

colorThresholdScale(0.02); // "#fee5d9"
colorThresholdScale(0.25); // "#fb6a4a"
colorThresholdScale(0.6); // "#a50f15"

你能更具体地回答你的问题吗?您是否希望在越过“阈值”线时更改“实际值”线的颜色?请您更具体地说明您的问题?当越过“阈值”线时,您是否希望更改“实际值”线的颜色?