亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這是來自 chart.js 的自定義問題

這是來自 chart.js 的自定義問題

慕工程0101907 2021-06-22 09:05:45
我用的是chart.js,但是沒有應用css。我用的是chart.js,但是我不知道如何調整位置和大小以及移動標簽。<div class="penpal-count-box"><div class="col">    <h5 style="padding-top:2%"><i class="fa fa-globe" style="color:blue">   </i>&nbsp;@lang('home/main.penpal_count')    </h5>    <hr>    <canvas id="myChart"></canvas>  </div></div><script>var ctx = document.getElementById('myChart').getContext('2d');var myChart = new Chart(ctx, {    type: 'pie',    data: {        labels: ['??', '??'],        datasets: [{            label: '# of Votes',            data: [{                    !!$koreaSenderCount!!                },                {                    !!$japanSenderCount!!                }            ],            backgroundColor: [                'red',                'blue',            ],        }]    },    options: {        maintainAspectRatio: false,    }});</script><style> canvas {    width: 400px !important;    height: 170px !important;    margin-bottom: 3%;}</style>我想從側面取下標簽并將其設置為適合上方的 div。我的目標是以類似于第二張圖片的方式應用它。
查看完整描述

1 回答

?
慕無忌1623718

TA貢獻1744條經驗 獲得超4個贊

試試這個,這里為標簽添加了位置,來自圖表 js,圖例標簽文檔

var myChart = new Chart(ctx, {

    type: 'pie',

    data: {

        labels: ['??', '??'],

        datasets: [{

            label: '# of Votes',

            data: [{

                    !!$koreaSenderCount!!

                },

                {

                    !!$japanSenderCount!!

                }

            ],

            backgroundColor: [

                'red',

                'blue',


            ],

        }]

    },

    options: {

        maintainAspectRatio: false,

        legend: {

          position:'right',   // from this line you can get your labels in right direction    

        },

    }

});


查看完整回答
反對 回復 2021-06-24
  • 1 回答
  • 0 關注
  • 185 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號