Error: v.toFixed is not a function

290 views
Skip to first unread message

xoundboy

unread,
Aug 10, 2009, 5:24:55 PM8/10/09
to Flot graphs
Hi flot people

I had my graph working fine under time mode but now i switched to
scalar mode the graph won't display and I get the js debugger
reporting an error:


Error: v.toFixed is not a function
Source File: http://centos-cf7/app/js/jquery.flot.js
Line: 672

here's the code.

<!--[if IE]><script language="javascript" type="text/javascript"
src="../../js/excanvas.pack.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="../../js/
jquery.flot.js"></script>
<script language="javascript" type="text/javascript">
$(function () {
var series1Series = [["04 Aug", 17.23],["05 Aug", 22.41],["06 Aug",
21.0],["07 Aug", 16.96],["10 Aug", 19.96],["11 Aug", 17.5]];
var series2Series = [["04 Aug", 46.0],["04 Aug", 50.32],["04 Aug",
45.24],["04 Aug", 46.75],["04 Aug", 38.0],["04 Aug", 48.32]];
var options = {
legend: {
show: true,
position: "ne",
backgroundOpacity:0.5,
backgroundColor: "rgb(255,255,255)",
margin: 3
},
xaxis: {
ticks: ["04 Aug","05 Aug","06 Aug","07 Aug","10 Aug","11 Aug"],
tickSize:[5, "day"]
}
,yaxis: {
autoscaleMargin:0.2,
tickFormatter: function (v, axis) { return " £" + v.toFixed
(axis.tickDecimals) },
ticks: 5,
tickDecimals: 0
,min: "0.0",
max: "25.0"
}
,y2axis: {
autoscaleMargin:1.0,
tickFormatter: function (v, axis) { return " £" + v.toFixed
(axis.tickDecimals) },
ticks: 5,
tickDecimals: 0
}
,grid: {
color: "rgb(153,153,153)",
borderWidth: 2
}
};
$.plot($("#chart_21"), [
// plot series 2 first so that it goes
underneath the primary series
{
label: "MichalCo Share Price",
data: series2Series,
color: "rgb(0,0,0)",
bars: {
show: true,
barWidth: 86400000,
lineWidth:2,
fill: true,
align: "center"
}
,yaxis: 2
,shadowSize: 5
},
{
label: "FTSE 100",
data: series1Series,
color: "rgb(5,39,235)",
lines: {
show: true,
lineWidth:2,
fill: false
}
,shadowSize: 5
}
], options);
});
</script>
<div style="height:300px;width:400px;" id="chart_21"></div>


any help very gratefully received. thanks

xoundboy

unread,
Aug 11, 2009, 3:07:25 AM8/11/09
to Flot graphs
I solved it. The problem was that I was using the tick label as the x
coordinate in the data series instead of a number value.

So now if i put:

var series1Series = [[1, 17.23],[2, 22.41],[3, 21.0],[4, 16.96],
[5, 19.96],[6, 17.5]];
var series2Series = [[1, 46.0],[2, 50.32],[3, 45.24],[4, 46.75],
[5, 38.0],[6, 48.32]];

and...

xaxis: {
ticks: [[1,"04 Aug"], [2,"05 Aug"], [3,"06 Aug"], [4,"07 Aug"],
[5,"10 Aug"], [6,"11 Aug"]]
}

..I get the desired results

Reply all
Reply to author
Forward
0 new messages