whychdw
2019-09-09 c0b9ce437d409b89ca0e5388344ca9c5a56d70a4
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
'use strict';
 
Object.defineProperty(exports, "__esModule", {
    value: true
});
/* *
 *
 *  !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
 *
 * */
var isFn = function isFn(x) {
    return typeof x === 'function';
};
/* eslint-disable no-invalid-this, valid-jsdoc */
/**
 * Handles the drawing of a component.
 * Can be used for any type of component that reserves the graphic property, and
 * provides a shouldDraw on its context.
 *
 * @private
 * @function draw
 * @param {DrawPointParams} params
 *        Parameters.
 *
 * @todo add type checking.
 * @todo export this function to enable usage
 */
var draw = function draw(params) {
    var component = this,
        graphic = component.graphic,
        animatableAttribs = params.animatableAttribs,
        onComplete = params.onComplete,
        css = params.css,
        renderer = params.renderer;
    if (component.shouldDraw()) {
        if (!graphic) {
            component.graphic = graphic = renderer[params.shapeType](params.shapeArgs).add(params.group);
        }
        graphic.css(css).attr(params.attribs).animate(animatableAttribs, params.isNew ? false : undefined, onComplete);
    } else if (graphic) {
        var destroy = function destroy() {
            component.graphic = graphic = graphic.destroy();
            if (isFn(onComplete)) {
                onComplete();
            }
        };
        // animate only runs complete callback if something was animated.
        if (Object.keys(animatableAttribs).length) {
            graphic.animate(animatableAttribs, undefined, function () {
                destroy();
            });
        } else {
            destroy();
        }
    }
};
/**
 * An extended version of draw customized for points.
 * It calls additional methods that is expected when rendering a point.
 *
 * @param {Highcharts.Dictionary<any>} params Parameters
 */
var drawPoint = function drawPoint(params) {
    var point = this,
        attribs = params.attribs = params.attribs || {};
    // Assigning class in dot notation does go well in IE8
    // eslint-disable-next-line dot-notation
    attribs['class'] = point.getClassName();
    // Call draw to render component
    draw.call(point, params);
};
exports.default = drawPoint;