static-scale.src.js
3.14 KB
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
/**
* @license Highcharts JS v6.2.0 (2018-10-17)
* StaticScale
*
* (c) 2016 Torstein Honsi, Lars A. V. Cabrera
*
* --- WORK IN PROGRESS ---
*
* License: www.highcharts.com/license
*/
'use strict';
(function (factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory;
} else if (typeof define === 'function' && define.amd) {
define(function () {
return factory;
});
} else {
factory(Highcharts);
}
}(function (Highcharts) {
(function (H) {
/**
* (c) 2018 Torstein Honsi, Lars Cabrera
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
pick = H.pick;
/**
* For vertical axes only. Setting the static scale ensures that each tick unit
* is translated into a fixed pixel height. For example, setting the static
* scale to 24 results in each Y axis category taking up 24 pixels, and the
* height of the chart adjusts. Adding or removing items will make the chart
* resize.
*
* @type {number}
* @sample gantt/xrange-series/demo/ X-range series with static scale
* @since 6.2.0
* @product gantt
* @default 50
* @apioption yAxis.staticScale
*/
H.addEvent(H.Axis, 'afterSetOptions', function () {
if (
!this.horiz &&
H.isNumber(this.options.staticScale) &&
!this.chart.options.chart.height
) {
this.staticScale = this.options.staticScale;
}
});
Chart.prototype.adjustHeight = function () {
if (this.redrawTrigger !== 'adjustHeight') {
each(this.axes || [], function (axis) {
var chart = axis.chart,
animate = !!chart.initiatedScale && chart.options.animation,
staticScale = axis.options.staticScale,
height,
diff;
if (axis.staticScale && H.defined(axis.min)) {
height = pick(
axis.unitLength,
axis.max + axis.tickInterval - axis.min
) * staticScale;
// Minimum height is 1 x staticScale.
height = Math.max(height, staticScale);
diff = height - chart.plotHeight;
if (Math.abs(diff) >= 1) {
chart.plotHeight = height;
chart.redrawTrigger = 'adjustHeight';
chart.setSize(undefined, chart.chartHeight + diff, animate);
}
// Make sure clip rects have the right height before initial
// animation.
each(axis.series, function (series) {
var clipRect =
series.sharedClipKey && chart[series.sharedClipKey];
if (clipRect) {
clipRect.attr({
height: chart.plotHeight
});
}
});
}
});
this.initiatedScale = true;
}
this.redrawTrigger = null;
};
H.addEvent(Chart, 'render', Chart.prototype.adjustHeight);
}(Highcharts));
return (function () {
}());
}));