Angular-highcharts-pie-legends

提供:Dev Guides
移動先:案内検索

Angular Highcharts-凡例付きの円グラフ

以下は、凡例付きの円グラフの例です。

link:/angular_highcharts/angular_highcharts_configuration_syntax [Highcharts構成構文]の章でチャートを描画するために使用される構成についてはすでに見ました。

凡例付きの円グラフの例を以下に示します。

構成

ここで、追加の構成/実行された手順を見てみましょう。

チャート

グラフタイプを「パイ」ベースに設定します。 chart.type は、チャートのシリーズタイプを決定します。 ここで、デフォルト値は「line」です。

var series = {
   type: 'pie'
};

plotOptions

*plotOptions.pie.showInLegend* 属性を使用して、円グラフに凡例を表示するようにplotOptionsを構成します。
plotOptions : {
   pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      dataLabels: {
         enabled: false
      },
      showInLegend: true
   }
}

*_app.component.ts_*
import { Component } from '@angular/core';
import * as Highcharts from 'highcharts';
@Component({
  selector: 'app-root',
  templateUrl: './app.componentl',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
   highcharts = Highcharts;
   chartOptions = {
      chart : {
         plotBorderWidth: null,
         plotShadow: false
      },
      title : {
         text: 'Browser market shares at a specific website, 2014'
      },
      tooltip : {
         pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
      },
      plotOptions : {
         pie: {
            allowPointSelect: true,
            cursor: 'pointer',

            dataLabels: {
               enabled: false
            },

            showInLegend: true
         }
      },
      series : [{
         type: 'pie',
         name: 'Browser share',
         data: [
            ['Firefox',   45.0],
            ['IE',       26.8],
            {
               name: 'Chrome',
               y: 12.8,
               sliced: true,
               selected: true
            },
            ['Safari',    8.5],
            ['Opera',     6.2],
            ['Others',      0.7]
         ]
      }]
   };
}

結果

結果を確認します。

凡例付きの円グラフ