-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
demo.js
115 lines (92 loc) · 2.81 KB
/
demo.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
QUnit.test('softMin and softMax', function (assert) {
var chart = Highcharts.chart('container', {
chart: {
animation: false
},
yAxis: {
minPadding: 0,
maxPadding: 0,
startOnTick: false,
endOnTick: false
},
series: [
{
data: [49, 50, 51],
animation: false
}
]
});
assert.strictEqual(chart.yAxis[0].min, 49, 'Basic min');
assert.strictEqual(chart.yAxis[0].max, 51, 'Basic max');
chart.yAxis[0].update({
softMin: 0,
softMax: 100
});
assert.strictEqual(chart.yAxis[0].min, 0, 'Soft min, padded');
assert.strictEqual(chart.yAxis[0].max, 100, 'Soft max, padded');
chart.series[0].setData([-50, 0, 150]);
assert.strictEqual(chart.yAxis[0].min, -50, 'Soft min, exceeded');
assert.strictEqual(chart.yAxis[0].max, 150, 'Soft max, exceeded');
// Zoom in
chart.yAxis[0].setExtremes(50, 100);
assert.strictEqual(chart.yAxis[0].min, 50, 'Soft min should allow zoom');
assert.strictEqual(chart.yAxis[0].max, 100, 'Soft max should allow zoom');
chart.yAxis[0].setExtremes();
chart.series[0].setData([-100, -101, -102]);
assert.strictEqual(chart.yAxis[0].max, 100, 'Soft max should be respected');
let { min, max } = chart.yAxis[0];
let diff = max - min;
chart.yAxis[0].update({
softMin: undefined,
minPadding: 0.5
});
assert.strictEqual(
chart.yAxis[0].min,
min - diff / 2,
'Min padding should be added when when soft max set, #18110'
);
chart.yAxis[0].update({
softMin: -200,
softMax: undefined
});
min = chart.yAxis[0].min;
max = chart.yAxis[0].max;
diff = max - min;
chart.yAxis[0].update({
minPadding: 0,
maxPadding: 0.5
});
assert.strictEqual(
chart.yAxis[0].max,
max + diff / 2,
'Max padding should be added when when soft min set, #18110'
);
});
QUnit.test('softMax combined with ceiling (#6359)', function (assert) {
var chart = Highcharts.chart('container', {
chart: {
animation: false
},
yAxis: {
softMax: 30,
ceiling: 40
},
series: [
{
data: [6, 9, 2, 6, 9, 1, 2, 2, 4, 5],
animation: false
}
]
});
assert.strictEqual(chart.yAxis[0].max, 30, 'softMax takes effect');
chart.series[0].points[0].update(50, true, false);
assert.strictEqual(chart.yAxis[0].max, 40, 'ceiling takes effect');
chart.yAxis[0].update({
ceiling: 20 // lower than softMax
});
assert.strictEqual(
chart.yAxis[0].max,
20,
'Conflicting settings, ceiling takes precedence'
);
});