簡體   English   中英

如何使用科學計數法使(笛卡爾)圖表軸縮放?

[英]How to have (cartesian) chart axis to scale using scientific notation?

我有一個numeric軸,我希望它顯示1.6e10、7e-10、9.9e7等。它目前正以難以置信的小十進制數字進行縮放。 Ext.util.Format.numberRenderer('0.0e')僅顯示0.0e。

axes: [{
    type: 'numeric',
    position: 'left',
    title: {
        text: 'BER Level (log\u2081\u2080)', // 1_unicode and 0_unicode
        fontSize: '14px'
    },
    maximum: maxAxis,
    minimum: minAxis,
    grid: true,
    //renderer: Ext.util.Format.numberRenderer('0.0E'),
    label: {
        fontSize: '10px'
    }
}]

我想我知道了。

renderer

renderer: function(label, layout, lastLabel) {
    if (Math.abs(label) < 1.0) {
        var fl = Ext.util.Format.number(parseFloat(label.toString().split('e-')[0]), '0.0'); // returns String
        var sn = label.toString().split('e-')[1];
        var newLbl = Number(fl + 'e' + sn);
        if (!isNaN(newLbl)){
            label = newLbl;
        }
    }
    else {
        var fl = Ext.util.Format.number(parseFloat(label.toString().split('e')[0]), '0.0');
        var sn = label.toString().split('e')[1];
        var newLbl = Number(fl + 'e-' + sn);
        if (!isNaN(newLbl)){
            label = newLbl;
        }
    }
    return label;
},

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM