|
@@ -33,6 +33,12 @@ export default { |
|
@@ -33,6 +33,12 @@ export default { |
33
|
trigger: "axis",
|
33
|
trigger: "axis",
|
34
|
formatter: "{a} <br/>{b} : {c} '%'"
|
34
|
formatter: "{a} <br/>{b} : {c} '%'"
|
35
|
},
|
35
|
},
|
|
|
36
|
+ toolbox:{
|
|
|
37
|
+ show:true,
|
|
|
38
|
+ right:10,
|
|
|
39
|
+ y:5,
|
|
|
40
|
+ orient:'vertical',
|
|
|
41
|
+ },
|
36
|
legend: {
|
42
|
legend: {
|
37
|
textStyle: {
|
43
|
textStyle: {
|
38
|
color: "#fff"
|
44
|
color: "#fff"
|
|
@@ -133,6 +139,45 @@ export default { |
|
@@ -133,6 +139,45 @@ export default { |
133
|
top: this.optionsStyle.top + "px",
|
139
|
top: this.optionsStyle.top + "px",
|
134
|
background: this.optionsSetup.background
|
140
|
background: this.optionsSetup.background
|
135
|
};
|
141
|
};
|
|
|
142
|
+ },
|
|
|
143
|
+ //数据视图的单元格样式
|
|
|
144
|
+ dataViewTd(){
|
|
|
145
|
+ let style=`style="
|
|
|
146
|
+ border: 1px solid #cccccc;
|
|
|
147
|
+ border-bottom: none;
|
|
|
148
|
+ border-right:none;
|
|
|
149
|
+ padding:10px;
|
|
|
150
|
+ "`;
|
|
|
151
|
+ return style
|
|
|
152
|
+ },
|
|
|
153
|
+ //数据视图的表格样式
|
|
|
154
|
+ dataViewTable(){
|
|
|
155
|
+ let style=`style="
|
|
|
156
|
+ width:100%;
|
|
|
157
|
+ border-bottom: 1px solid #ccc;
|
|
|
158
|
+ border-right:1px solid #ccc;
|
|
|
159
|
+ "`;
|
|
|
160
|
+ return style;
|
|
|
161
|
+ },
|
|
|
162
|
+ //数据视图的表头样式
|
|
|
163
|
+ dataViewThead(){
|
|
|
164
|
+ let style=`style="
|
|
|
165
|
+ background:#f1f6f9;
|
|
|
166
|
+ border: 1px solid #cccccc;
|
|
|
167
|
+ border-bottom: none;
|
|
|
168
|
+ border-right:none;
|
|
|
169
|
+ padding:10px;
|
|
|
170
|
+ "`;
|
|
|
171
|
+ return style;
|
|
|
172
|
+ },
|
|
|
173
|
+ //数据视图的表格表体样式
|
|
|
174
|
+ dataViewTbody(){
|
|
|
175
|
+ let style=`style="
|
|
|
176
|
+ height:`+(this.optionsStyle.height-130) + "px"+`;
|
|
|
177
|
+ overflow:auto;
|
|
|
178
|
+ "`;
|
|
|
179
|
+ return style;
|
|
|
180
|
+
|
136
|
}
|
181
|
}
|
137
|
},
|
182
|
},
|
138
|
watch: {
|
183
|
watch: {
|
|
@@ -216,6 +261,14 @@ export default { |
|
@@ -216,6 +261,14 @@ export default { |
216
|
this.optionsCollapse = this.value.collapse;
|
261
|
this.optionsCollapse = this.value.collapse;
|
217
|
this.optionsSetup = this.value.setup;
|
262
|
this.optionsSetup = this.value.setup;
|
218
|
this.editorOptions();
|
263
|
this.editorOptions();
|
|
|
264
|
+ window.addEventListener("scroll", function (e){
|
|
|
265
|
+ if($(".dataViewTable thead")){
|
|
|
266
|
+ $(".dataViewTable").parent().unbind('scroll').scroll(function (){
|
|
|
267
|
+ $(this).find(".dataViewTable thead").css('transform','translate(0,'+e.target.scrollTop +'px)')
|
|
|
268
|
+ })
|
|
|
269
|
+ }
|
|
|
270
|
+ }, true); //数据视图的监听滚动事件
|
|
|
271
|
+
|
219
|
},
|
272
|
},
|
220
|
methods: {
|
273
|
methods: {
|
221
|
// 修改图标options属性
|
274
|
// 修改图标options属性
|
|
@@ -230,6 +283,7 @@ export default { |
|
@@ -230,6 +283,7 @@ export default { |
230
|
this.setOptionsMargin();
|
283
|
this.setOptionsMargin();
|
231
|
this.setOptionsLegend();
|
284
|
this.setOptionsLegend();
|
232
|
this.setOptionsColor();
|
285
|
this.setOptionsColor();
|
|
|
286
|
+ this.setOptionsToolbox();
|
233
|
},
|
287
|
},
|
234
|
// 标题修改
|
288
|
// 标题修改
|
235
|
setOptionsTitle() {
|
289
|
setOptionsTitle() {
|
|
@@ -296,6 +350,7 @@ export default { |
|
@@ -296,6 +350,7 @@ export default { |
296
|
},
|
350
|
},
|
297
|
// Y轴设置
|
351
|
// Y轴设置
|
298
|
setOptionsY() {
|
352
|
setOptionsY() {
|
|
|
353
|
+ let that=this;
|
299
|
const optionsSetup = this.optionsSetup;
|
354
|
const optionsSetup = this.optionsSetup;
|
300
|
const yAxis = [
|
355
|
const yAxis = [
|
301
|
{
|
356
|
{
|
|
@@ -358,6 +413,38 @@ export default { |
|
@@ -358,6 +413,38 @@ export default { |
358
|
];
|
413
|
];
|
359
|
this.options.yAxis = yAxis;
|
414
|
this.options.yAxis = yAxis;
|
360
|
},
|
415
|
},
|
|
|
416
|
+ //计算最大值
|
|
|
417
|
+ calMax(arr){
|
|
|
418
|
+ let max=0;
|
|
|
419
|
+ arr.forEach((el)=>{
|
|
|
420
|
+ el.forEach((el1)=>{
|
|
|
421
|
+ if(!(el1 === undefined || el1 === '')){
|
|
|
422
|
+ if(max<el1){
|
|
|
423
|
+ max=el1;
|
|
|
424
|
+ }
|
|
|
425
|
+ }
|
|
|
426
|
+ })
|
|
|
427
|
+ })
|
|
|
428
|
+ let maxint=Math.ceil(max/9.5);
|
|
|
429
|
+ let maxval=maxint * 10;//让显示的刻度是整数
|
|
|
430
|
+ return maxval;
|
|
|
431
|
+ },
|
|
|
432
|
+ //计算最小值
|
|
|
433
|
+ calMin(arr){
|
|
|
434
|
+ let min=0;
|
|
|
435
|
+ arr.forEach((el)=>{
|
|
|
436
|
+ el.forEach((el1)=>{
|
|
|
437
|
+ if(!(el1 === undefined || el1 === '')){
|
|
|
438
|
+ if(min>el1){
|
|
|
439
|
+ min=el1;
|
|
|
440
|
+ }
|
|
|
441
|
+ }
|
|
|
442
|
+ })
|
|
|
443
|
+ })
|
|
|
444
|
+ let minint=Math.floor(min/10);
|
|
|
445
|
+ let minval=minint * 10;//让显示的刻度是整数
|
|
|
446
|
+ return minval;
|
|
|
447
|
+ },
|
361
|
// 折线设置 数值设置
|
448
|
// 折线设置 数值设置
|
362
|
setOptionsTop() {
|
449
|
setOptionsTop() {
|
363
|
const optionsSetup = this.optionsSetup;
|
450
|
const optionsSetup = this.optionsSetup;
|
|
@@ -525,6 +612,45 @@ export default { |
|
@@ -525,6 +612,45 @@ export default { |
525
|
this.options.color = arrColor;
|
612
|
this.options.color = arrColor;
|
526
|
this.options = Object.assign({}, this.options);
|
613
|
this.options = Object.assign({}, this.options);
|
527
|
},
|
614
|
},
|
|
|
615
|
+ //数据视图导出
|
|
|
616
|
+ handleExport(){
|
|
|
617
|
+ console.log("+++++")
|
|
|
618
|
+ },
|
|
|
619
|
+ //设置数据视图
|
|
|
620
|
+ setOptionsToolbox(){
|
|
|
621
|
+ let that=this;
|
|
|
622
|
+ const optionsSetup = this.optionsSetup;
|
|
|
623
|
+ const dataView=this.optionsSetup.dataView;
|
|
|
624
|
+ this.options.toolbox.show=(dataView==undefined || dataView=='undefined')?true:dataView;
|
|
|
625
|
+ this.options.toolbox.toolBoxOrient=this.optionsSetup.toolBoxOrient?this.optionsSetup.toolBoxOrient:'vertical';
|
|
|
626
|
+ this.options.toolbox.feature= {
|
|
|
627
|
+ dataView: {
|
|
|
628
|
+ show: true, title: '数据视图', readOnly: true, optionToContent: function (opt) {
|
|
|
629
|
+ let series = opt.series;
|
|
|
630
|
+ let str='';
|
|
|
631
|
+ if(that.optionsSetup.download){
|
|
|
632
|
+ str+=`<div style="position: absolute;right: 10px;top: 6px;color:#1e9fff;cursor: pointer;">
|
|
|
633
|
+ <span id="handleButton" >导出</span>
|
|
|
634
|
+ </div>`;
|
|
|
635
|
+ }
|
|
|
636
|
+ let table =str+ '<table '+that.dataViewTable+' class="dataViewTable"><thead><tr class="dataViewTr">';
|
|
|
637
|
+ for(let i=0;i<series.length;i++){
|
|
|
638
|
+ table+='<td '+that.dataViewThead+' class="dataViewHead">' + (series[i].name?series[i].name:'') + '</td>';
|
|
|
639
|
+ }
|
|
|
640
|
+ table+= '</thead></tr><tbody '+that.dataViewTbody+'>';
|
|
|
641
|
+ for(let j=0;j<series[0].data.length;j++){
|
|
|
642
|
+ table += '<tr class="dataViewTr">';
|
|
|
643
|
+ for(let i=0;i<series.length;i++){
|
|
|
644
|
+ table +='<td '+that.dataViewTd+' class="dataViewTd">' + series[i].data[j] + '</td>'
|
|
|
645
|
+ }
|
|
|
646
|
+ table += '</tr>';
|
|
|
647
|
+ }
|
|
|
648
|
+ table += '</tbody></table>';
|
|
|
649
|
+ return table;
|
|
|
650
|
+ }
|
|
|
651
|
+ }
|
|
|
652
|
+ }
|
|
|
653
|
+ },
|
528
|
// 数据处理
|
654
|
// 数据处理
|
529
|
setOptionsData() {
|
655
|
setOptionsData() {
|
530
|
const optionsData = this.optionsData; // 数据类型 静态 or 动态
|
656
|
const optionsData = this.optionsData; // 数据类型 静态 or 动态
|
|
@@ -644,6 +770,18 @@ export default { |
|
@@ -644,6 +770,18 @@ export default { |
644
|
})
|
770
|
})
|
645
|
}
|
771
|
}
|
646
|
this.options.series=series;
|
772
|
this.options.series=series;
|
|
|
773
|
+ let arr=[];
|
|
|
774
|
+ this.options.series.map(item=>{
|
|
|
775
|
+ arr.push(item.data)
|
|
|
776
|
+ })
|
|
|
777
|
+ let min=this.calMin(arr);
|
|
|
778
|
+ let max=this.calMax(arr);
|
|
|
779
|
+ if(min<0){
|
|
|
780
|
+ this.options.yAxis[1].min=-20;
|
|
|
781
|
+ }
|
|
|
782
|
+ // this.options.yAxis[0].max=max;
|
|
|
783
|
+ // this.options.yAxis[0].min=min;
|
|
|
784
|
+ // this.options.yAxis[0].interval=(max-min)/7
|
647
|
/* if(this.chartData.indexOf(this.optionsData.dynamicData.contextData.flag)!=-1){
|
785
|
/* if(this.chartData.indexOf(this.optionsData.dynamicData.contextData.flag)!=-1){
|
648
|
this.isDisplay=true;
|
786
|
this.isDisplay=true;
|
649
|
}else{
|
787
|
}else{
|