d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Help With Updating Chart Data > Loop Wont Work- Jquery/javascript
Add Reply New Topic New Poll
Member
Posts: 2,081
Joined: Jan 13 2007
Gold: 515.76
Oct 13 2014 01:27pm
This should redisplay every month changing the title to each month... It only shows January, then February.
why is this
Please help
Much appreciated and will be compensated.

Code
<script>
$(document).ready(function() {
var data1 = {
chart : {
type : 'column',
plotBackgroundImage: "lottographs_background.bmp"
},
title : {
text : "January's Picks"
},
xAxis : {
dateTimeLabelFormats: {
month: '%B'
},
categories : [ '1', '2','3','4','5','6','7','8','9','10','11','12','13',
'14','15','16','17','18','19','20','21','22','23',
'24','25','26','27','28','29','30','31','32','33',
'34','35','36','37','38','39','40' ]
},
yAxis : {
title : {
text : 'Numbers'
}
},
series : [ {
name : 'January',
data : [ 10, 24, 2,5,11,13,54,2,62,22,2,12,21,2,25,52,15,15,16,17,18,20,31,23,12,13,14,15,16,11,17,18,44,3,5,6,7,4,5,3 ],
color: '#FFFF00'
}, ]};

//call it once
myFunction(data1);

// change some of the data
for ( var i = 1; i < 13; i++ ) {

if (i = 1){
setTimeout(function() {
myFunction(data1);
}, 3000)
data1.title.text="February's Picks";
break;
}

else if (i = 2){
setTimeout(function() {
myFunction(data1);
}, 3000)
data1.title.text="March's Picks";
break;
}

else if (i = 3) {
setTimeout(function() {
myFunction(data1);
}, 3000)
data1.title.text="April's Picks";
break;
}

else if (i = 4){
setTimeout(function() {
myFunction(data1);
}, 3000)
data1.title.text="May's Picks";
break;
}

else if (i = 5){
setTimeout(function() {
myFunction(data1);
}, 3000)
data1.title.text="June's Picks";
break;
}
}
});
function myFunction(data1) {
$('#container').highcharts(data1);
}
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Oct 13 2014 01:51pm
What are the errors showing up in your browser's console?
Member
Posts: 2,081
Joined: Jan 13 2007
Gold: 515.76
Oct 13 2014 02:53pm
Quote (Blind[zF&#93; @ Oct 13 2014 07:51pm)
What are the errors showing up in your browser's console?


No errors, it is just not displaying what I want it to..

It is showing January (wait 3 seconds) then February..
When It should display every month for 3 seconds.
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Oct 13 2014 05:48pm
Quote (mcfighter @ Oct 13 2014 12:53pm)
No errors, it is just not displaying what I want it to..

It is showing January (wait 3 seconds) then February..
When It should display every month for 3 seconds.


Your conditional if statements are wrong.

You're actually setting the value of i by using a single =

Code
if(i = 2) {

}


should be

Code
if(i ==2) {

}


and so on
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Oct 13 2014 06:03pm
Quote (SelfTaught @ Oct 13 2014 06:48pm)
Your conditional if statements are wrong.

You're actually setting the value of i by using a single =

Code
if(i = 2) {

}


should be

Code
if(i ==2) {

}


and so on


Yah, I told him that via PM's he's got other issues too.

I might have time to look at it tonight. The fixing of the if statements didn't have any effect.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll