高图yAxis错误

时间:2015-05-08 08:16:10

标签: angularjs highcharts

这是高图表的配置文件

$scope.chartConfig1 = {
        options: {
            chart: {

                borderColor: '#EBBA95',
                borderWidth: 3,
            },

        },
        yAxis: [],

        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },

        legend: {
            enabled: true
        },
        series: [],
        title: {

        },
        xAxis: {

       }

    }

这是我将数据插入chartConfig1

的代码片段
var yAxisObj = {
        labels: {
            style: {
                    color: Highcharts.getOptions().colors[1]
            }
        },
        title: {
            style: {
                color: Highcharts.getOptions().colors[1]
            }
        }
    };

    $scope.maxHistogramGraph = function(){


            var StartDate = new Date($scope.data1.date);
            var EndDate = new Date($scope.data2.date);

            if(parseFloat(StartDate.getTime())>= parseFloat(EndDate.getTime())){
                $scope.histDiv = false;
                console.log("start date bigger");
                alert("Your Date & Time selection is wrong");
            }else{

                $scope.histDiv = true;
                var finalStartDate = new Date($scope.data1.date).toISOString();
                var finalEndDate = new Date($scope.data2.date).toISOString();
                var intervalSelected = $scope.intervalSelected;
                setTemporalFilter(finalStartDate,finalEndDate,intervalSelected);
                var attrArray = [];
                attrArray.push($scope.sensorattrSelected);
                var op = "extended_stats";
                var data = aggregations($scope.sensornameSelected.sensorname, attrArray, op);


                $scope.chartConfig1.series = [];



                var names = [];

                var finalData = [];


                var buck1 = data[1].aggregations.group_by_name.buckets
                for(var x = 0; x < buck1.length; x++){          
                    var data_series = {"name":buck1[x].key,"data":[]};
                    angular.forEach(buck1[x].articles_over_time.buckets, function(value, key){
                            var temData = [];
                            temData.push(value.key,value.extended_stats_values.max);
                            data_series.data.push(temData);
                            /*data_series.max.push(value.extended_stats_values.max);
                            data_series.min.push(value.extended_stats_values.min);
                            data_series.avg.push(value.extended_stats_values.avg);
                            data_series.sum.push(value.extended_stats_values.sum);*/
                        });
                    finalData.push(data_series);

                };      
                $scope.chartConfig1.yAxis.push(yAxisObj);
                console.log("yaxisObj......");
                console.log(angular.toJson($scope.chartConfig1.yAxis));
                $scope.chartConfig1.series = angular.copy(finalData);
                $scope.chartConfig1.xAxis.type = 'datetime';
                $scope.chartConfig1.yAxis[0].title.text = $scope.sensorattrSelected;
                $scope.chartConfig1.title.text = $scope.sensorattrSelected+" Histogram"
                console.log("$scope.chartConfig1......");
                console.log(angular.toJson($scope.chartConfig1));
            }   


        };

所有数据都插入得很好,但仍然出现此错误 Highcharts错误#18:www.highcharts.com/errors/18

  

Highcharts Error#18

     

请求的轴不存在

     

设置系列时会发生此错误。 xAxis或yAxis属性指向不存在的轴。

请帮忙...... !!

1 个答案:

答案 0 :(得分:0)

而不是使用$ scope.chartConfig1.yAxis = [yAxisObj];使用$ scope.chartConfig1.options.yAxis = [yAxisObj];