| | |
| | | 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]; |
| | |
| | | }, |
| | | 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 |
| | |
| | | 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); |
| | |
| | | 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 + ')' : ''; |