如何使用角度 JS 创建甜甜圈高图



我想使用角度js创建一个甜甜圈高图。

JavaScript是-

$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: 0,
            plotShadow: false
        },
        title: {
            text: 'Browser<br>shares<br>2015',
            align: 'center',
            verticalAlign: 'middle',
            y: 40
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                dataLabels: {
                    enabled: true,
                    distance: -50,
                    style: {
                        fontWeight: 'bold',
                        color: 'white',
                        textShadow: '0px 1px 2px black'
                    }
                },
                startAngle: -180,
                endAngle: 180,
                center: ['50%', '55%']
            }
        },
        series: [{
            type: 'pie',
            name: 'Browser share',
            innerSize: '50%',
            data: [
                ['Firefox',   10.38],
                ['IE',       56.33],
                ['Chrome', 24.03],
                ['Safari',    4.77],
                ['Opera',     0.91],
                {
                    name: 'Proprietary or Undetectable',
                    y: 0.9,
                    dataLabels: {
                        enabled: false
                    }
                }
            ]
        }]
    });
});

HTML是-

<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>

我正在包含这些脚本文件 -

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
    <script src="https://code.highcharts.com/highcharts.js"></script>
    <script src="https://code.highcharts.com/modules/exporting.js"></script>

我将如何在角度js中转换上述脚本。谁能帮我解决这个问题?我认为需要创建一些指令函数。我是角度自定义指令的新手,任何人都可以帮助我们如何在角度中为甜甜圈高图做到这一点吗?

无需将高图表转换为角度,因为它已经存在。无需注入依赖项。您可以直接使用它。只需注入高图表文件

<script src="script/chart/highcharts.js"></script>
<script src="script/chart/highcharts-more.js"></script>
<script src="script/chart/drilldown.js"></script>
<script src="script/chart/highcharts-3d.js"></script>
<script src="script/chart/exporting.js"></script>

在控制器中直接使用 Highcharts.chart({//code go here})。这是甜甜圈高图的链接

最新更新