Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS 6无法覆盖轴';渲染器_Javascript_Extjs_Overriding_Extjs6 Classic - Fatal编程技术网

Javascript ExtJS 6无法覆盖轴';渲染器

Javascript ExtJS 6无法覆盖轴';渲染器,javascript,extjs,overriding,extjs6-classic,Javascript,Extjs,Overriding,Extjs6 Classic,我正在重写Axis类,并且在大多数情况下它是有效的——可以毫无问题地调用新添加的方法。但是,尝试设置默认渲染器不会产生任何效果。我还尝试使用initComponent和构造函数(通过这个.callParent(arguments)调用),但并没有效果 Ext.define('Dashboards.overrides.chart.axis.Axis', { override : 'Ext.chart.axis.Axis', config : { maxLabel

我正在重写Axis类,并且在大多数情况下它是有效的——可以毫无问题地调用新添加的方法。但是,尝试设置默认渲染器不会产生任何效果。我还尝试使用initComponent和构造函数(通过这个.callParent(arguments)调用),但并没有效果

Ext.define('Dashboards.overrides.chart.axis.Axis', {

    override : 'Ext.chart.axis.Axis',

    config : {
        maxLabelLength : 15,
        numberPrecision : 2
    },

    abbreviateNumber : function(value, precision) {
            var newValue = value;
            if (value >= 1000) {
                var suffixes = ["", "k", "m", "b","t"];
                var suffixNum = Math.floor( (""+value).length/3 );
                var shortValue = '';
                for (; precision >= 1; precision--) {
                        shortValue = parseFloat( (suffixNum != 0 ? (value / Math.pow(1000,suffixNum) ) : value).toPrecision(precision));
                        var dotLessShortValue = (shortValue + '').replace(/[^a-zA-Z 0-9]+/g,'');
                        if (dotLessShortValue.length <= 2) { break; }
                }
                if (shortValue % 1 != 0)  shortNum = shortValue.toFixed(1);
                newValue = shortValue+suffixes[suffixNum];
            }
            return newValue;
    },

    shortenLabel : function (axis, data, max_length) {
            var str = data;
                var chart = axis.getChart();
                if (str.length > max_length) {
                str = str.substring(0, max_length-3)+"...";
        }
        return str;
    },

    shorteningRenderer : function (axis, label) {
            if (!isNaN(label)) {
                        return axis.abbreviateNumber(label, this.getNumberPrecision());
                    } else return shortenLabel (axis, label, maxLabelLength);
            },

        renderer : this.shorteningRenderer
})
Ext.define('dashboard.overrides.chart.axis.axis'{
覆盖:“Ext.chart.axis.axis”,
配置:{
最大标签长度:15,
数字精度:2
},
缩写数字:函数(值、精度){
var newValue=价值;
如果(值>=1000){
变量后缀=[“”,“k”,“m”,“b”,“t”];
变量suffixNum=数学地板((“”+值).length/3);
var shortValue=“”;
对于(;精度>=1;精度--){
shortValue=parseFloat((suffixNum!=0)(value/Math.pow(1000,suffixNum)):value.toPrecision(precision));
var dotlesshortvalue=(shortValue++'')。替换(/[^a-zA-Z 0-9]+//g'');
if(点短值.length最大长度){
str=str.substring(0,最大长度-3)+“…”;
}
返回str;
},
缩短器:功能(轴、标签){
如果(!isNaN(标签)){
返回axis.缩写数字(标签,this.getNumberPrecision());
}否则返回短标签(轴、标签、最大标签长度);
},
渲染器:this.shorteningrender
})