调整图例闪亮R

时间:2018-06-21 13:43:06

标签: r shiny legend

我正试图摆脱空白的空白,如下所示,但是似乎无法弄清楚如何做到这一点。

enter image description here

示例代码:

 legend("bottom", 
         colnames(bvoip.collab.seats)[3:4],
         xpd = FALSE,
         horiz = TRUE, 
         #ncol = 1 , 
         inset = c(0, 0),
         bty = "o",
         bg = "gray90", 
         box.col="gray90",
         pch = c(15, 15, 15, 15, 15), 
         col = c(attDarkBlue,attOrange,attGreen), 
         legend = c(" Collaborate-Enhanced Mobile"," Collaborate"," Collaborate-Internal"),
         pt.cex = 1.3,cex = 0.8,yjust = 0.5)

1 个答案:

答案 0 :(得分:0)

这是一种解决方法,但是在Legend()中使用“ text.width”属性可以完成工作。这不是完美的,但可以。

legend("bottom", 
         colnames(bvoip.collab.seats)[3:4],
         xpd = FALSE,
         horiz = TRUE, 
         text.width=c(.5,.2,.5),
         #ncol = 1 , 
         inset = c(0, 0),
         bty = "o",
         bg = "gray90", 
         box.col="gray90",
         pch = c(15, 15, 15, 15, 15), 
         col = c(attDarkBlue,attOrange,attGreen), 
         legend = c(" Collaborate-Enhanced Mobile", " Collaborate", " Collaborate-Internal"),
         pt.cex = 1.3,cex = 0.8,yjust = 0.5)

整个代码

<script type="text/javascript">
    jQuery(function($) {
        openExpressDonate = function() {
            $.fancybox({
                    closeBtn: false,
                    closeEffect: 'none',
                    helpers : {
                        overlay : {
                            closeClick: false,
                            css: {'background-color': 'rgba(0, 0, 0, 0.60'},
                            locked: true
                        }
                    },
                    href: 'https://demo.donordrive.com/index.cfm?fuseaction=expressDonate.modalparticipant&ParticipantID=8558',
                    margin: 0,
                    maxWidth: 400,
                    height: 'auto',
                    openEffect: 'none',
                    padding: 1,
                    scrolling: 'no',
                    type: 'iframe'
                });
        }

        $('.js-express-donate').on('click', function(e) {
                e.preventDefault();

                if (window.ga) {
                    ga('send', {
                            hitType: 'event',
                            eventCategory: 'Express Donate - Participant',
                            eventAction: 'Donation Started',
                            eventLabel: 'Event 1183'
                        });
                }

                openExpressDonate();
            });

        if (location.hash && location.hash == '#donate') {
            $('.js-express-donate').click();
        }

        resizeExpressDonateModal = function() {
            $.fancybox.update();
        }

        showExpressDonateThankYou = function(target, data) {
            $.fancybox({
                    afterShow: function () {
                        fancyParent = $('.fancybox-wrap').parents(); // normally html and body
                        fancyParent.on('click.modalThanks', function () {
                            $.fancybox.close();
                            fancyParent.off('click.modalThanks');
                        });
                        $('.fancybox-wrap').on('click', function (event) {
                            // prevents closing when clicking inside the fancybox wrap
                            event.stopPropagation();
                        });
                    },
                    helpers : {
                        overlay : {
                            closeClick: false,
                            css: {'background-color': 'rgba(0, 0, 0, 0.60'},
                            locked: true
                        }
                    },
                    href: 'https://demo.donordrive.com/index.cfm?fuseaction=donorDrive.modal' + target + 'ExpressDonateThanks&donorID=' + data.values.donorID + '&CSRFToken=' + data.values.CSRFToken + '&n=' + data.values.isNewConstituent,
                    margin: 0,
                    maxWidth: 400,
                    minHeight: 300,
                    modal: 1,
                    openEffect: 'none',
                    padding: 1,
                    scrolling: 'no',
                    type: 'iframe'
                });
        }
    });
</script>

enter image description here