Javascript:将变量(对象)导入构造函数/选项setter

时间:2016-04-07 15:02:10

标签: javascript highcharts

我有这个Highchart构造函数/选项setter:

function drawChart(chart_lang) {

    Highcharts.setOptions({
                lang: {
                    loading: 'In caricamento...',
                    months: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
                    weekdays: ['Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato'],
                    shortMonths: ['Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic'],
                    exportButtonTitle: 'Esporta',
                    printButtonTitle: 'Stampa',
                    rangeSelectorFrom: 'Da',
                    rangeSelectorTo: 'A',
                    rangeSelectorZoom: 'Zoom',
                    downloadPNG: 'Download PNG',
                    downloadJPEG: 'Download JPEG',
                    downloadPDF: 'Download PDF',
                    downloadSVG: 'Download SVG',
                    printChart: 'Stampa',
                    resetZoom: 'Reset'
               }
        });

    $('div#grow').highcharts({

            chart: {
                type: 'column'
            },

     // other stuffs...


}

我在这种模式下回忆起这个功能:

var chart_lang = {

        lang: {
                loading: 'In caricamento...',
                months: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
                weekdays: ['Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato'],
                shortMonths: ['Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic'],
                exportButtonTitle: "Esporta",
                printButtonTitle: "Stampa",
                rangeSelectorFrom: "Da",
                rangeSelectorTo: "A",
                rangeSelectorZoom: "Zoom",
                downloadPNG: 'Download PNG',
                downloadJPEG: 'Download JPEG',
                downloadPDF: 'Download PDF',
                downloadSVG: 'Download SVG',
                printChart: 'Stampa',
                resetZoom: 'Reset'
        }

    };

    if ($('div#grow').length>0) {

        drawGrowChart(chart_lang);

    }

我可以在drawChart()中使用chart_lang变量//重写的对象吗?

谢谢

0 个答案:

没有答案
相关问题