Highcharts -Messgeräte, festgelegte Daten nach $ .getJson -Anruf festlegenPhp

PHP-Programmierer chatten hier
Anonymous
 Highcharts -Messgeräte, festgelegte Daten nach $ .getJson -Anruf festlegen

Post by Anonymous »

Ich habe Schwierigkeiten, die Daten vom PHP-Skript empfangen zu lassen und sie in den Gauge-Diagramm einzustellen. Wert im Gauge -Diagramm.

Code: Select all

$('#container-C_2').highcharts(
mit einigen Argumenten, aber nicht wissen, wie
PHP

Code: Select all

$result = array();
$result['name'][0] = 'A';

//--some values
$result['min'][] = 10;
$result['max'][] = 50;
$result['val'][]  = 20;

$json = array();
array_push($json,$result);

print json_encode($json);
Client-Seite :

Code: Select all




Highcharts Example








$(document).ready(function() {

var gaugeOptions = {

chart: {
type: 'solidgauge'
},

title: null,

pane: {
center: ['50%', '100%'],
size: '100%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
},

tooltip: {
enabled: false
},

// the value axis
yAxis: {
stops: [
[0.25, '#DF5353'], // red
[0.5, '#DDDF0D'], // yellow
[0.75, '#55BF3B'], // green
],
lineWidth: 0,
minorTickInterval: null,
tickPixelInterval: 400,
tickWidth: 0,
title: {
y: -70
},
labels: {
y: 16
}
},

plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
}
};  //-- gaugeOptions

// The C_1 gauge
$('#container-C_1').highcharts(Highcharts.merge(gaugeOptions, {
yAxis: {
min: -50,
max: 50,
title: {
text: 'graph 1'
}
},

credits: {
enabled: false
},

series: [{
name: 'C_1',
data: [-50],
dataLabels: {
format: '{y}
' +
'  graph... '
},
tooltip: {
valueSuffix: ' graph... '
}
}]

}));

// The C_2 gauge
$('#container-C_2').highcharts(Highcharts.merge(gaugeOptions, {
yAxis: {
min: -50,
max: 50,
title: {
text: 'C_2'
}
},
series: [

{
name: 'C_2',
data: [45],
dataLabels: {
format: '{y:.1f}
' +
' graph...  '
},
tooltip: {
valueSuffix: ' graph... '
}
}

]

})); //--container-C_2

$.getJSON("query.php", function(json) {

//this WORKS!
alert("name, grow_rate: " + json[0]['name'] + ","+ json[0]['val'] );

//This seems not to have any effect
gaugeOptions.yAxis.min = json[0]['min'];
gaugeOptions.yAxis.max = json[0]['max'];
gaugeOptions.yAxis.title.text = 'JUST SOME TEXT...';

gaugeOptions.series[0] = {};
//gaugeOptions.series[0].name = json[0]['name'][0];
gaugeOptions.series[0].name = json[0]['name'];
gaugeOptions.series[0].data = json[0]['val'];

//--            stucked here, how can I passed retreived values to the graph?
// chart = new Highcharts.merge(gaugeOptions);

});

});  //-- ready()






















Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post