diff --git a/app/assets/javascripts/houston/core/burndown_chart.coffee b/app/assets/javascripts/houston/core/burndown_chart.coffee deleted file mode 100644 index 3acedaf5..00000000 --- a/app/assets/javascripts/houston/core/burndown_chart.coffee +++ /dev/null @@ -1,111 +0,0 @@ -class Houston.BurndownChart - - constructor: -> - @_margin = {top: 40, right: 0, bottom: 24, left: 50} - @_selector = '#graph' - @_height = 260 - @$el = $(@_selector) - @_totalEffort = 0 - @_lines = {} - @_regressions = {} - $(window).resize (e)=> - @render() if e.target is window - - margin: (@_margin)-> @ - height: (@_height)-> @ - selector: (@_selector)-> @$el = $(@_selector); @ - dateFormat: (@_dateFormat)-> @ - days: (@days)-> @ - totalEffort: (@_totalEffort)-> @ - addLine: (slug, data)-> @_lines[slug] = data; @ - addRegression: (slug, data)-> @_regressions[slug] = data; @ - - render: -> - width = @$el.width() || 960 - height = @_height - graphWidth = width - @_margin.left - @_margin.right - graphHeight = height - @_margin.top - @_margin.bottom - - totalEffort = @_totalEffort - unless totalEffort - for slug, data of @_lines - totalEffort = data[0].effort if data[0] and data[0].effort > totalEffort - - formatDate = @_dateFormat || d3.time.format('%A') - - [min, max] = d3.extent(@days) - x = d3.scale.ordinal().rangePoints([0, graphWidth], 0.75).domain(@days) - y = d3.scale.linear().range([graphHeight, 0]).domain([0, totalEffort]) - rx = d3.scale.linear().range([x(min), x(max)]).domain([min, max]) - - xAxis = d3.svg.axis() - .scale(x) - .orient('bottom') - .tickFormat((d)=> formatDate(new Date(d))) - - yAxis = d3.svg.axis() - .scale(y) - .orient('left') - - line = d3.svg.line() - .interpolate('linear') - .x((d)-> x(d.day)) - .y((d)-> y(d.effort)) - - @$el.empty() - svg = d3.select(@_selector).append('svg') - .attr('width', width) - .attr('height', height) - .append('g') - .attr('transform', "translate(#{@_margin.left},#{@_margin.top})") - - svg.append('g') - .attr('class', 'x axis') - .attr('transform', "translate(0,#{graphHeight})") - .call(xAxis) - - svg.append('g') - .attr('class', 'y axis') - .call(yAxis) - .append('text') - .attr('transform', 'rotate(-90)') - .attr('y', -45) - .attr('x', 160 - height) - .attr('dy', '.71em') - .attr('class', 'legend') - .style('text-anchor', 'end') - .text('Points Remaining') - - - - for slug, data of @_regressions - svg.append('line') - .attr('class', "regression regression-#{slug}") - .attr('x1', rx(data.x1)) - .attr('y1', y(data.y1)) - .attr('x2', rx(data.x2)) - .attr('y2', y(data.y2)) - - - - for slug, data of @_lines - svg.append('path') - .attr('class', "line line-#{slug}") - .attr('d', line(data)) - - svg.selectAll("circle.circle-#{slug}") - .data(data) - .enter() - .append('circle') - .attr('class', "circle-#{slug}") - .attr('r', 5) - .attr('cx', (d)-> x(d.day)) - .attr('cy', (d)-> y(d.effort)) - - svg.selectAll(".effort-remaining.effort-#{slug}") - .data(data) - .enter() - .append('text') - .text((d) -> d.effort) - .attr('class', "effort-remaining effort-#{slug}") - .attr('transform', (d)-> "translate(#{x(d.day) + 5.5}, #{y(d.effort) - 10}) rotate(-75)") diff --git a/app/assets/javascripts/houston/core/stacked_area_graph.coffee b/app/assets/javascripts/houston/core/stacked_area_graph.coffee deleted file mode 100644 index b8695639..00000000 --- a/app/assets/javascripts/houston/core/stacked_area_graph.coffee +++ /dev/null @@ -1,113 +0,0 @@ -class Houston.StackedAreaGraph - - constructor: -> - @_margin = {top: 10, right: 10, bottom: 25, left: 50} - @_width = 960 - @_height = 260 - @_data = [] - @_labels = [] - @_lines = [] - @_colors = ['rgb(31, 119, 180)', 'rgb(174, 199, 232)', 'rgb(255, 127, 14)', 'rgb(255, 187, 120)', 'rgb(44, 160, 44)'] - @_axes = ['x', 'y'] - - margin: (@_margin)-> @ - width: (@_width)-> @ - height: (@_height)-> @ - selector: (@_selector)-> @ - data: (@_data)-> @ - labels: (@_labels)-> @ - colors: (@_colors)-> @ - addLine: (line)-> @_lines.push(line); @ - axes: (@_axes)-> @ - domain: (@_domain)-> @ - - - render: -> - graphWidth = @_width - @_margin.left - @_margin.right - graphHeight = @_height - @_margin.top - @_margin.bottom - - formatDate = d3.time.format('%A') - - @x = x = d3.time.scale().range([0, graphWidth]) - @y = y = d3.scale.linear().range([graphHeight, 0]) - - xAxis = d3.svg.axis() - .scale(x) - .orient('bottom') - - yAxis = d3.svg.axis() - .scale(y) - .orient('left') - - color = d3.scale.ordinal().range(@_colors).domain(@_labels) - - area = d3.svg.area() - .interpolate('linear') - .x((d)-> x(d.date)) - .y0((d)-> y(d.y0)) - .y1((d)-> y(d.y0 + d.y)) - - line = d3.svg.area() - .interpolate('linear') - .x((d)-> x(d.date)) - .y((d)-> y(d.y)) - - stack = d3.layout.stack() - .values((d)-> d.values) - - data = stack [0...@_labels.length].map (i)=> - name: @_labels[i] - values: @_data.map (d)-> - date: new Date(d[0]) - y: d[i + 1] - - x.domain d3.extent(data[0].values, (d)-> d.date) - y.domain @_domain or [0, d3.max(data[@_labels.length - 1].values, (d)-> d.y + d.y0)] - - $(@_selector).empty() - svg = d3.select(@_selector).append('svg') - .attr('width', @_width) - .attr('height', @_height) - .append('g') - .attr('transform', "translate(#{@_margin.left},#{@_margin.top})") - - if 'x' in @_axes - svg.append('g') - .attr('class', 'x axis') - .attr('transform', "translate(0,#{graphHeight})") - .call(xAxis) - - if 'y' in @_axes - svg.append('g') - .attr('class', 'y axis') - .call(yAxis) - - section = svg.selectAll('.section').data(data) - - section.enter() - .append('g') - .attr('class', 'section') - - section.append('path') - .attr('class', 'area') - .attr('d', (d)-> area(d.values)) - .style('fill', (d)-> color(d.name)) - - for data in @_lines - point.date = new Date(point.date) for point in data - svg.append('path') - .attr('class', 'line') - .attr('d', line(data)) - .attr('style', 'stroke: #f00; stroke-width: 2px') - - $legend = $('