Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 自定义指令的单选按钮_Javascript_Angularjs_Highcharts - Fatal编程技术网

Javascript 自定义指令的单选按钮

Javascript 自定义指令的单选按钮,javascript,angularjs,highcharts,Javascript,Angularjs,Highcharts,我有一个指令,使highcharts区域样条曲线图成为一个可重用元素,如下所示: angular.module('statisticsApp') .directive('stockchart', function ($http) { return { transclude: true, template: '<div></div>', restrict: 'E',

我有一个指令,使highcharts区域样条曲线图成为一个可重用元素,如下所示:

angular.module('statisticsApp')
    .directive('stockchart', function ($http) {

        return {
            transclude: true,
            template: '<div></div>',
            restrict: 'E',
            scope: {},
            link: function postLink(scope, element, attrs) {
                // scope.country=attrs.country;
                var type=attrs.type;
                var currencies=attrs.currencies;
                var baseRestUrl="http://mydomain/background/rest/statistics";
                var realUrl=baseRestUrl + "/" + type;
                if (type == "equity") {
                    realUrl += "/" + scope.country;
                    scope.header="Equity per day - " + scope.country;                   
                }
                // alert(realUrl);
                $http.get(realUrl).then(
                    function successCallback(response){
                        var equity = response.data;
                        var arrayLength = equity.length;

                        var serie =  {
                                    name: scope.country,
                                    data: []
                                    }
                        var categories = [];
                        for ( var i = 0; i < arrayLength; i+=1) {
                            var seriesName = equity[i][2];
                            var currency = equity[i][3];
                            var date = equity[i][0];
                            var amount = equity[i][1];

                            if ( currency == "EUR") {
                                serie["data"].push(amount);
                                categories.push(date);
                            } 
                        }
                        var series = [];
                        series.push(serie);

                        element.highcharts({
                            chart: {
                                type: "areaspline"
                            },
                            title: {
                                text: scope.header
                            },
                            legend: {
                                layout: "vertical",
                                align: "left",
                                verticalAlign: "top",
                                x: 150,
                                y: 100,
                                floating: true,
                                borderWidth: 1,
                                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || "#FFFFFF"
                            },
                            tooltip:{
                                valueDecimals : 2
                            },
                            yAxis: {
                                title: {
                                    text: 'Amount'
                                }
                            },
                            xAxis: {
                                categories: categories
                            },
                            series: series
                        });
                    },
                    function errorCallBack(response){
                        equity = ["It", "did", "not", "work"];
                    }
                );
            }
        };
    });
角度模块('statisticsApp') .directive('stockchart',函数($http){ 返回{ 是的, 模板:“”, 限制:'E', 作用域:{}, 链接:函数postLink(范围、元素、属性){ //scope.country=attrs.country; var type=attrs.type; var货币=属性货币; var baseRestUrl=”http://mydomain/background/rest/statistics"; var realUrl=baseRestUrl+“/”+类型; 如果(类型=“权益”){ realUrl+=“/”+scope.country; scope.header=“每日权益-”+scope.country; } //警报(realUrl); $http.get(realUrl)。然后( 函数成功回调(响应){ var equity=响应数据; var arrayLength=股权长度; 变量系列={ 名称:scope.country, 数据:[] } var类别=[]; 对于(变量i=0;i 我试图绑定一些单选按钮来删除HTML硬编码的货币和国家

在HTML中,我有

<div>
    <form>
        <h3>Currency</h3>
        <input type="radio" ng-model="currency" name="currency" value="EUR"> EUR<br/>
        <input type="radio" ng-model="currency" name="currency" value="USD"> USD<br/>
        Other: <input type="text" ng-model="currency" name="currency" value=""><br/>
    </form>
    <form>
        <h3>Country</h3>
        <input type="radio" ng-model="country" name="country" value="BE"> BE<br/>
        <input type="radio" ng-model="country" name="country" value="NL"> NL<br/>
        <input type="radio" ng-model="country" name="country" value="FI"> FI<br/>
        <input type="radio" ng-model="country" name="country" value="CZ"> CZ<br/>
        <input type="radio" ng-model="country" name="country" value="DE"> DE<br/>
        <input type="radio" ng-model="country" name="country" value="FR"> FR<br/>
    </form>
    <stockchart country="BE" type="equity" currencies="EUR"></stockchart>
    <stockchart country="NL" type="equity" currencies="EUR"></stockchart>
</div>

通货
欧元
美元
其他:
国家 是
NL
FI
CZ
DE
FR
我希望能够将最后一行减少到1行: 或者是同样全球化的东西