/* FILE ARCHIVED ON 19:27:00 Nov 13, 2014 AND RETRIEVED FROM THE AN OPENWAYBACK INSTANCE ON 7:14:24 Sep 27, 2024. JAVASCRIPT APPENDED BY OPENWAYBACK, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ var leafHandlerLoaded = void 0; var rootHandlerLoaded = void 0; $(document).ready(function(){ /* SD 2012-03-13 The dropdowns had an onchange event * that redirected the page to selected value. If you hit * the browser back button the page went back to the original * page, except for the dropdown that stayed the same. This * was because the browser caches the form values; particularly IE. * In order to avoid caching of the form elements we shall.. * 1. remove the onchange attributes on the dropdown * 2. transfer the onchange to a JQuery onchange event * 3. When an onchange is triggered, capture the new selected value * 4. Revert the dropdowns to the original values, then * 5. redirect the page to the newly selected values. * This is an ugly solution. It could have been put in the * meta tags in the original html files. */ if($('select[name="Drop1"]').length > 0) { /* *SD 2012-03-13 The following 5 lines may not be necessary, but they do make the html valid-html. */ var dropdown = $('select[name="Drop1"]').html(); dropdown = dropdown.replace('SELECTED=""','selected="selected"'); dropdown = dropdown.replace('SELECTED','selected="selected"'); dropdown = dropdown.replace('selected=""','selected="selected"'); $('select[name="Drop1"]').html(dropdown); //Drop1 $('select[name="Drop1"]').removeAttr('onchange'); var originalSelection = $('select[name="Drop1"] option:selected').attr('value'); $('select[name="Drop1"]').change(function(){ var currentSelection = $(this).attr('value'); $('select[name="Drop1"]').find('option[value="'+originalSelection+'"]').attr('selected','selected'); window.location = currentSelection; return false; }); } //DropF if($('select[name="DropF"]').length > 0) { $('select[name="DropF"]').removeAttr('onchange'); var originalSelectionF = $('select[name="DropF"] option:selected').attr('value'); $('select[name="DropF"]').change(function(){ var currentSelectionF = $(this).attr('value'); $('select[name="DropF"]').find('option[value="'+originalSelectionF+'"]').attr('selected','selected'); window.location = currentSelectionF; return false; }); } }); (function(){ /* Generated from eia-theme.js using https://webarchive.library.unt.edu/dentonfracking/20141113192700/http://jscompress.com/ */ (function(){function F(t,n){var r=function(n,r){var i=this,s=s||{};isPie=n.chart.defaultSeriesType!=void 0&&n.chart.defaultSeriesType=="pie";j=0;ops=jQuery.extend(true,{},e.getOptions(),n);ops.xAxis=o(T(ops.xAxis||{}),function(e){return N(H,e,s.xAxis||{})});ops.yAxis=o(T(ops.yAxis||{}),function(e){opposite=e.opposite;return N(P,e,s.yAxis||{})});st(ops);U(ops);if(isPie)i=I.call(i,t,ops,r);else i=R.call(i,t,ops,r);return i};r.prototype=_(t.prototype);return r}function I(e,t,n){var r=this;r=e.call(r,t,n)||r;return r}function q(t){var n=[],r,i;if(t.yAxis instanceof Array){if(t.yAxis.length>1){for(r=0;r1&&t.userGenerated){$.extend(true,t,{chart:{logo:Highcharts.logos.none}});if(t.credits.text==e.eiaTheme.credits.text){t.credits.text=t.credits.text.replace("Source","Data source")}}if(t.yAxis.length>1&&t.yAxis.length<=4){if(t.yAxis.length>2){$.extend(true,t,{captions:{items:[{text:"Warning: Please take care in interpreting this chart. You have selected series with different units resulting in a chart with "+t.yAxis.length+" axes.",style:{color:"red"}}]}})}}else if(t.yAxis.length>4){return false}}return true}function R(t,n,r){var i=q(n);if(!i){$(n.chart.renderTo).empty().append($('
You have chosen data series resulting in more than 4 axes. Series with the same units will be plotted on the same axis. Axes will be added for each unique unit. You must select series that result in 4 or fewer axes.
'));return false}var o=this,u=n.chart.renderTo,a=typeof u=="string"?$("#"+u):$(u),f=0,l=0,c,h,p,o,d,v=$.isArray(n.yAxis)?n.yAxis:[n.yAxis],m={options:n,counters:{wrapColor:function(e){if(this.color>=e){this.color=0}},wrapSymbol:function(e){if(this.symbol>=e){this.symbol=0}},color:0,symbol:0},series:[],xAxis:[],yAxis:[]},g=$("
").appendTo("body").css({position:"absolute",top:-9999}),y=new e.Renderer(g[0],0,0);var c;if(n.xAxis instanceof Array){for(c=0;c").css({height:"auto",width:"auto"}).addClass("outerChartContainer");i=$("
").css({height:"auto",width:"auto"}).addClass("printChartContainer");n.before(r);i.appendTo(r);n.appendTo(i)}e.chart.outerContainer=r[0];e.chart.printContainer=i[0];e.chart.container=n[0]}}function z(t,n){var r=this,i=jQuery.extend(true,{},P,t),s=i.title,o=0,u=0,a,f=s.originalAlign||s.align.toLowerCase(),l=0;if(f=="above"){if(s.text==void 0||i.text==""){jQuery.extend(true,t,{align:"middle",originalAlign:"middle"})}else{a=n.text(s.text,0,0).attr({rotation:0}).css(s.style).add();var c=a.getBBox();if(s.align=="above")jQuery.extend(true,t,{title:{offset:-1*c.width+(t.opposite?20:10),rotation:0,align:"high",x:t.opposite?c.width-20:0,y:-1*c.height}});l=c.height}}jQuery.extend(true,t,{title:{originalAlign:f}});if(!t.labels||!t.labels.formatter){jQuery.extend(true,t,{labels:{formatter:function(){var t=this.value.toString(),n=/\d+\.?(\d*)/;if(n.test(t)){u=Math.max(this.value.toString().match(n)[1].length,u);if(o===void 0)o=u;if(this.isLast){if(u!=o){o=u;B=true}u=0;t=e.numberFormat(this.value,o,".",",")}else{t=e.numberFormat(this.value,o,".",",")}}return t}}})}return l}function W(e,n,r){var s=0,o,u;if(e&&e.text){e.text=e.text.replace(//gi," ");o=t.prototype.splitText(e.text,e.style,r,n);e.text=$.map(o,function(e){return e.line}).join("
");for(i=0;i1){for(i=0;i0?d+" : ":"")+e.parseXValue(p,this.point.options&&this.point.options.tooltipX!==void 0?this.point.options.tooltipX:this.x);r=s.options.compare!=null?e.numberFormat(this.point.change,a.precision||void 0)+" "+v:e.numberFormat(this.y,a.precision||void 0)+" "+v}else{i=this.point.name;n=d;r=this.y}t=(s.options.tooltip.showName?""+i+"
":"")+n+(n!=""?"
":"")+r}else{var n,r="",i,m,s,g,v,u,a,y=this.points,o=y[0].series.chart,l=o.options.chart.defaultSeriesType=="pie",c=l?false:o.options.xAxis.type=="datetime",p=o.options.maxXType,d=e.tooltipXLabels[p];if(!l){n=(d!=""?d+" : ":"")+e.parseXValue(p,this.x);t+=n+"
";for(m=0;m"+" "+r;if(m"}}else{for(m=0;m"+" "+r;if(m"}}}return t},generateEIAExportOptions:function(){var e=this,t={};return t},numberFormat:function(t,n,r,i){if(t!==null&&t!==void 0&&!isNaN(t)){var s=e.getOptions().lang,o=t,u=isNaN(n=Math.abs(n))?Math.min(o.toString().match(/\d+\.?(\d*)/)[1].length,20):n,a=r===undefined?s.decimalPoint:r,f=i===undefined?s.thousandsSep:i,l=o<0?"-":"",c=String(parseInt(o=Math.abs(+o||0).toFixed(u))),h=c.length>3?c.length%3:0;return l+(h?c.substr(0,h)+f:"")+c.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+f)+(u?a+Math.abs(o-c).toFixed(u).slice(2):"")}else return""},Chart:F(t,{}),StockChart:e.StockChart?F(n,{xAxis:{type:"dateTime"}}):void 0});r(t.prototype,{resetZoom:function(){var e=this,t=e.xAxis;s(t,function(e){e.setExtremes(null,null,false)})},resetSeries:function(e){var t=this,n,r,i=[];if(e===void 0)e=true;t.removeAllSeries(e);for(n=0;n]*>.*?<\s*\/\2\s*>|<\s*\/[^>]+>|[^<>\s]+|(<[^>]+>))/g;words=e.match(g).concat("");while(a/)){words.splice(a-1,1);break}m=c.getBBox().width}while(m\s+/g,">");o=a-1}i.push({line:d,lineHeight:h});c.destroy();c=null}return i}});t.prototype.callbacks.push(function(){var e=this.setTitle;this.adjustTitleAlignment(true,true);this.setTitle=function(t,n){e.call(this,t,n);if(t)this.options.title=N(this.options.title,t);if(n)this.options.subtitle=N(this.options.subtitle,n);this.adjustTitleAlignment(t,n)}});r(u.prototype,{getOffset:function(){var e=this,t=e.chart,n=t.renderer,r=e.options,i=e.tickPositions,o=e.ticks,u=e.horiz,h=e.side,p=t.inverted?[1,0,3,2][h]:h,v,g,y=0,b,w=0,E=r.title,S=r.labels,T=0,N=t.axisOffset,C=t.clipOffset,k=[-1,1,1,-1][h],L,A,O=1,M=a(S.maxStaggerLines,5),_,D,P,H,B,j,F,I;e.hasData=v=e.hasVisibleSeries||x(e.min)&&x(e.max)&&!!i;e.showAxis=g=v||a(r.showEmpty,true);e.staggerLines=e.horiz&&S.staggerLines;if(!e.axisGroup){e.gridGroup=n.g("grid").attr({zIndex:r.gridZIndex||1}).add();e.axisGroup=n.g("axis").attr({zIndex:r.zIndex||2}).add();e.labelGroup=n.g("axis-labels").attr({zIndex:S.zIndex||7}).addClass(f+e.coll.toLowerCase()+"-labels").add()}if(v||e.isLinked){e.labelAlign=a(S.align||e.autoLabelAlign(S.rotation));s(i,function(t){if(!o[t]){o[t]=new l(e,t)}else{o[t].addLabel()}});if(e.horiz&&!e.staggerLines&&M&&!S.rotation){_=e.reversed?[].concat(i).reverse():i;while(O1){e.staggerLines=O}}s(i,function(t){if(h===0||h===2||{1:"left",3:"right"}[h]===e.labelAlign){T=m(o[t].getLabelSize(),T)}});if(e.staggerLines){T*=e.staggerLines;e.labelOffset=T}}else{for(L in o){o[L].destroy();delete o[L]}}if(E&&E.text&&E.enabled!==false){if(!e.axisTitle){e.axisTitle=n.text(E.text,0,0,E.useHTML).attr({zIndex:7,rotation:E.rotation||0,align:E.textAlign||{low:"left",middle:"center",high:"right"}[E.align]}).addClass(f+this.coll.toLowerCase()+"-title").css(E.style).add(e.axisGroup);e.axisTitle.isNew=true}if(g){y=e.axisTitle.getBBox()[u?"height":"width"];w=a(E.margin,u?5:10);b=E.offset}e.axisTitle[g?"show":"hide"]()}e.offset=k*a(r.offset,N[h]);e.axisTitleMargin=a(isNaN(b)?b:b+T+w,T+w+(h!==2&&T&&k*r.labels[u?"y":"x"]));N[h]=m(N[h],e.axisTitleMargin+y+k*e.offset);C[p]=m(C[p],d(r.lineWidth/2)*2)}});P=e.eiaTheme.yAxis;H=e.eiaTheme.xAxis;e.setOptions(e.eiaTheme);var tt=.15,nt=tt*138,rt=tt*188,it=5;reuters_logoURL="https://webarchive.library.unt.edu/dentonfracking/20141113192700/http://www.eia.gov/global/images/logos/Thomson_Reuters_logo.png";reuters_logoHeight=30,reuters_logoWidth=135,reuters_logoPadding=5;t.prototype.callbacks.push(ot);e.setOptions($.extend(true,e.eiaTheme,{exporting:{csvOptions:{overrideURL:null,postURL:"/global/scripts/jquery/highcharts/exporting-server/csv_exporter.cfm"}}}));r(t.prototype,{generateCSV:function(){function t(e){if(!F.hasOwnProperty(e)){if(P){for(d=H.length-1;d>=0;d--)if(e/g,f=/[\?%\*:\|"\<\>\\,]/g,l=/\//g,c=/\s+/g,h,p,d,v,m,g,y,b,w,E,S,x,N,C,k,L,A,O,M=T(n.options.xAxis)[0],_,D=true,P=false,H=[],B={},j={},F={},I=false,q=false,R="chartData";if(i)return window.location=i;try{if(n.options.title.text!==void 0&&n.options.title.text.length>0)R=n.options.title.text.replace(a," ").replace(f,"").replace(l," per ").replace(c," ");if(n.options.subtitle.text!==void 0&&n.options.subtitle.text.length>0)R+=" ("+n.options.subtitle.text.replace(a," ").replace(f,"").replace(l," per ").replace(c," ")+")"}catch(U){}try{P=M.type=="datetime"}catch(U){}try{if(M.title.text!==void 0&&M.title.text.length>0)b=M.title.text}catch(U){}for(h=0;h=0;d--)if(v=0;d--)if(v').val(JSON.stringify(S));L=$('').val(R.replace(/\s+/g,"_"));jQuery('
').append(k).append(L).appendTo("body").submit().remove()}});r(t.prototype,{addButton:function(e){var t=this,n=t.renderer,i=N(t.options.navigation.buttonOptions,e),s=i.onclick,o=i.menuItems,u,a,f={stroke:i.symbolStroke,fill:i.symbolFill},l=i.symbolSize||12,c;if(!t.btnCount){t.btnCount=0}c=t.btnCount++;if(!t.exportDivElements){t.exportDivElements=[];t.exportSVGElements=[]}if(i.enabled===false){return}if(!t.buttonGroup){t.buttonGroup=n.g("buttonGroup").add();t.exportSVGElements.push(t.buttonGroup)}var h=i.theme,p=h.states,d=p&&p.hover,v=p&&p.select,m;delete h.states;if(s){m=function(){s.apply(t,arguments)}}else if(o){m=function(){t.contextMenu("contextmenu",o,a.translateX,a.translateY,a.width,a.height,a);a.setState(2)}}if(i.text&&i.symbol){h.paddingLeft=Highcharts.pick(h.paddingLeft,25)}else if(!i.text){r(h,{width:i.width,height:i.height,padding:0})}a=n.button(i.text,0,0,m,h,d,v).attr({title:t.options.lang[i._titleKey],"stroke-linecap":"round"});if(i.symbol){u=n.symbol(i.symbol,i.symbolX-l/2,i.symbolY-l/2,l,l).attr(r(f,{"stroke-width":i.symbolStrokeWidth||1,zIndex:1})).add(a)}a.add().align(r(i,{width:a.width,x:j}),true,"spacingBox");j+=(a.width+i.buttonSpacing)*(i.align==="right"?-1:1);t.exportSVGElements.push(a,u)}})})() if(/\/hist\//.test(window.location.pathname)){ /** * The Petroleum Navigator leaf page charting function **/ var leafHandler = function($){ return function(){ // Is this the Natural Gas Navigator? var isNG; //min must not be zero if negative values negativeValues = false; // An array of months for performing lookups var monthsArray = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; // Returns the Chart Title and Units as an array var getTitleMatch = function(){ //var titleRegex = /[^\(\)]+/g; var title = $('.Title1').html(); //return title.match(titleRegex); <- this didn't work as some series name have parenthical phrases var aTitle = [title.substring(0,title.lastIndexOf('(')-1), title.substring(title.lastIndexOf('(')+1,title.lastIndexOf(')')) ]; return aTitle; } // Returns the table rows in a page for iteration var getTableRows = function(){ if(isNG) return $('body > table:eq(2) tr'); else return $('table.FloatTitle tr'); } // Trims null values from the beginning and end of data // arrays var trimNulls = function(data){ var i; var dataCopy = data.slice(0); for(i=data.length - 1; i>0; i--){ if(data[i][1] === null) dataCopy.pop(); else break; } for(i=0; i -1)console.info(JSON.stringify(ret)); return ret; } //Indicates whether this is a Reutures series var isReuters = function(){ var tr_series = ['RWTC','RBRTE','EER_EPMRU_PF4_Y35NY_DPG','EER_EPMRU_PF4_RGC_DPG','EER_EPMRR_PF4_Y05LA_DPG','EER_EPD2F_PF4_Y35NY_DPG','EER_EPJK_PF4_RGC_DPG','EER_EPLLPA_PF4_Y44MB_DPG']; var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i').width('100%').appendTo(imageParent); // Make the chart 100% width chartTable.width('100%'); // Hide the chart during processing chartParent.children().hide(); return chartParent; } // This is the function that creates the chart object. // Executes immediately i.e.: function(args){/*do*/}(args); var createLeafChart = function(){ isNG = window.location.pathname.match(/\/ng\//) !== null; var chartParent = prepareChartParent(); var titleMatch = getTitleMatch(); var data = processData(); leafChart = new Highcharts.Chart( createOptions( chartParent.get(0), titleMatch[0], titleMatch[1], data ) ); }(); } }(jQuery); /** * Created by Shivan Computers Corporation on behalf of the * U.S. Energy Information Administration: * Author : Ryan Lynch (Ryan.Lynch@eia.gov) * * EIA Analyis Module: * * This module extend the EIA Theme to add various analytical * functions to the chart, along with a set of controls to * activate them. * * Depends on: highcharts.js, eia-theme.js **/ (function(){ // Shortcuts var HC = Highcharts, Chart = HC.Chart; each = HC.each, extend = HC.extend, map = HC.map, eiaTheme = HC.eiaTheme, seasonalPalletAlpha = 0.3; // Default Analysis Options HC.setOptions(extend(eiaTheme, { analysis: { enableMovingAverage:true, enableSeasonalAnalysis:true } })); function seasonalPalletConverter(h){ return 'rgba(' + parseInt(h.substring(1,3), 16) + ',' + parseInt(h.substring(3,5), 16) + ',' + parseInt(h.substring(5), 16) + ',' + seasonalPalletAlpha + ')'; } // Colors for seasonal analysis extend(HC, { eia_seasonal_pallet : map(eiaTheme.colors.slice(1), seasonalPalletConverter) }); ////////////////////////// // Analytical Functions // ////////////////////////// extend(Chart.prototype,{ addMovingAverage : function(index, duration){ var chart = this, baseSeries = chart.series[index], interval = baseSeries.options.xType, baseXData = baseSeries.xData, baseYData = baseSeries.yData, avgData = [], helperArray = [], dayInterval, durationTitle, avg = total = i = j = calcDuration = 0; // If we are dealing with a series that has been destroyed, then // return if(!baseXData) return; // else switch(interval){ case HC.xTypes.Annual: case HC.xTypes.Quarterly: case HC.xTypes.Monthly: return; break; case HC.xTypes.weekly: durationTitle = duration + ' Week'; dayInterval = 7 * 24 * 60 * 60 * 1000; break; case HC.xTypes.daily: durationTitle = duration + ' Day'; dayInterval = 1 * 24 * 60 * 60 * 1000; break; } for(i = duration; helperArray.length == 0; i++){ for(j = i - duration; j < i; j++){ if( baseYData[j] != null && baseXData[j] >= baseXData[i] - dayInterval * duration ){ total += baseYData[j]; helperArray.push({ x : baseXData[j], y : baseYData[j] }); } } } avgData.push([baseXData[i], total/helperArray.length]); for(i = duration + 1; i < baseXData.length; i++){ if( helperArray[0].x <= baseXData[i] - dayInterval * duration ){ total -= helperArray[0].y; helperArray.shift(); } j = i - 1 if( baseYData[j] != null && baseXData[j] >= baseXData[i] - dayInterval * duration ){ total += baseYData[j]; helperArray.push({ x : baseXData[j], y : baseYData[j] }); } avgData.push([baseXData[i], total / helperArray.length]); } //chart.legend.enabled = true; return chart.addSeries({ //name : baseSeries.name + durationTitle + ' Moving Average', name : durationTitle + ' Moving Average', data : avgData }); }, createSeasonalAnalysis : function(index, interval){ var chart = this, baseSeries = chart.series[index], yearOffset, baseXData = baseSeries.xData, baseYData = baseSeries.yData, i = j = 0, series = [], seriesData, xType = baseSeries.options.xType, serie, startDate, currentDate, firstDate, originalStartDate, lastDate, dateString; if(!baseXData) return; j = baseXData.length - 1; startDate = originalStartDate = new Date(baseXData[j]); for(i = 0; i <= interval && j > 0; i++){ endDate = new Date( startDate.getUTCFullYear() - 1, startDate.getUTCMonth(), startDate.getUTCDate() ) seriesData = []; lastDate = new Date(baseXData[j]); while( j >= 0 && (!currentDate || currentDate.getTime() >= endDate.getTime()) ){ currentDate = new Date(baseXData[j]); seriesData.push({ x: Date.UTC( currentDate.getUTCFullYear() + i, currentDate.getUTCMonth(), currentDate.getUTCDate()), tooltipX : currentDate.getTime(), y: baseYData[j] }); firstDate = currentDate; j--; } j++; switch(xType){ case HC.xTypes.daily: dateString = HC.dateFormat('%m/%d/%Y', firstDate.getTime()) + ' to ' + HC.dateFormat('%m/%d/%Y', lastDate.getTime()); break; case HC.xTypes.weekly: dateString = HC.dateFormat('%m/%d/%Y', firstDate.getTime()) + ' to ' + HC.dateFormat('%m/%d/%Y', lastDate.getTime()); break; case HC.xTypes.monthly: dateString = HC.dateFormat('%m/%Y', firstDate.getTime()) + ' to ' + HC.dateFormat('%m/%Y', lastDate.getTime()); break; } serie = { //name:baseSeries.options.name + ' ' + dateString, name: dateString, data:seriesData, legendIndex:i }; if(i > 0) serie.color = HC.eia_seasonal_pallet[i-1]; series.push(serie); startDate = endDate; } chart.removeAllSeries(false); for(j=series.length - 1; j>=0; j--){ chart.addSeries(series[j], false); } chart.resetZoom(); chart.redraw(); } }); function createSeasonalAnalysisOptions(s, index){ var chart = this, xType = s.options.xType; if(s.type == 'line' && xType != HC.xTypes.category){ var link, durations, maxInterval; if(xType > HC.xTypes.annual){ maxInterval = (s.data[s.data.length - 1].x - s.data[0].x) / 31536E6 /*365 days*/; // Add moving averages each([5, 10], function(interval){ if(interval < maxInterval){ //option = $('').html(s.name + ': ' + interval + ' Year Seasonal Analysis') option = $('').html(interval + ' Year Seasonal Analysis') .data({ method:chart.createSeasonalAnalysis, arguments:[index, interval] }); option.appendTo(chart.options.chart.analysisSelect); } }); } } } function createMovingAverageOptions(s, index){ var chart = this, xType = s.options.xType; if(s.type == 'line' && xType != HC.xTypes.category){ var link, durations, maxDuration = s.data.length; if(xType == HC.xTypes.daily){ // Add moving averages each([30, 60, 90], function(duration){ if(duration < maxDuration){ //option = $('').html(s.name + ': ' + duration + ' Day Moving Average ') option = $('').html(duration + ' Day Moving Average ') .data({ method:chart.addMovingAverage, arguments:[index, duration] }); option.appendTo(chart.options.chart.analysisSelect); } }); } if(xType == HC.xTypes.weekly){ each([4, 8, 12], function(duration){ if(duration < maxDuration){ //option = $('').html(s.name + ': ' + duration + ' Week Moving Average ') option = $('').html(duration + ' Week Moving Average ') .data({ method:chart.addMovingAverage, arguments:[index, duration] }); option.appendTo(chart.options.chart.analysisSelect); } }); } } } function processAnalysis(){ var chart = this, ops = chart.options, container = $(chart.options.chart.container), outerContainer = $(chart.options.chart.outerContainer); analysisContainer = $('
').css({ height:'auto', width:'auto', // We set the margin and padding on the // captions container to match the chart // container so that the links are // lined up correctly marginLeft:container.css('marginLeft'), marginRight:container.css('marginRight') /*paddingLeft:container.css('paddingLeft'), paddingRight:container.css('paddingRight')*/ }).addClass('chartAnalysisContainer').append('Chart Tools'), analysisSelect = $(''), analysisTable = $('
'); // Enable or disable analysis based on maxXType switch(ops.maxXType){ case HC.xTypes.annual: ops.analysis.enableMovingAverage &= false; ops.analysis.enableSeasonalAnalysis &= false; break; case HC.xTypes.monthly: ops.analysis.enableMovingAverage &= false; ops.analysis.enableSeasonalAnalysis &= true; break; case HC.xTypes.weekly: ops.analysis.enableMovingAverage &= true; ops.analysis.enableSeasonalAnalysis &= true; break; case HC.xTypes.daily: ops.analysis.enableMovingAverage &= true; ops.analysis.enableSeasonalAnalysis &= true; break; default: ops.analysis.enableMovingAverage &= false; ops.analysis.enableSeasonalAnalysis &= false; break; } if(( ops.analysis.enableMovingAverage || ops.analysis.enableSeasonalAnalysis ) && !ops.chart.analysisContainer){ analysisContainer.appendTo(outerContainer); analysisTable.append( $('').append( $('').append(analysisSelect) ) ).appendTo(analysisContainer); ops.chart.analysisContainer = analysisContainer[0]; ops.chart.analysisSelect = analysisSelect[0]; // Create Analytical function links resetButton = $('').html('Reset').click(function(){ chart.resetSeries(true); }); applyButton = $('').html('Apply').click(function(){ var select = chart.options.chart.analysisSelect, option = select.options[select.selectedIndex], optionData = $(option).data(); chart.resetSeries(false); optionData.method.apply(chart, optionData.arguments); }); if( ops.analysis.enableMovingAverage || ops.analysis.enableSeasonalAnalysis ){ for(i in chart.series){ s = chart.series[i]; if(ops.analysis.enableMovingAverage) createMovingAverageOptions.call(chart, s, i); if(ops.analysis.enableSeasonalAnalysis) createSeasonalAnalysisOptions.call(chart, s, i); } if(analysisSelect.children().length > 0){ analysisSelect.change(function(){ if(analysisSelect.children(':selected').get(0).index ==0){ chart.resetSeries(true); } else { var select = chart.options.chart.analysisSelect, option = select.options[select.selectedIndex], optionData = $(option).data(); chart.resetSeries(false); optionData.method.apply(chart, optionData.arguments); } }); /*analysisTable.find('td') .append(applyButton) .append(resetButton);*/ /*$('').appendTo(analysisTable) .append( $('') .append(applyButton) .append(resetButton) );*/ } else analysisContainer.remove(); } } } Chart.prototype.callbacks.push(processAnalysis); }()); leafHandlerLoaded = true; $(leafHandler); } else{ var rootHandler = function($){ function trimNulls(data){ var i; var dataCopy = data.slice(0); for(i=data.length - 1; i>0; i--){ if(data[i][1] === null) dataCopy.pop(); else break; } for(i=0; i') .attr('id', 'hc_container') .css({ height : '600px', width : '800px', backgroundImage : 'url(/global/scripts/jQuery/tabs/loading.gif)', backgroundPosition : 'center', backgroundRepeat : 'no-repeat' }) .appendTo(cont), link = $('') .attr('href', '#hc_container') .attr('id', 'hc_link') .attr('title', 'Click and drag to zoom chart. Use the buttons in upper right of chart for high quality print-outs and downloads.') .appendTo(cont) .fancybox({ titlePosition : 'inside', titleFormat : function(title){ return '' + title + ''; }, autoResize : false // To sidestep issue with Highcharts in Fancybox 2 disappearing when the browser is resized -SNW }); }; function addButtons(){ // Clone the first th element and put the buttons in it var th = $('table.data1 > tbody > tr:eq(1) > th:eq(0)'); th = th.clone().empty().insertAfter(th); gbtn = $('').text('Graph').css('font-size', '90%').click(createChart); cbtn = $('').text('Clear').css('font-size', '90%').click(clearCheckboxes); gbtn.appendTo(th); cbtn.appendTo(th); }; function addCheckboxes(){ var buttonsAdded = false, processRows = $('tr.DataRow td.DataHist a').length > 0; if(processRows){ $('tr.DataRow').each( function(index, tr){ var cbtd, cb, td, tokens, a, href; // JQueryify the tr element tr = $(tr); // Get the second td cbtd = tr.children(':eq(1)'); // Clone it cbtd = cbtd.clone().insertBefore(cbtd) .css('text-align', 'center'); // Find the history td td = tr.find('td.DataHist'); if(td && (a = td.children('a')).length > 0){ if(!buttonsAdded){ addButtons(); buttonsAdded = true; } // Get the sourcekey and frequency from the link // We use the html href instead of the jQuery attr('href') // to retrieve an absolute instead of relative link href = a.get(0).href; // Petroleum Navigator tokens = href.match(/s=(.*?)&f=(\w)/); // Natural Gas Navigator if(!tokens) tokens = href.match(/([^\/]*?)([WwMmDd4Aa]).(htm|html)/); // put the checkbox into the checkbox td cbtd.empty(); cb = $('') .addClass('chartCheckBox') .appendTo(cbtd) // Store the source key and frequency .data({ srcKey : tokens[1].toUpperCase(), freq : tokens[2].toUpperCase(), link : href }); } } ); } }; function createChart(){ var srcKeys = [], srcLinks = {}, srcKey, freq; $('.chartCheckBox:checked').each(function(){ var cb = $(this); srcKey = cb.data('srcKey') srcKeys.push(srcKey); srcLinks[srcKey] = cb.data('link') freq = cb.data('freq'); }); if(srcKeys.length > 0){ $('#hc_container').empty(); $('#hc_link').click(); $.ajax({ type:'POST', url: '/petroleum/get_series2.cfm', dataType: 'json', data: { srcKeys : srcKeys.join(','), freq : freq }, success: function(result){ var keys = result.KEYS, axis = result.AXIS, baseAtZero = result.BASEATZERO, axisOpts = [], seriesOpts = [], units = [], seriesInfo; for(unit in axis){ units.push(unit); axisOpts.push({ title : { text : axis[unit] }, min : baseAtZero ? 0 : null, plotLines : [ Highcharts.eia_zero_axis_line ], opposite : axisOpts.length % 2 }) } var source_logo = Highcharts.logos.eia; for(key in keys){ seriesInfo = keys[key]; if(seriesInfo.SOURCE=="Thomson Reuters") source_logo = Highcharts.logos.reuters; seriesOpts.push({ name : seriesInfo.NAME + (axisOpts.length > 1 ? ' (' + keys[key].UNITSABBREV + ')' : ''), sourceKey : seriesInfo.KEY, sourceLink : srcLinks[key], data : trimNulls(Highcharts.map(seriesInfo.DATA, function(item, index){ var ds = String(item[0]), val = Number(item[1]), y = Number(ds.substring(0, 4)), m = Number(ds.substring(4, 6)) - 1; // Annual data has zero for the month m = m >= 0 ? m : 0; d = Number(ds.substring(6)); // Monthly / Annual data has a zero for the day d = d != 0 ? d : 1; return[Date.UTC(y, m, d), !isNaN(val) ? val : null]; })), yAxis : $.inArray(seriesInfo.UNITSABBREV.toUpperCase(), units) }); } chartOpts = { chart : { renderTo: 'hc_container', lineUpYAxisZeros : true, logo : seriesOpts.length > 1 ? Highcharts.logos.none : source_logo }, title : { text : $('.TopLabel2').text() }, xAxis : { type : 'datetime' }, yAxis : axisOpts, series : seriesOpts } var chart = new Highcharts.Chart(chartOpts); } }); } }; function clearCheckboxes(){ $('.chartCheckBox:checked').each(function(){ $(this).attr('checked', false); }); }; return function(){ addChartElements(); addCheckboxes(); }; }(jQuery); rootHandlerLoaded = true; $(rootHandler); } }());