Hardware Reference
In-Depth Information
Discussion
You can perform plotting externally, via the
jsfiddle
site, or locally.
Plotting with jsfiddle
plot. The JavaScript code in
Example 6-5
then reads the analog in and creates the plot to
display.
Example 6-5. Code for plotting data with Flot (flotDemo.js)
setTargetAddress
(
'192.168.7.2'
, {
initialized
:
run
});
function
run
() {
var
b
=
require
(
'bonescript'
);
var
POT
=
'P9_36'
;
var
container
=
$
(
"#myplot"
);
var
totalPoints
=
container
.
outerWidth
() /
2
||
250
;
var
data
= [];
var
plotOptions
= {
series
: {
shadowSize
:
0
},
yaxis
: {
min
:
0
,
max
:
1
},
xaxis
: {
min
:
0
,
max
:
totalPoints
,
show
:
false
}
};
var
plot
=
$
.
plot
(
container
,
getData
(),
plotOptions
);
drawGraph
();
function
drawGraph
() {
plot
.
setData
(
getData
());
plot
.
draw
();