Permalink
Browse files

commit before trying to bundle update to latest rails

  • Loading branch information...
bentut committed Jan 19, 2013
1 parent d42fcc7 commit f7a61fa803ab01fd6862392d67244cf7604988fd
View
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.9'
+gem 'rails', '3.0.19'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -0,0 +1 @@
+<h1>Prognoz Export</h1>
@@ -0,0 +1,194 @@
+
+ <script type="text/javascript" src="/javascripts/d3.v2.js"></script>
+ <script type="text/javascript" src="/javascripts/dat.gui.min.js"></script>
+
+
+
+<h1><%= @series.name %></h1>
+<div id= "chart_div">
+ <svg></svg>
+</div>
+
+<script type="text/javascript">
+
+var gui = new dat.GUI();
+
+var dat_gui_ranges = {
+ w : [0, 800],
+ h : [0, 1200],
+ udaman_width :[0,20],
+ aremos_width :[0,20],
+
+}
+
+//put all hard coded values in this object
+var params = {
+ scale: 1.7,
+ w: 555,
+ h: 280,
+ t_margin: 20,
+ r_margin: 20,
+ b_margin: 85,
+ l_margin: 50,
+
+ // bar_width: 50,
+ tick_length: 7,
+
+ x_axis_color: "gray",
+ x_axis_fontcolor: "gray",
+ x_axis_fontsize: 10,
+ x_axis_font_rotation: 320,
+
+ y_axis_color: "gray",
+ y_axis_fontcolor: "gray",
+ y_axis_fontsize: 10,
+
+ udaman_color: "#227893",
+ aremos_color: "#D84506",
+ aremos_width:1.5,
+ udaman_width:1.5,
+ // fill_opacity: 0.2,
+ // point_size :2.5,
+ //just to store for redraw
+ viz_data: [],
+};
+
+function left_boundary() { return params.l_margin; }
+function right_boundary() { return params.w * params.scale - params.r_margin; }
+function top_boundary() { return params.t_margin; }
+function bottom_boundary() { return params.h * params.scale - params.b_margin; }
+
+
+function init_viz_element(svg, elem_with_class, data) {
+ var elem_parts = elem_with_class.split(".");
+ var elem = elem_parts[0];
+ var elem_class = elem_parts[1];
+
+ var viz_element = svg.selectAll(elem_with_class).data(data);
+ viz_element.enter().append(elem).attr("class", elem_class);
+ viz_element.exit().remove();
+
+ return viz_element;
+}
+
+function draw() {
+ var data = [
+ <% @comp.sort.each do |date_string, val| %>
+ {date: "<%=date_string %>", aremos: <%= val[:aremos].nil? ? "null" : val[:aremos] %>, udaman: <%= val[:udaman].nil? ? "null" : val[:udaman] %>},
+ <%end%>
+ ]
+ //store things for next draw iteration
+ params.viz_data = data;
+
+ var max_y_val = d3.max(data, function(row) {return row.aremos > row.udaman ? row.aremos : row.udaman });// 30000; // replace with actual value from data
+ var min_y_val = d3.min(data, function(row) {return row.aremos < row.udaman ? row.aremos : row.udaman });// 30000; // replace with actual value from data
+
+ //preparing SVG Area
+ var svg = d3.selectAll("svg");
+ svg.
+ attr("height", function(d,i) {return params.h * params.scale}).
+ attr("width", function(d) {return params.w * params.scale}).
+ attr("fill", 'green')
+ .data([data]);
+
+ var headers = data.map(function(elem) { return elem.date });
+ //var categories = headers.slice(1); //alert(categories.toSource());
+ var first_year = d3.min(data, function(row) {return row[headers[0]]});
+ var last_year = d3.max(data, function(row) {return row[headers[0]]});
+
+ var x = d3.scale.ordinal().domain(headers).rangePoints([left_boundary(), right_boundary() ]);
+ var y = d3.scale.linear().domain([min_y_val, max_y_val]).range([bottom_boundary(), top_boundary() ]);
+
+
+ var line = init_viz_element(svg, "path.line_aremos", function(d) { return [d]; })
+ .attr("d", d3.svg.line()
+ .x(function(d) { return x(d.date); })
+ .y(function(d) { return d.aremos === null ? y(min_y_val) : y(d.aremos); })
+ )
+ .attr("stroke", params.aremos_color)
+ .attr("fill", "none")
+ .attr("stroke-dasharray", "10,5")
+ .attr("stroke-width", params.aremos_width);
+
+ var line = init_viz_element(svg, "path.line_udaman", function(d) { return [d]; })
+ .attr("d", d3.svg.line()
+ .x(function(d) { return x(d.date); })
+ .y(function(d) { return d.udaman === null ? y(min_y_val) : y(d.udaman); })
+ )
+ .attr("stroke", params.udaman_color)
+ .attr("stroke-width",params.udaman_width)
+ .attr("fill", "none");
+
+
+ //------ x Axis -------------------------------------------------------------------
+ var xaxis = init_viz_element(svg, "line.xaxis", ["dummy_data"])
+ .attr("y1", bottom_boundary())
+ .attr("y2", bottom_boundary())
+ .attr("x1", function(d) {return left_boundary()})
+ .attr("x2", function(d) {return right_boundary()})
+ .attr("stroke", params.x_axis_color);
+
+ var xticks = init_viz_element(svg, "line.xtick", headers)
+ .attr("y1", bottom_boundary())
+ .attr("y2", bottom_boundary() + params.tick_length )
+ .attr("x1", function(d) {return x(d)})
+ .attr("x2", function(d) {return x(d)})
+ .attr("stroke", params.x_axis_color);
+
+ var xtick_labels = init_viz_element(svg, "text.xtick_label", headers)
+ .attr("x", function(d) { return x(d)})
+ .attr("y", bottom_boundary())
+ .attr("fill", params.x_axis_fontcolor)
+ .attr("font-size", params.x_axis_fontsize+"px")
+ .attr("transform", function(d) {return "rotate("+params.x_axis_font_rotation +" "+ (x(d)+params.tick_length*4).toString() + "," + bottom_boundary() + ")"; })
+ .attr("text-anchor", "end")
+ .text(function(d) {return d; });
+
+ //------ x Axis End -------------------------------------------------------------------
+
+
+ //------ y Axis -------------------------------------------------------------------
+ var yaxis = init_viz_element(svg, "line.yaxis", ["dummy_data"])
+ .attr("x1", left_boundary())
+ .attr("x2", left_boundary())
+ .attr("y1", function(d) {return top_boundary()})
+ .attr("y2", function(d) {return bottom_boundary()})
+ .attr("stroke", params.y_axis_color);
+
+ var yticks = init_viz_element(svg, "line.ytick", y.ticks(10))
+ .attr("y1", function(d) {return y(d)})
+ .attr("y2", function(d) {return y(d)})
+ .attr("x1", left_boundary() - params.tick_length)
+ .attr("x2", left_boundary() )
+ .attr("stroke", params.y_axis_color);
+
+ var ytick_labels = init_viz_element(svg, "text.ytick_label", y.ticks(10))
+ .attr("y", function(d) { return y(d) + (params.y_axis_fontsize / 3.5)})
+ .attr("x", left_boundary() - params.tick_length * 1.5)
+ .attr("fill", params.y_axis_fontcolor)
+ .attr("font-size", params.y_axis_fontsize+"px")
+ .attr("text-anchor", "end")
+ .text(function(d) {return d; });
+
+ //------ y Axis End -------------------------------------------------------------------
+
+}
+
+
+//all dat.gui changes should trigger a redraw
+// generate the dat.gui control for any numerical ranges
+d3.entries(dat_gui_ranges).forEach(function(elem) {
+ var attr = elem.key;
+ var range = elem.value;
+ gui.add(params, attr, range[0], range[1]).onChange(draw);
+} );
+
+gui.addColor(params, 'udaman_color').onChange(draw);
+gui.addColor(params, 'aremos_color').onChange(draw);
+
+//add color or custom controls here
+
+draw();
+</script>
+
+
View
@@ -78,19 +78,19 @@
rake "us_upd_m"
end
-every 1.day, :at => "#{bls_hour}:45 am" do
+every 1.day, :at => "#{bls_hour.to_i+1}:15 am" do
rake "bls_cpi_upd_m"
rake "bls_job_upd_m"
rake "bls_cpi_upd_s"
rake "hiwi_upd"
end
-every 1.day, :at => "#{bls_hour.to_i+1}:00 am" do
+every 1.day, :at => "#{bls_hour.to_i+1}:30 am" do
rake "bls_identities"
rake "bea_identities"
end
-every 1.day, :at => "#{bls_hour.to_i+1}:15 am" do
+every 1.day, :at => "#{bls_hour.to_i+1}:45 am" do
rake "write_ur_dash"
end
@@ -36,6 +36,7 @@ def get_last_complete_4th_quarter_datestring
def get_last_incomplete_year
last_date = self.data.keys.sort[-1]
+ # BT 2013-01-09 Taking out temporarily. Will see if anything else breaks
if last_date[5..6] == "12"
new_series_data = {}
return new_transformation("No Data since no incomplete year", new_series_data)
@@ -63,4 +64,10 @@ def compressed_date_range_data(compressed_date_array = Date.compressed_date_rang
compressed_date_array.each { |date| compressed_date_range_data[date] = data[date] }
compressed_date_range_data
end
+
+ def get_data_for_month(month_num)
+ return {} if month_num > 12 or month_num < 1
+ month_prefix = ["01","02","03","04","05","06","07","08","09","10","11","12"][month_num-1]
+ data.reject {|date_string, value| date_string[5..6] != month_prefix}
+ end
end
@@ -4690,7 +4690,7 @@ task :run_aggregations2 => :environment do
"TRCVNS@HAW.Q".ts_eval=%Q|"TRCVNS@HAW.M".ts.aggregate(:quarter, :average)|
"TRCVNS@KAU.Q".ts_eval=%Q|"TRCVNS@KAU.M".ts.aggregate(:quarter, :average)|
"TRCVNS@MAU.Q".ts_eval=%Q|"TRCVNS@MAU.M".ts.aggregate(:quarter, :average)|
- "TRIHNS@HAW.Q".ts_eval=%Q|"TRIHNS@HAW.M".ts.aggregate(:quarter, :average)|
+
"TRISNS@HAW.Q".ts_eval=%Q|"TRISNS@HAW.M".ts.aggregate(:quarter, :average)|
"TRISNS@KAU.Q".ts_eval=%Q|"TRISNS@KAU.M".ts.aggregate(:quarter, :average)|
"TRISNS@MAU.Q".ts_eval=%Q|"TRISNS@MAU.M".ts.aggregate(:quarter, :average)|
View
@@ -251,7 +251,7 @@ task :tour_seats_upd=>:environment do
p = Packager.new
p.add_definitions tour_seats
- p.write_definitions_to "/Volumes/UHEROwork/data/tour/update/tour_seats_upd_NEW.xls"
+ p.write_definitions_to "/Volumes/UHEROwork/data/tour/update/seats_NEW.xls"
CSV.open("public/rake_time.csv", "a") {|csv| csv << ["tour_seats_upd", "%.2f" % (Time.now - t) , t.to_s, Time.now.to_s] }
end
@@ -662,11 +662,11 @@ task :tour_upd=>:environment do
"VSOTSCHNS@MAU.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Other:1:90", :col=>8, :frequency=>"M" })/1000|,
"VSOTSCHNS@HAW.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Other:1:90", :col=>11, :frequency=>"M" })/1000|,
"VSOTSCHNS@KAU.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Other:1:90", :col=>17, :frequency=>"M" })/1000|,
-"VSITCHTNS@HI.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:50", :col=>2, :frequency=>"M" })/1000|,
-"VSITCHTNS@HON.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:50", :col=>5, :frequency=>"M" })/1000|,
-"VSITCHTNS@MAU.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:50", :col=>8, :frequency=>"M" })/1000|,
-"VSITCHTNS@HAW.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:50", :col=>11, :frequency=>"M" })/1000|,
-"VSITCHTNS@KAU.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:50", :col=>17, :frequency=>"M" })/1000|,
+"VSITCHTNS@HI.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:60", :col=>2, :frequency=>"M" })/1000|,
+"VSITCHTNS@HON.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:60", :col=>5, :frequency=>"M" })/1000|,
+"VSITCHTNS@MAU.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:60", :col=>8, :frequency=>"M" })/1000|,
+"VSITCHTNS@HAW.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:60", :col=>11, :frequency=>"M" })/1000|,
+"VSITCHTNS@KAU.M"=>%Q|Series.load_from_download( "TOUR_%b%y@hawaiitourismauthority.org", { :file_type=>"xls", :start_date=>"2011-08-01", :sheet=>"sheet_num:10", :row=>"header_range:col:1:Charter Seats:40:60", :col=>17, :frequency=>"M" })/1000|,
"VDAYDMNS@HON.M"=>%Q|Series.load_from_file("/Volumes/UHEROwork/data/rawdata/TOUR_CYFENG%y.xls", {:file_type=>"xls", :start_date=>"2011-01-01", :sheet=>"sheet_num:1", :row=>4, :col=>"repeat:2:13", :frequency=>"M" })/1000|,
"VDAYDMNS@KAU.M"=>%Q|Series.load_from_file("/Volumes/UHEROwork/data/rawdata/TOUR_CYFENG%y.xls", {:file_type=>"xls", :start_date=>"2011-01-01", :sheet=>"sheet_num:1", :row=>5, :col=>"repeat:2:13", :frequency=>"M" })/1000|,
"VDAYDMNS@MAUI.M"=>%Q|Series.load_from_file("/Volumes/UHEROwork/data/rawdata/TOUR_CYFENG%y.xls", {:file_type=>"xls", :start_date=>"2011-01-01", :sheet=>"sheet_num:1", :row=>6, :col=>"repeat:2:13", :frequency=>"M" })/1000|,
Oops, something went wrong.

0 comments on commit f7a61fa

Please sign in to comment.