2013-05-08 18 views
1

我可以通過調用通過用戶傳遞的函數來動態添加顏色。 我已經有默認定義的選項變量,用戶通過的顏色應該位於選項變量中。這可能嗎?請幫助通過flot圖中的函數添加顏色

var options = { 
    series: { 
    lines: { 
    show: true 
    }, 
    points: { 
    show: true 
    }, 
    color: '#00c7ce'--> user should pass dynamically 
}, 
    xaxis: { 
    mode: "time", 
    tickSize: [1, "month"], 
    tickLength: 0,    
    }, 
    yaxis: { 
    show: false 
    } 
} 

};

回答

3

您應該能夠將顏色傳遞給選項。設置你的輸入,然後使用該變量作爲你的顏色。

<input id="userInput"></input> 
    var usrColor = $("#userInput").val(); 

    var options = { 

    series: { 

    lines: { show: true}, 
    points: {show: true, radius: 4}, 
    color: usrColor 
    } 


}; 

小提琴 - http://jsfiddle.net/Rnusy/4/

+0

謝謝你,它工作得很好:) – Sweetz 2013-05-09 07:01:47