dojox.gfx還沒有對數軸呢。
更新:一種方法是將數據沿對數軸重新映射,並使用線性軸和自定義標籤。例如:
// we will transform our 'x' to a decadic logarithmic scale
var LOG10 = Math.log(10);
var data = [...]; // my data of {x, y}
var transformedData = dojo.map(data, function(value){
return {
x: Math.log(value.x)/LOG10,
y: value.y // 'y' is unchanged
};
});
// ...
// add the axis and the data
chart.addAxis("x", {
natural: true,
includeZero: true,
// our logarithmic labels
labels: [
{value: 0, text: "1"},
{value: 1, text: "10"},
{value: 2, text: "100"},
{value: 3, text: "1000"},
{value: 4, text: "10^4"},
{value: 5, text: "10^5"},
{value: 6, text: "10^6"},
{value: 7, text: "10^7"},
{value: 8, text: "10^8"},
{value: 9, text: "10^9"}
]
});
chart.addSeries("my data", transformedData);
// ...
類似這樣的事情可以做到這一點。另一種選擇是使用標籤功能自動生成「對數」標籤。