0

I have a Shield UI JavaScript Chart on a web page. My aim is to be able to refresh the chart by pressing a button, which works, and to apply some settings based on user’s choice. For that purpose I have a select menu, from which a color for the data series can be chosen:

<select id="seriescolor">
    <option value="red"> Red  </option>
    <option value="green"> Green </option>
    <option value="blue"> Blue </option>
</select>

In addition I placed the following code in my refresh function:

       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',
                },
            }
        },
4

1 回答 1

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
于 2013-09-13T13:14:46.490 回答