2011-04-20 48 views

回答

1

您可以使用對數標度。

假設maxValue是您的最大允許值。然後,您可以定義一個方法myLog(x)這樣的:

var maxValue = 350; 

function myLog(x) { 
    return roundNumber(Math.pow(maxValue + 1,(x/100)) - 1, 2); 

} 

function roundNumber(num, dec) { 
    return Math.round(num * Math.pow(10,dec))/Math.pow(10,dec); 
} 

然後,你可以簡單地轉換默認值滑塊到對數的:

var outputString = "€" + myLog( $("#slider-range").slider("values", 0)) + " - €" + myLog($("#slider-range").slider("values", 1)) ; 

$("#amount").val(outputString);