lib/gruff/net.rb
# Hide parts of the graph to fit more data points, or for a different appearance.
Hide parts of the graph to fit more data points, or for a different appearance.
Hide parts of the graph to fit more data points or for a different appearance .
def draw_graph
    store.norm_data.each do |data_row|
      data_row.points.each_with_index do |data_point, index|
        next if data_point.nil?
        rad_pos = index * Math::PI * 2 / column_count
        point_distance = data_point * @radius
        start_x = @center_x + Math.sin(rad_pos) * point_distance
        start_y = @center_y - Math.cos(rad_pos) * point_distance
        next_index = index + 1 < data_row.points.length ? index + 1 : 0
        next_rad_pos = next_index * Math::PI * 2 / column_count
        next_point_distance = data_row.points[next_index] * @radius
        end_x = @center_x + Math.sin(next_rad_pos) * next_point_distance
        end_y = @center_y - Math.cos(next_rad_pos) * next_point_distance
        Gruff::Renderer::Line.new(renderer, color: data_row.color, width: @stroke_width).render(start_x, start_y, end_x, end_y)
        unless @hide_dots
          circle_renderer = Gruff::Renderer::Circle.new(renderer, color: data_row.color, width: @stroke_width)
          circle_renderer.render(start_x, start_y, start_x - @circle_radius, start_y)
        end
      end
    end
  end
def draw_graph store . norm_data . each do | data_row | data_row . points . each_with_index do | data_point , index | next if data_point . nil? rad_pos = index * Math :: PI * 2 / column_count point_distance = data_point * @radius start_x = @center_x + Math . sin ( rad_pos ) * point_distance start_y = @center_y - Math . cos ( rad_pos ) * point_distance next_index = index + 1 < data_row . points . length ? index + 1 : 0 next_rad_pos = next_index * Math :: PI * 2 / column_count next_point_distance = data_row . points [ next_index ] * @radius end_x = @center_x + Math . sin ( next_rad_pos ) * next_point_distance end_y = @center_y - Math . cos ( next_rad_pos ) * next_point_distance Gruff :: Renderer :: Line . new ( renderer , color : data_row . color , width : @stroke_width ) . render ( start_x , start_y , end_x , end_y ) unless @hide_dots circle_renderer = Gruff :: Renderer :: Circle . new ( renderer , color : data_row . color , width : @stroke_width ) circle_renderer . render ( start_x , start_y , start_x - @circle_radius , start_y ) end end end end
Hide parts of the graph to fit more data points, or for a different appearance.
Hide parts of the graph to fit more data points or for a different appearance .