gpt4 book ai didi

javascript - Highcharts JS 未捕获类型错误 : x[(intermediate value)(intermediate value)(intermediate value)] is not a constructor

转载 作者:行者123 更新时间:2023-11-30 16:00:27 24 4
gpt4 key购买 nike

我正在构建一个条形图,从 ajax 响应中检索选项。但是当我将对象传递给 highcharts 构造函数时,我收到以下错误

Uncaught TypeError: x[(intermediate value)(intermediate value)(intermediate value)] is not a constructor

我的 ajax 响应是这样的(使用 JsonLint 验证):

{
"chart": {
"type": "column"
},
"title": {
"text": "Resumo diario de Movimentos"
},
"subtitle": {
"text": "Selecione os Fornecedores em questão"
},
"xAxis": {
"categories": [
"Indiferenciado", "Papel / Cartão", "Madeira", "Vidro", "Metais", "Ramagem", "Pneus", "Plástico Não Reciclável", "Embalão", "REEE", "Lâmpadas", "Pilhas", "Compostagem", "Diversos Incineração", "Diversos Aterro", "Outros", "Diversos", "Embalão/Vidro", "Roupas e Brinquedos", "Cemitério", "Papel", "Cartão", "Papel Porta a Porta", "Orgânico", "RX", "Orgânico Porta a Porta", "Embalão Porta a Porta", "Vidro Porta a Porta", "Plástico Filme", "Esferovite", "Mad. Shopping", "Forum Madeira", "Mad. Carlton", "Capa 2", "Oleos Alimentares Usados", "Papel Saco Azul", "Estilha", "Baterias", "Paletes"
],
"crosshair": true
},
"yAxis": {
"min": 0,
"title": {
"text": "Peso (Kg)"
}
},
"tooltip": {

"shared": true,
"useHTML": true
},
"plotOptions": {
"column": {
"pointPadding": 0.2,
"borderWidth": 0
}
},
"series": [{
"name": "Tokyo",
"data": [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 71.5, 106.4, 129.2, 144.0, 55],
"visible": false
}, {
"name": "Tokyo",
"data": [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 71.5, 106.4, 129.2, 144.0, 55],
"visible": false
}

]
}

现在,当我尝试使用传入数据启动 Highcharts 时

 <script>
$(function(){
$.post("/ajax/getResumo/diario")
.done(function(dataInc) {
$("#chartContainer").highcharts(dataInc);
});
});

</script>

我收到以下错误

Uncaught TypeError: x[(intermediate value)(intermediate value)(intermediate value)] is not a constructor

但是如果我将来 self 的 ajax 的响应直接复制并粘贴到 Highcharts 构造函数中,它工作正常。

知道如何解决这个问题吗?

最佳答案

$("#chartContainer").highcharts(JSON.parse(dataInc));

必须解析,传入的响应是一个字符串

关于javascript - Highcharts JS 未捕获类型错误 : x[(intermediate value)(intermediate value)(intermediate value)] is not a constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37857734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com