/* ---------- income with points ---------- */
if ($("#incomeChart").length)
{
var income = [[1, randNum() - 10], [2, randNum() - 10], [3, randNum() - 10], [4, randNum()], [5, randNum()], [6, 4 + randNum()], [7, 5 + randNum()], [8, 6 + randNum()], [9, 6 + randNum()], [10, 8 + randNum()], [11, 9 + randNum()], [12, 10 + randNum()], [13, 11 + randNum()], [14, 12 + randNum()], [15, 13 + randNum()], [16, 14 + randNum()], [17, 15 + randNum()], [18, 15 + randNum()], [19, 16 + randNum()], [20, 17 + randNum()], [21, 18 + randNum()], [22, 19 + randNum()], [23, 20 + randNum()], [24, 21 + randNum()], [25, 14 + randNum()], [26, 24 + randNum()], [27, 25 + randNum()], [28, 26 + randNum()], [29, 27 + randNum()], [30, 31 + randNum()], [31, 31 + randNum()]];
var plot = $.plot($("#incomeChart"),
[{data: income, label: "Income"}], {
series: {
lines: {show: true,
lineWidth: 3,
fill: true, fillColor: {colors: [{opacity: 0.5}, {opacity: 0.2}]}
},
points: {show: true},
shadowSize: 2
},
grid: {hoverable: true,
clickable: true,
tickColor: "#eee",
borderWidth: 0,
},
colors: ["#b1d3d4"],
xaxis: {ticks: 11, tickDecimals: 0},
yaxis: {ticks: 11, tickDecimals: 0},
});
function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css({
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 5,
border: '1px solid #fdd',
padding: '2px',
'background-color': '#dfeffc',
opacity: 0.80
}).appendTo("body").fadeIn(200);
}
var previousPoint = null;
$("#incomeChart").bind("plothover", function(event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(0),
y = item.datapoint[1].toFixed(2);
//--------------------
var d = new Date();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];
var dnm = "";
if(x.toString() === "1"){
dnm = "st";
}else if(x.toString() === "2"){
dnm = "nd";
}else if(x.toString() === "3"){
dnm = "rd";
}else if(x.toString() === "21"){
dnm = "st";
}else if(x.toString() === "22"){
dnm = "nd";
}else if(x.toString() === "23"){
dnm = "rd";
}else if(x.toString() === "31"){
dnm = "st";
}else{
dnm = "th";
}
showTooltip(item.pageX, item.pageY,
item.series.label + " of " + d.getFullYear() + " " + n + " " + x + dnm +" is Rs." + y);
}
}
else {
$("#tooltip").remove();
previousPoint = null;
}
});
$("#sincos").bind("plotclick", function(event, pos, item) {
if (item) {
$("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
plot.highlight(item.series, item.datapoint);
}
});
}