我在网页上有一个Shield UI JavaScript图表。我的目标是能够通过按下按钮来刷新图表,该按钮可以工作,并根据用户的选择应用一些设置。为此,我有一个选择菜单,可以从中选择数据系列的颜色:
<select id="seriescolor">
<option value="red"> Red </option>
<option value="green"> Green </option>
<option value="blue"> Blue </option>
</select>
此外,我在刷新功能中放置了以下代码:
seriesSettings: {
line: {
applyAnimation: {
duration: 0
},
pointMark: {
enabled: false
},
if (document.getElementById("seriescolor").value=='red'){
color: 'green',
},
if (document.getElementById("seriescolor").value=='green'){
color: 'green',
},
if (document.getElementById("seriescolor").value=='blue'){
color: 'green',
},
}
},
答案 0 :(得分:1)
您可能无法在图表创建模块中检查选择状态/值。相反,您需要分配选定的值。为此,您可能希望更新以下选择选项:
<select id="seriescolor">
<option value="#E01B1B"> Red </option>
<option value="#46E01B"> Green </option>
<option value="#1B28E0"> Blue </option>
</select>
此外,您可以通过选择以下两个选项之一来指定颜色的值:
color: document.getElementById("seriescolor").value
或者您可以使用其他变量:
var SeriesColor = document.getElementById("seriescolor").value
并将其值分配给该属性:
color: document.getElementById("seriescolor").value