whychdw
2019-11-29 496507e81418167403133d1a3837c19911a291a6
www/js/componets.js
@@ -299,7 +299,6 @@
            if (this.names.length == 0) {
                this.names.push(this.name);
            }
            console.log(this.names);
            var series = [];
            for (var i = 0; i < this.names.length; i++) {
                var name = this.names[i];
@@ -347,7 +346,14 @@
                    },
                    lineWidth: 1
                }],
                tooltip: {},
                tooltip: {
                    shared: true,
                    useHTML: true,
                    headerFormat: '<small>{point.key}</small><table>',
                    pointFormat: '<tr><td style="color: {series.color}">{series.name}: </td>' + '<td style="text-align: right"><b>{point.y}' + this.unit + '</b></td></tr>',
                    footerFormat: '</table>',
                    valueDecimals: 2
                },
                plotOptions: {
                    column: {
                        borderWidth: 0
@@ -359,6 +365,9 @@
        setOption: function setOption(options) {
            var categories = options.categories;
            var data = options.data;
            if (options.names) {
                this.setNames(options.names);
            }
            this.setCategories(categories);
            this.setExtremes(null, null);
            this.setData(data);
@@ -391,12 +400,38 @@
                    result.push(tmp);
                }
                if (this.chart.series[k]) {
                    // console.log(result);
                    this.chart.series[k].setData(result, false);
                }
            }
            // 更新图表
            this.chart.redraw();
        },
        setNames: function setNames(names) {
            var self = this;
            var series = this.chart.series;
            for (var i = 0; i < series.length; i++) {
                this.chart.series[0].remove(false);
                i--;
            }
            for (var i = 0; i < names.length; i++) {
                var name = names[i];
                var tmp = {
                    name: name,
                    data: [],
                    events: {
                        click: self.monHanderClick
                    },
                    dataLabels: {
                        enabled: false
                    },
                    marker: {
                        enabled: false
                    }
                };
                this.chart.addSeries(tmp, false);
            }
        },
        getUnit: function getUnit() {
            // 格式化单位
            var unit = this.unit ? '(' + this.unit + ')' : '';