0

Web ページに 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',
                },
            }
        },
4

1 に答える 1

1

チャート作成モジュールで選択状態/値を確認できない場合があります。代わりに、選択した値を割り当てる必要があります。その目的のために、次のように選択オプションを更新することをお勧めします。

<select id="seriescolor">
    <option value="#E01B1B"> Red  </option>
    <option value="#46E01B"> Green </option>
    <option value="#1B28E0"> Blue </option>    
</select>

さらに、次の 2 つのオプションのいずれかを選択して、色の値を割り当てることができます。

color: document.getElementById("seriescolor").value

または、追加の変数を使用できます。

var SeriesColor = document.getElementById("seriescolor").value

そして、その値をプロパティに割り当てます。

 color: document.getElementById("seriescolor").value
于 2013-09-13T13:14:46.490 に答える