-
Notifications
You must be signed in to change notification settings - Fork 17
/
comparisonarea.js
91 lines (82 loc) · 2.47 KB
/
comparisonarea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import graph_area from './area.js'
import JUI from 'juijs-chart'
import AreaBrush from 'juijs-chart/src/brush/area.js'
JUI.use(AreaBrush)
export default {
name: 'graph-comparison-area',
mixins: [ graph_area ],
props: {
axisMin: {
type: Array,
required: false,
default: null
},
axisMax: {
type: Array,
required: false,
default: null
}
},
methods: {
getAxisMinAndMax: function(data, index) {
let min = this.axisMin;
let max = this.axisMax;
if(min != null && max != null) {
return [ min[index], max[index] ]
}
return data[index];
},
initGraphAxes: function() {
const self = this;
return [{
x : {
type : "fullblock",
domain : this.labels,
line : this.axisXStyle,
hide : this.axisXStyle == "hidden",
},
y : {
type : "range",
domain : function(data) {
return self.getAxisMinAndMax(data, 0);
},
step : this.axisStep,
line : this.axisYStyle,
hide : this.axisYStyle == "hidden",
reverse : true,
color : 0
},
data : this.convertToData(this.values)
}, {
x : {
hide : true
},
y : {
orient : "right",
domain : function(data) {
return self.getAxisMinAndMax(data, 1);
},
reverse : false,
color : 1
},
extend : 0
}]
}
},
beforeMount: function() {
const _ = JUI.include('util.base')
let colors = !this.colors ? [ 0, 1 ] : this.colors;
let options = {
type: 'area',
clip: this.clip,
symbol: this.shape,
opacity: this.opacity,
line: this.borderLine,
display: this.display
}
this.brushes = [
_.extend({ target: '0', axis: 0, colors: [ colors[0] ] }, options),
_.extend({ target: '1', axis: 1, colors: [ colors[1] ] }, options)
]
}
}