高图表规范getJson问题..。
我有一个php文件,它回显了几个不同的json_encode。这是输出。我需要只抓取三个高图表中的每一个的量规数据。其他一切都正常..。这是clickdates.php的输出。
{"ampPowerP":161,"dayPowerP":4.24,"monthAmpP":755,"monthPowerP":19.78,"yearAmpP":14015,"yearPowerP":369.5,"stateC":24,"gauge2":29.2,"gauge3":69.2}
我现在的重点是3尺输出,从我的阅读是正确的格式输出,与高图表文件说,它正在寻找什么。
也许我把自己搞糊涂了,所以我制作了三个单独的JS文件来保持简单.对于每个div,将显示每个高图表规格的量程1.js、量程2.js和量程3.js文件。我已经尝试了百万种方法,如在高海图论坛上列出的,以及在这里得到的答案,但都没有效果。我得到一个没有显示针的量规。我回到了基础,这是我的基础,为每一个gauge.js,我试图使工作。
这是量规1.js
$(document).ready(function() {
var options = {
chart: {
type: 'gauge',
renderTo: 'minVolt',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false,
backgroundColor: null,
borderWidth: 0,
spacingTop: 0,
spacingLeft: 0,
spacingRight: 0,
spacingBottom: 0,
},
title: {
text: null
},
pane: {
startAngle: -150,
endAngle: 150,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#FFF'],
[1, '#333']
]
},
borderWidth: 0,
outerRadius: '109%'
}, {
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#333'],
[1, '#FFF']
]
},
borderWidth: 1,
outerRadius: '107%'
}, {
// default background
}, {
backgroundColor: '#DDD',
borderWidth: 0,
outerRadius: '105%',
innerRadius: '103%'
}]
},
// the value axis
yAxis: {
min: 20,
max: 40,
minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickColor: '#666',
tickPixelInterval: 20,
tickWidth: 2,
tickPosition: 'inside',
tickLength: 10,
tickColor: '#666',
labels: {
step: 2,
rotation: 'auto'
},
title: {
y: 20,
text: 'Volts'
},
plotBands: [{
from: 20,
to: 22,
color: '#DF5353' // red
}, {
from: 22,
to: 23,
color: '#FFFF00' // yellow
}, {
from: 23,
to: 30,
color: '#55BF3B' // green
}, {
from: 30,
to: 40,
color: '#DF5353' // red
}]
}, credits: {
enabled:false,
},
series: [{
name: 'Volt',
data: [],
tooltip: {
enabled: false
},
}] };
$.getJSON('clickdates.php', function(gauge1) {
options.series[0].data = gauge1;
var chart = new Highcharts.Chart(options);
}); });
getJSON中的某些东西肯定是我没有看到的,也不是我所理解的.海图正在寻找格式..。
{"gauge1":[24]}..。这就是我要发送的..。
这个$.getJSON应该工作,因为我有图表显示,但没有数据从数据库.
$.getJSON('clickdates.php', function(gauge1) { options.series[0].data = gauge1; var chart = new Highcharts.Chart(options);
一定很简单,但我看不见.而我的努力似乎都没有把JSON的数据放进量规.
我们非常感谢你的智慧。
艾伦
发布于 2016-10-16 04:52:05
经过几天的阅读和尝试了无数不同的事情。很简单的事情我没看到..。
$.getJSON('clickdates.php', function(data) {
options.series[0].data = data.gauge1;
var chart5 = new Highcharts.Chart(options);阿贾克斯让我找到了答案..。
$.ajax({
url: "clickdates.php",
data: 'gauge1',
type:'get',
dataType: "json",
cache: false,
success: function(json_data){
options.series[0].data = json_data.gauge1;
var chart5 = new Highcharts.Chart(options);
}
});一直就在我眼皮底下.
祝你周末愉快。
艾伦
https://stackoverflow.com/questions/39992642
复制相似问题