0

我曾尝试使用 highcharts-ng 在 MEANJS 中创建图表,但它不起作用。什么是 highcharts-ng 的最佳选择。

1.我已经安装了highcharts使用

bower install highcharts-ng

2. 将其包含在 applicationModuleVendorDependencies 中

var applicationModuleVendorDependencies = ['ngResource', 'ui.router', 'ui.bootstrap', 'ui.utils','highcharts-ng'];

3.包含在资产库中

assets: {
    lib: {
        css: [
            'public/lib/bootstrap/dist/css/bootstrap.css',
            'public/lib/bootstrap/dist/css/bootstrap-theme.css',
        ],
        js: [
            'public/lib/angular/angular.js',
            'public/lib/angular-resource/angular-resource.js', 
            'public/lib/angular-ui-router/release/angular-ui-router.js',
            'public/lib/angular-ui-utils/ui-utils.js',
            'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
            'public/lib/highstock/js/highcharts.src.js',
            'public/lib/highcharts-ng/dist/highcharts-ng.js',
            'public/lib/file-saver/FileSaver.js'
        ]

4.将以下代码放入Index.htm

<div ng-app="myapp">
    <div ng-controller="myctrl">
       <div class='container'>
                    <highchart id='example1' config='config'></highchart>
        </div>
    </div>
    </div>
  1. 并将以下代码放入控制器中

    var myapp = angular.module('myapp', ["highcharts-ng"]);

    myapp.controller('myctrl', function ($scope) {

    $scope.config = {
        options: {
            chart: {
                type: 'column'
            },
        },
        xAxis: {
            categories: ['Yes', 'No']
        },
        series: [{
            name: 'Votes',
            data: [0, 0]
        }],
        title: {
            text: 'Data-binding Example'
        },
        subtitle: {
            text: 'Is this easy?'
        },
        credits: {
            enabled: false
        },
        loading: false
    };
    

视图没有显示图表。我错过了什么吗?谢谢你。

4

1 回答 1

0

您必须使用以下命令安装原始的 highchart:

bower install highcharts-release    

并使用 highchart-ng 加载它:

...
'public/lib/highcharts-release/adapters/standalone-framework.js',
'public/lib/highcharts-release/highcharts.js',
'public/lib/highcharts-ng/src/highcharts-ng.js',
...   

并且声明模块时不要加载两次highchart-ng(只需要在applicationModuleVendorDependencies中做):

var myapp = angular.module('myapp');  
于 2015-01-06T20:27:45.117 回答