使用Highstock与x轴和y轴数据的问题

时间:2017-05-24 18:31:23

标签: javascript highcharts highstock

当我尝试在我的proyect中使用Highstock时,我遇到了一些问题。例如,我试图制作一张图表“Provincias”x“Raza”,事情就是图表没有向我展示所有的“Provincias”。

enter image description here

但是,如果我改变图表的类型,我会看到它的

enter image description here

我在客户端使用的js是:

$scope.MultiDataGrafics = function (rs, title, text) {
                $scope.chartConfig5.xAxis.categories = rs.data.categories;
                $scope.chartConfig5.series = rs.data.data;
                $scope.chartConfig5.xAxis.title.text = text;
                $scope.chartConfig5.title.text = title;
                $scope.chartConfig5.loading = false;
            }

我在另一个要求数据的函数中调用此函数

//Some Code here not important now
else if (value == '43') {
                        $http.get("/Estadisticas/EstadisticasNivelEscolarProvincia").then(function(rs) {
                            $scope.MultiDataGrafics(rs, 'Estadísticas por Nivel Escolar y Provincia', 'Nivel Escolar', 'Provincia');
                        });

我发布json以提供更多数据,但我认为没问题,因为在饼图中显示所有“Provincias”。

{"categories": ["Primaria","Secundaria","Preuniversitario/Bachiller","Técnico Medio","Universitario"
,"Master en Ciencias"], "data": [{"name": "Artemisa", "center": ["30%"], "data": [{"name": "Primaria"
, "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico
 Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name":
 "Camagüey ", "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0
},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario"
, "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name": "Ciego de Ávila", "center": ["70%"], "data"
: [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller"
, "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias"
, "y": 0}]},{"name": "Cienfuegos", "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name":
 "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico Medio", "y":
 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name": "Granma", "center"
: ["70%"], "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario
/Bachiller", "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master
 en Ciencias", "y": 0}]},{"name": "Guantánamo", "center": ["70%"], "data": [{"name": "Primaria", "y"
: 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico
 Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name":
 "Holguín", "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},
{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario"
, "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name": "Isla de la Juventud", "center": ["70%"]
, "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller"
, "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias"
, "y": 0}]},{"name": "La Habana", "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria"
, "y": 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario"
, "y": 2},{"name": "Master en Ciencias", "y": 0}]},{"name": "Las Tunas", "center": ["70%"], "data": 
[{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y"
: 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias"
, "y": 0}]},{"name": "Matanzas", "center": ["70%"], "data": [{"name": "Primaria", "y": 1},{"name": "Secundaria"
, "y": 0},{"name": "Preuniversitario/Bachiller", "y": 1},{"name": "Técnico Medio", "y": 0},{"name": "Universitario"
, "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name": "Mayabeque", "center": ["70%"], "data": 
[{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y"
: 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias"
, "y": 0}]},{"name": "Pinar del Río", "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name"
: "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico Medio", "y"
: 1},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name": "Sancti Spíritus"
, "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario
/Bachiller", "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master
 en Ciencias", "y": 0}]},{"name": "Santiago de Cuba", "center": ["70%"], "data": [{"name": "Primaria"
, "y": 0},{"name": "Secundaria", "y": 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico
 Medio", "y": 0},{"name": "Universitario", "y": 0},{"name": "Master en Ciencias", "y": 0}]},{"name":
 "Villa Clara", "center": ["70%"], "data": [{"name": "Primaria", "y": 0},{"name": "Secundaria", "y":
 0},{"name": "Preuniversitario/Bachiller", "y": 0},{"name": "Técnico Medio", "y": 0},{"name": "Universitario"
, "y": 0},{"name": "Master en Ciencias", "y": 0}]}]}

初始图表配置为:

    $scope.chartConfig5 = {
                    options: {
                        chart: {
                            type: 'bar'
                        }
                    },
                    xAxis: {
                        title: {
                            text: ''
                        }
                    },
                    series: [{}],
                    title: {
                        text: 'Estadísticas por Raza y Sexo'
                    },
                    loading: true};

0 个答案:

没有答案