高图表未生成

时间:2015-05-05 07:34:41

标签: javascript html angularjs highcharts-ng

这是我的控制器

$scope.chartConfig2 = {
        options: {
            chart: {
                type: 'column',
                borderColor: '#EBBA95',
                borderWidth: 3,
            }
        },
        title: {

        },
        yAxis: [],

        tooltip: {
            shared: true
        },
        legend: {
            layout: 'vertical',
            align: 'left',
            x: 120,
            verticalAlign: 'top',
            y: 100,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
        },

        plotOptions: {
            column: {
                dataLabels: {
                    enabled: true
                }
            }
        },

        series: [],
        title: {

        },
        xAxis: {
            categories: []
       }

    }



    $scope.chartConfig2.series = [];

    $scope.dualaxesselectedGraph1 = function(){
        var primaryYaxisObj = {
            labels: {
                style: {
                        color: Highcharts.getOptions().colors[1]
                }
           },
            title: {
                style: {
                        color: Highcharts.getOptions().colors[1]
                }
            }
        };

        var secondaryYaxisObj = {
            title: {
                style: {
                        color: Highcharts.getOptions().colors[0]
                }
            },
            labels: {
                style: {
                        color: Highcharts.getOptions().colors[0]
                }
            },
            opposite: true
        };

            var attrArrayDual =[];
            attrArrayDual.push($scope.sensorattrSelected);
            var op =  "extended_stats";
            var data = aggregations($scope.sensornameSelected.sensorname, attrArrayDual, op);
            console.log("data........");
            console.log(angular.toJson(data));
                $scope.chartConfig2.series =[];


                $scope.dualgraphdiv = true;
                $scope.graphdiv = false;

                var master_obj3 = [];
                var xAxis = [];
                var maxData = [];
                var minData = [];
                var avgData = [];
                var sumData = [];

                var maxDataObj = {};
                var minDataObj = {};
                var avgDataObj = {};
                var sumDataObj = {};

                var name_json = data.aggregations.group_by_name.buckets;


                angular.forEach(name_json, function(value, key){ 
                    /*console.log("CreateDualGraph Value...");
                    console.log(value);
                    console.log("CreateDualGraph Key...");
                    console.log(key);*/                 
                    payload_series = {"name":value.key,"max":value.extended_stats_values.max,"min":value.extended_stats_values.min,"avg":value.extended_stats_values.avg,"sum":value.extended_stats_values.sum,"sum_of_squares":value.extended_stats_values.sum_of_squares,"variance":value.extended_stats_values.variance,"std_deviation":value.extended_stats_values.std_deviation,"count":value.extended_stats_values.count};

                        master_obj3.push(payload_series);

                });

                for (var i = 0; i < master_obj3.length; i++) {

                    xAxis.push(master_obj3[i].name);
                    maxData.push(master_obj3[i].max);
                    minData.push(master_obj3[i].min);
                    avgData.push(master_obj3[i].avg);
                    sumData.push(master_obj3[i].sum);

                }

                maxDataObj.name = "max";
                maxDataObj.type = "column";
                maxDataObj.yAxis = 1;
                maxDataObj.data =  maxData;

                minDataObj.name = "min";
                minDataObj.type = "column";
                minDataObj.yAxis = 1;
                minDataObj.data =  minData;

                avgDataObj.name = "avg";
                avgDataObj.type = "column";
                avgDataObj.yAxis = 1;
                avgDataObj.data =  avgData;

                sumDataObj.name = "sum";
                sumDataObj.type = "column";
                sumDataObj.yAxis = 1;
                sumDataObj.data =  sumData;

                $scope.chartConfig2.yAxis.push(primaryYaxisObj,secondaryYaxisObj);
                console.log("printing $scope.chartConfig2.yAxis");
                console.log(angular.toJson($scope.chartConfig2.yAxis));
                $scope.chartConfig2.series.push(maxDataObj,minDataObj,avgDataObj,sumDataObj);
                $scope.chartConfig2.xAxis.categories = xAxis;
                $scope.chartConfig2.yAxis[0].title.text = $scope.sensorattrSelected;
                $scope.dualaxesselectedGraph2();
    };


    $scope.dualaxesselectedGraph2 = function(){
            var attrArrayDual =[];
            attrArrayDual.push($scope.sensorattrSelectedSecondory);
            var op =  "extended_stats";
            var data = aggregations($scope.sensornameSelected.sensorname, attrArrayDual, op);
            console.log("data........");
            console.log(angular.toJson(data));

                $scope.dualgraphdiv = true;
                $scope.graphdiv = false;

                var master_obj3 = [];
                var xAxis = [];
                var maxData = [];
                var minData = [];
                var avgData = [];
                var sumData = [];

                var maxDataObj = {};
                var minDataObj = {};
                var avgDataObj = {};
                var sumDataObj = {};

                var name_json = data.aggregations.group_by_name.buckets;


                angular.forEach(name_json, function(value, key){ 

                    payload_series = {"name":value.key,"max":value.extended_stats_values.max,"min":value.extended_stats_values.min,"avg":value.extended_stats_values.avg,"sum":value.extended_stats_values.sum,"sum_of_squares":value.extended_stats_values.sum_of_squares,"variance":value.extended_stats_values.variance,"std_deviation":value.extended_stats_values.std_deviation,"count":value.extended_stats_values.count};

                        master_obj3.push(payload_series);

                });

                for (var i = 0; i < master_obj3.length; i++) {

                    xAxis.push(master_obj3[i].name);
                    maxData.push(master_obj3[i].max);
                    minData.push(master_obj3[i].min);
                    avgData.push(master_obj3[i].avg);
                    sumData.push(master_obj3[i].sum);

                }

                maxDataObj.name = "max";
                maxDataObj.type = "line";
                maxDataObj.data =  maxData;

                minDataObj.name = "min";
                minDataObj.type = "line";
                minDataObj.data =  minData;

                avgDataObj.name = "avg";
                avgDataObj.type = "line";
                avgDataObj.data =  avgData;

                sumDataObj.name = "sum";
                sumDataObj.type = "line";
                sumDataObj.data =  sumData;

                $scope.chartConfig2.series.push(maxDataObj,minDataObj,avgDataObj,sumDataObj);
                $scope.chartConfig2.xAxis.categories = xAxis;
                $scope.chartConfig2.yAxis[1].title.text = $scope.sensorattrSelectedSecondory;


                $scope.chartConfig2.title.text = $scope.sensorattrSelected +" "+$scope.sensorattrSelectedSecondory;
    };

高cahrt并非所有数据都被插入但我收到错误 Highcharts错误#18

请求的轴不存在

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

0 个答案:

没有答案