谁知道如何放下在离子2馅饼的标题

问题描述:

我想把标签放在pie.who请告诉我。谢谢!这里的代码。谁知道如何放下在离子2馅饼的标题

 this.pieChart = new Chart(this.pieCanvas.nativeElement, { 
     type: 'pie', 
     data: { 
      labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], 
      datasets: [{ 
       label: '# of Votes', 
       data: [12, 19, 3, 5, 2, 3], 
       backgroundColor: [ 
        "#ff0000", 
        "#0000ff", 
        "#ffff00", 
        "#008000", 
        "#800080", 
        "#ffa500" 
       ] 
      }] 
     } 

    }); 

image

您可以通过设置标签/传奇的位置实现这一目标。

options: { 
    legend: { 
     position: 'bottom' 
    } 
} 

完整代码会是这样......

this.pieChart = new Chart(this.pieCanvas.nativeElement, { 
    type: 'pie', 
    data: { 
     labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], 
     datasets: [{ 
      label: '# of Votes', 
      data: [12, 19, 3, 5, 2, 3], 
      backgroundColor: [ 
        "#ff0000", 
        "#0000ff", 
        "#ffff00", 
        "#008000", 
        "#800080", 
        "#ffa500" 
       ] 
      }] 
    }, 
    options: { 
     legend: { 
      position: 'bottom' 
     } 
    } 
}); 
+0

太感谢你了。有用 –