最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - In morris.bar chart all label is not showing But when I Zoom in all Labels are showing properly - Stack Overflow

programmeradmin3浏览0评论

In Morris.js Bar chart all labels are not showing properly

But in big screen it shows all labels properly.It has 12 labels but it's not showing all labels.

Morris.Bar({
        element: 'morris-bar-chart',
        barGap:4,
        barSizeRatio:0.55,
        data: [

            <?php for($i=0;$i<12;$i++)
            {
                echo "{y: '";
                echo $barchart1[$i]->month;
                echo "', a: ";
                echo $barchart1[$i]->totalamount; 
                echo ", b:";
                echo ($barchart2[$i]->totalamount) ? $barchart2[$i]->totalamount : "0";
                echo "}";

                if($i!=11)
                {
                  echo ",\n";
                }
            }
                ?>
           ],
        xkey: 'y',
        ykeys: ['a', 'b'],
        labels: ['Invoice Amount', 'Received Amount'],
        barColors: ['#55ce63', '#03a9f3'],
        hideHover: 'auto',
        gridLineColor: '#eef0f2',
        resize: true
    });

In Morris.js Bar chart all labels are not showing properly

But in big screen it shows all labels properly.It has 12 labels but it's not showing all labels.

Morris.Bar({
        element: 'morris-bar-chart',
        barGap:4,
        barSizeRatio:0.55,
        data: [

            <?php for($i=0;$i<12;$i++)
            {
                echo "{y: '";
                echo $barchart1[$i]->month;
                echo "', a: ";
                echo $barchart1[$i]->totalamount; 
                echo ", b:";
                echo ($barchart2[$i]->totalamount) ? $barchart2[$i]->totalamount : "0";
                echo "}";

                if($i!=11)
                {
                  echo ",\n";
                }
            }
                ?>
           ],
        xkey: 'y',
        ykeys: ['a', 'b'],
        labels: ['Invoice Amount', 'Received Amount'],
        barColors: ['#55ce63', '#03a9f3'],
        hideHover: 'auto',
        gridLineColor: '#eef0f2',
        resize: true
    });
Share Improve this question edited Jan 19, 2019 at 9:29 PREM asked Jan 19, 2019 at 9:19 PREMPREM 1142 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

This is because Morris chart applies by default a left and right margin to labels on X-axis. This is to avoid that labels are too close to each other. You can change it through the option xLabelMargin (default value is 50, you can try with 10 per example).

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论