简体   繁体   中英

How to resize space of chart are and legend label

I use ng2-chart in angular 2, how to resize spacte chart are and legend label ? Thank you very much.

html

<div align="center" style="width: auto; height: auto">
  <div class="chartArea">
    <canvas baseChart id="chartBalanceId" [data]="chartData"
            [labels]="chartLabels" 
            [colors]="chartColors"
            [options]="chartOptions"
            [chartType]="chartType"></canvas>
  </div>
</div>

component

private chartData: number[] = [];
  private chartType: string = "doughnut";
  private chartOptions: any = {legend: {position: "right"}};
  private chartLabels: string[] = ["BTC", "ETH", "LTC", "XRP"];
  private chartData = [30, 34, 30, 6];
  private chartColors: any[] = [{ backgroundColor: ["#b8436d", "#00d9f9", "#a4c73c", "#a4add3"] }];

在此处输入图片说明

元素将填充块的大小,因此不要使用style="width: auto; height: auto"将它们放入具有固定宽度的div中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM