Quantcast
Channel: ThingSpeak IoT Community - All Forums
Viewing all articles
Browse latest Browse all 1833

mazo on Google gauge - how to remove comma from 1,000.00

$
0
0

Hi,

i would like to display pressure value in format: 1029.61 but the plugin returns like 1,029.61. Please if anybody can help me.

 

Press - gauge

 

Code:

 

<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>

// set your channel id here
var channel_id = xxxxxxx;
// set your channel's read api key here if necessary
var api_key = 'xxxxxxx';
// maximum value for the gauge
var max_gauge_value = 1060;
// name of the gauge
var gauge_name = 'P [mBar]';

// global variables
var chart, charts, data;

// load the google gauge visualization
google.load('visualization', '1', {packages:['gauge']});
google.setOnLoadCallback(initChart);

// display the data
function displayData(point) {

data.setValue(0, 0, gauge_name);
data.setValue(0, 1, point);
chart.draw(data, options);
}

// load the data
function loadData() {

// variable for the data point
var p;

// get the data from thingspeak
$.getJSON('https://api.thingspeak.com/channels/' + channel_id + '/feed/last.json?api_key=' + api_key, function(data) {

// get the data point
p = data.field3;

// if there is a data point display it
if (p) {
//p = Math.round((p / max_gauge_value) * 1023);
displayData(p);
}

});
}

// initialize the chart
function initChart() {

data = new google.visualization.DataTable();
data.addColumn('string', 'Label');
data.addColumn('number', 'Value');
data.addRows(1);

chart = new google.visualization.Gauge(document.getElementById('gauge_div'));
options = {
width: 240, height: 240, min: 960, max: 1060,
majorTicks: [960, 980, 1000, 1020, 1040, 1060], minorTicks: 10,

greenFrom: 995,
greenTo: 1030,
greenColor: "#00e600"
};

loadData();

// load new data every 15 seconds
setInterval('loadData()', 15000);
}

</script>

 


Viewing all articles
Browse latest Browse all 1833

Trending Articles