IT-KIMI_SHI\SINOIT.KIMI
2018-12-07 50eb1d766c470dc6ff927199eaee934f972a8b70
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
define(['zrender','zrender/tool/color','zrender/shape/Rectangle','jquery','jquery-ui'],function(zrender,color,RectangleShape,$){
    return function() {
        var zr = {};
        return {
            render: function (id, option) {
                var target = $("#" + id);
                zr = zrender.init(target[0]);
                //绑定zrenderid
                target.attr("zid",zr.getId());
                var pageY = zr.getHeight();
                var pageX = zr.getWidth();
                if (!option) {
                    zr.addShape(new RectangleShape({
                        style: {
                            x: pageX / 8,
                            y: pageY / 8,
                            width: pageX - (pageX / 4),
                            height: pageY - (pageY / 4),
                            brushType: 'both',
                            color: 'rgba(0, 153, 255, 1)',          // rgba supported
                            strokeColor: 'rgba(0, 153, 255, 1)',
                            text: '请输入文字',
                            textFont: "bold " + pageX / 8 + "px verdana",
                            textPosition: 'inside',
                            textColor: 'black',
                            radius: [20, 50],
                            lineWidth: 5
                        },
                        hoverable: false,
                    }));
                } else {
                    // option.x = pageX / 8;
                    // option.y = pageY / 8;
                    option.width = pageX - (pageX / 5);
                    // option.height = pageY - (pageY / 4);
                    // option.textFont =  "bold " + pageX / 8 + "px verdana";
                    zr.addShape(new RectangleShape({
                        style: option,
                        hoverable: false,
                    }));
                }
                zr.render();
                return this;
            },
            getOption: function () {
                if(zr){
                    return zr.storage.getShapeList()[0].style;
                }
            }
        }
    }
})