<!–
var root_url = "http://www.interest.co.nz/charts-csv/";
var tabs_count="7";
var csvfiles_loc= ["/charts-csv/chart_data/exchangerates/daily-usd.csv"," /charts-csv/chart_data/exchangerates/daily-aud.csv"," /charts-csv/chart_data/exchangerates/daily-twi.csv"," /charts-csv/chart_data/exchangerates/daily-yen.csv"," /charts-csv/chart_data/exchangerates/daily-yuan.csv"," /charts-csv/chart_data/exchangerates/daily-eur.csv"," /charts-csv/chart_data/exchangerates/daily-gbp.csv"];
var chart_title_arr= ["US dollar","Australian dollar","Trade weighted index","Japanese Yen","Chinese Yuan","Euro","British pound"];
var chart_subtitles_arr= ["Daily benchmark rate","Daily benchmark rate","Daily benchmark rate","Daily benchmark rate","Daily benchmark rate","Daily benchmark rate","Daily benchmark rate"];
var tab_titles_arr= ["US$","AU$","TWI","u00a5en","u00a5uan","u20acuro","GBP"];
var source_arr= ["RBNZ","RBNZ","RBNZ","RBNZ","RBNZ","RBNZ","RBNZ"];
var source_hyperlink_arr= ["8"];
var tabswidth="8";
var decimal_arr= ["4","4","4","2","2","4","4"];
// variable declaration
var xpad;
var padding_value=0;
var range_selector=0
var loc;
var updt;
var val_num;
var vi=0;
var max_val;
var x;
var finalAr = new Array();
for (var i = 0; i <= tabs_count; i++) {
finalAr[i] = new Array();
}
var flagAr = new Array();
for (var i = 0; i <= tabs_count; i++) {
flagAr[i] =[];
}
var yaxisAr = new Array();
for (var i = 0; i 536)
{
var b = arr.length – 536; // to get last 36 points
}
else if (arr.length < 536)
{
var b = 537 – arr.length;
}
else if(arr.length == 536)
{
var b=2;
}
// to generate the format for date representation in x axis
var timestamweek = 604800000;
var timestamday = 86400000;
var timestammonth30 = 2592000000;
var timestammonth31 = 2678400000;
var timestamyear = 31536000000;
var timestamquarterly = 7776000000;
for (var u=0;u<2;u++) {
arr[u] = parseLineCSV(arr[u]);
fomat= String(arr[u][0]);
var k=0;
do {
k++;
} while(fomat.charAt(k)!="-")
var k1 =k;
do {
k++;
} while(fomat.charAt(k)!="-")
var k2=k;
do {
k++;
} while(k<fomat.length)
var k3=k;
var dd= fomat.substring(0,k1);
var mm = fomat.substring(k1+1,k2);
var yy = "20"+fomat.substring(k2+1,k3+1);
var yy1=fomat.substring(k2+1,k3+1);
// conversion of months into numerical form
//+++++++++++++++++++++++++++++++++++
if (mm == "Jan")
{
mm= "01";
}
else if (mm == "Feb")
{
mm= "02";
}
else if (mm == "Mar")
{
mm= "03";
}
else if (mm == "Apr")
{
mm= "04";
}
else if (mm == "May")
{
mm= "05";
}
else if (mm == "Jun")
{
mm= "06";
}
else if (mm == "Jul")
{
mm= "07";
}
else if (mm == " Aug")
{
mm= "08";
}
else if (mm == "Sep")
{
mm= "09";
}
else if (mm == "Oct")
{
mm= "10";
}
else if (mm == "Nov")
{
mm= "11";
}
else if (mm == "Dec")
{
mm= "12";
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
var date2 = mm+"/"+dd+"/"+yy;
if (u==0)
{
var timestam1 = Date.parse(date2);
}
else if(u==1)
{
var timestam2 = Date.parse(date2);
}
}
var timestamvar = (timestam2- timestam1);
var flagAR_count=0;
for (var i=2;i<arr.length;i++) {
flagAR_count++;
var tempAr = new Array();
var tempAr1 = new Array();
arr[i] = parseLineCSV(arr[i]);
if (arr[i]!='')
{
fomat= String(arr[i][0]);
replic=String(arr[i][0]);
var k=0;
do {
k++;
} while(fomat.charAt(k)!="-")
var k1 =k;
do {
k++;
} while(fomat.charAt(k)!="-")
var k2=k;
do {
k++;
} while(k<fomat.length)
var k3=k;
var dd= fomat.substring(0,k1);
var mm = fomat.substring(k1+1,k2);
var current_year=""+new Date().getFullYear();
var c_year=Number(current_year.substring(2,4));
var c_data=Number(''+fomat.substring(k2+1,k3+1));
if(c_data c_year)
{
var yy = “19”+fomat.substring(k2+1,k3+1);
}
else if(c_data == c_year)
{
var yy = “20”+fomat.substring(k2+1,k3+1);
}
// conversion of months into numerical form
//+++++++++++++++++++++++++++++++++++
if (mm == “Jan”)
{
mm= “01”;
}
else if (mm == “Feb”)
{
mm= “02”;
}
else if (mm == “Mar”)
{
mm= “03”;
}
else if (mm == “Apr”)
{
mm= “04”;
}
else if (mm == “May”)
{
mm= “05”;
}
else if (mm == “Jun”)
{
mm= “06”;
}
else if (mm == “Jul”)
{
mm= “07”;
}
else if (mm == “Aug”)
{
mm= “08”;
}
else if (mm == “Sep”)
{
mm= “09”;
}
else if (mm == “Oct”)
{
mm= “10”;
}
else if (mm == “Nov”)
{
mm= “11”;
}
else if (mm == “Dec”)
{
mm= “12”;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
var date = mm+”/”+dd+”/”+yy;
var timestam_1 = Date.parse(date);
var timestam= timestam_1+86400000; //86400000 added to get correct timezone output from Date.parse
var time4 = new Date(timestam);
var Weeko = time4.getDay();
var dd2 = time4.getDate();
var mm2 = time4.getMonth();
var flag_y=arr[i][1];
var ahref_title=”Click here for full story”;
if(arr[i][2]) {
var url=arr[i][2];
var flag_date='{“x”:’+timestam+’, “title”:” “,”text”:”Click here for Story!”}’;
flagAr[csvgen_counter].push(flag_date);
}
var yy2 = time4.getFullYear();
var yy3 = yy2+””;
var yy4= yy3.substring(2,4);
//++++++++++++++++++++++++this for days conversion++++++++++++++++++++++++++++
if (Weeko==1)
{
Weeko = “Mon”;
}
else if (Weeko==2)
{
Weeko = “Tue”;
}
else if (Weeko==3)
{
Weeko = “Wed”;
}
else if (Weeko==4)
{
Weeko = “Thu”;
}
else if (Weeko==5)
{
Weeko = “Fri”;
}
else if (Weeko==6)
{
Weeko = “Sat”;
}
else if (Weeko==0)
{
Weeko = “Sun”;
}
//+++++++++++++++++++++++this is for month conversion+++++
if (mm2==0)
{
mm2 = “Jan”;
}
else if (mm2==1)
{
mm2 = “Feb”;
}
else if (mm2==2)
{
mm2 = “Mar”;
}
else if (mm2==3)
{
mm2 = “Apr”;
}
else if (mm2==4)
{
mm2 = “May”;
}
else if (mm2==5)
{
mm2 = “Jun”;
}
else if (mm2==6)
{
mm2 = “Jul”;
}
else if (mm2==7)
{
mm2 = “Aug”;
}
else if (mm2==8)
{
mm2 = “Sep”;
}
else if (mm2==9)
{
mm2 = “Oct”;
}
else if (mm2==10)
{
mm2 = “Nov”;
}
else if (mm2==11)
{
mm2 = “Dec”;
}
//++++++++++++++++++++++++++++++++++++++++
//weekly
if ( timestamvar == timestamweek)
{
fomat2=dd2+”-“+mm2+”-“+yy4;
padding_value=timestamweek;
range_selector=2;
}
// Daily
else if ( timestamvar = timestamyear)
{
fomat2=mm2+”-“+yy4;
padding_value=timestamyear;
range_selector=3;
}
//monthly
else if ((timestamvar <= timestammonth30)&&(timestamvar = timestamquarterly)
{
fomat2=mm2+”-“+yy4;
padding_value=timestamquarterly;
range_selector=3;
}
else
{
fomat2=dd2+”-“+mm2+”-“+yy4;
padding_value=timestamday;
range_selector=3;
}
arr[i][0]= fomat2;
var decpad;
decpad = parseFloat(arr[i][1]);
arr[i][1] = decpad;
if(i==(arr.length-1))
{
// Functionality to get the last value
var xvalu=dd2+”-“+mm2+”-“+yy4;
var yvalu= String(arr[i][1]);
var xyvalu=”Latest value at “+xvalu+” is “+yvalu;
updt=”Updated on “+xvalu;
}
tempAr.push(timestam);
if(!arr[i][1])
{
arr[i][1]=null;
}
yaxisAr[csvgen_counter].push(arr[i][1]);
// tempAr1.push(timestam);
// tempAr2.push(tempAr1);
tempAr.push(arr[i][1]);
last_val=timestam;
finalAr[csvgen_counter].push(tempAr);
}
xpad=last_val+padding_value; //*****************to end up graph early//////
if(arr[i]== “”)
{
vi=arr.length-i;
arr.length=arr.length-vi;
i=arr.length-1;
fomat = replic;
var k=0;
do {
k++;
} while(fomat.charAt(k)!=”-“)
var k1 =k;
do {
k++;
} while(fomat.charAt(k)!=”-“)
var k2=k;
do {
k++;
} while(k<fomat.length)
var k3=k;
var dd= fomat.substring(0,k1);
var mm = fomat.substring(k1+1,k2);
var yy = "20"+fomat.substring(k2+1,k3+1);
// conversion of months into numerical form
//+++++++++++++++++++++++++++++++++++
if (mm == "Jan")
{
mm= "01";
}
else if (mm == "Feb")
{
mm= "02";
}
else if (mm == "Mar")
{
mm= "03";
}
else if (mm == "Apr")
{
mm= "04";
}
else if (mm == "May")
{
mm= "05";
}
else if (mm == "Jun")
{
mm= "06";
}
else if (mm == "Jul")
{
mm= "07";
}
else if (mm == "Aug")
{
mm= "08";
}
else if (mm == "Sep")
{
mm= "09";
}
else if (mm == "Oct")
{
mm= "10";
}
else if (mm == "Nov")
{
mm= "11";
}
else if (mm == "Dec")
{
mm= "12";
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
var date = mm+"/"+dd+"/"+yy;
//here flagAr may be
var timestam = Date.parse(date);
var time4 = new Date(timestam);
var Weeko = time4.getDay();
var dd2 = time4.getDate();
var mm2 = time4.getMonth();
var yy2 = time4.getFullYear();
var yy3 = yy2+"";
var yy4= yy3.substring(2,4);
//++++++++++++++++++++++++this for days conversion++++++++++++++++++++++++++++
if (Weeko==1)
{
Weeko = "Mon";
}
else if (Weeko==2)
{
Weeko = "Tue";
}
else if (Weeko==3)
{
Weeko = "Wed";
}
else if (Weeko==4)
{
Weeko = "Thu";
}
else if (Weeko==5)
{
Weeko = "Fri";
}
else if (Weeko==6)
{
Weeko = "Sat";
}
else if (Weeko==0)
{
Weeko = "Sun";
}
//+++++++++++++++++++++++this is for month conversion+++++
if (mm2==0)
{
mm2 = "Jan";
}
else if (mm2==1)
{
mm2 = "Feb";
}
else if (mm2==2)
{
mm2 = "Mar";
}
else if (mm2==3)
{
mm2 = "Apr";
}
else if (mm2==4)
{
mm2 = "May";
}
else if (mm2==5)
{
mm2 = "Jun";
}
else if (mm2==6)
{
mm2 = "Jul";
}
else if (mm2==7)
{
mm2 = "Aug";
}
else if (mm2==8)
{
mm2 = "Sep";
}
else if (mm2==9)
{
mm2 = "Oct";
}
else if (mm2==10)
{
mm2 = "Nov";
}
else if (mm2==11)
{
mm2 = "Dec";
}
//++++++++++++++++++++++++++++++++++++++++
//weekly
if ( timestamvar == timestamweek)
{
fomat2=dd2+"-"+mm2+"-"+yy4;
}
// Daily
else if ( timestamvar = timestamyear)
{
fomat2=mm2+”-“+yy4;
}
//monthly
else if ((timestamvar <= timestammonth30)&&(timestamvar = timestamquarterly)
{
fomat2=mm2+”-“+yy4;
}
arr[i][0]= fomat2;
var decpad;
decpad = parseFloat(arr[i][1]);
//arr[i][1] = roundVal(decpad);
arr[i][1] = decpad;
if(i==(arr.length-1))
{
var xvalu=dd2+”-“+mm2+”-“+yy4;
var yvalu= String(arr[i][1]);
var xyvalu=”Latest value at “+xvalu+” is “+yvalu;
updt=”Updated on “+xvalu;
}
}
}
}
//other required functions
//chart configuration starts here
function getXMLHttpRequest(file) {
//var arrSignatures = [“MSXML2.XMLHTTP.5.0”, “MSXML2.XMLHTTP.4.0″,
//”MSXML2.XMLHTTP.3.0”, “MSXML2.XMLHTTP”,
//”Microsoft.XMLHTTP”];
//for (var i=0; i < arrSignatures.length; i++) {
try
{
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("POST",file,false);
return xmlhttp;
}
catch(e)
{
error=e.message;
}
//}
throw new Error("MSXML is not installed on your system.");
}
function readCSV(locfile) {
// load a whole csv file, and then split it line by line
var req = new getXMLHttpRequest(locfile);
//req.open("POST",locfile,false);
req.send("");
return req.responseText.split(/n/g);
}
function parseLineCSV(lineCSV) {
// parse csv line by line into array
var CSV = new Array();
lineCSV = lineCSV.replace(/,/g," ,");
lineCSV = lineCSV.split(/,/g);
// This is continuing of 'split' issue in IE
// remove all trailing space in each field
for (var i=0;i<lineCSV.length;i++) {
lineCSV[i] = lineCSV[i].replace(/s*$/g,"");
}
lineCSV[lineCSV.length-1]=lineCSV[lineCSV.length-1].replace(/^s*|s*$/g,"");
var fstart = -1;
for (var i=0;i=0) {
for (var j=fstart+1;j<=i;j++) {
lineCSV[fstart]=lineCSV[fstart]+","+lineCSV[j];
lineCSV[j]="-DELETED-";
}
fstart=-1;
}
}
fstart = (lineCSV[i].match(/^"/)) ? i : fstart;
}
var j=0;
for (var i=0;i<lineCSV.length;i++) {
if (lineCSV[i]!="-DELETED-") {
CSV[j] = lineCSV[i];
j++;
}
}
return CSV;
}
function roundVal(val_num){
var dec = 2;
var result = Math.round(val_num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
function setdecimalpoints(deca)
{
var deca1= deca;
var deca2= parseInt(deca);
if((deca1-deca2)!=0)
{
return 2;
}
else
{
return 0;
}
}
for(i=0;i
Charts loading…
Charts loading…
Charts loading…
Charts loading…
Charts loading…
Charts loading…
Charts loading…