JS 封裝類

來源:互聯網
上載者:User

標籤:style   blog   color   os   io   for   ar   art   div   

function HighchartsObj(id, type) {    var that = this;    this.options = {        chart : {            renderTo : id,            type : type,            style : {                cursor : ‘pointer‘            },            events : {                click : function(e) {                    // console.log(that.extra);                    var params = that.extra.split(‘,‘);                    if (null != params && 5 === params.length) {                        toIndiPage(params[0], params[1], params[2], params[3],                                params[4]);                    }                }            }        },        credits : {            // 隱藏著作權            enabled : false        },        title : {            // 隱藏標題            text : null        },        legend : {            // 隱藏圖列            enabled : false        },        tooltip : {            pointFormat : ‘{series.name}:<b>{point.y}</b>‘        },        xAxis : {            labels : {                // X座標隱藏                enabled : false            },            categories : []        },        yAxis : {            title : {                // 隱藏Y軸文本                text : null            }        },        series : []    };    this.highcharts = null;    this.extra = null;}HighchartsObj.prototype = {    setCategories : function(categories) {        if (!this.isArrayType(categories)) {            alert(‘not array‘);            return;        }        this.options.xAxis.categories = categories;    },    setSeries : function(series) {        if (!this.isArrayType(series)) {            alert(‘not array‘);            return;        }        var data = [];        for ( var i = series.length - 1; i >= 0; i--) {            for ( var j = 0, len = series[i][‘data‘].length; j < len; j++) {                var val = series[i][‘data‘][j];                if (‘‘ === val || null === val) {                    val = null;                } else {                    val = Number(val);                }                data.push(val);            }            var minVal = Math.min.apply(null, data);            var maxVal = Math.max.apply(null, data);            // console.log(minVal + ‘==========‘ + maxVal);            series[i][‘data‘] = $.map(data, function(val, key) {                // console.log(val + ‘--------‘ + key);                if (val === minVal) {                    return {                        y : val,                        marker : {                            radius : 3                        }                    };                } else if (val === maxVal) {                    return {                        y : val,                        marker : {                            radius : 5                        }                    };                }                return val;            });        }        this.options.series = series;    },    createObj : function() {        this.highcharts = new Highcharts.Chart(this.options);    },    isArrayType : isType(‘Array‘),    isNumberType : isType(‘Number‘),    isStringType : isType(‘String‘)}// 判斷類型function isType(type) {    return function(obj) {        return Object.prototype.toString.call(obj) === ‘[object ‘ + type + ‘]‘;    }}

 

JS 封裝類

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.