Sha256: a885d05d52d54b9ae9b65237612b3d33349cb52f2b4362fc9ccad81d0656fd93

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

module GitStats
  module StatsView
    module Charts
      class ActivityCharts
        def initialize(repo)
          @repo = repo
          @activity = repo.activity
        end

        def activity_by_date(author)
          Chart.new do |f|
            f.date_column_chart(
              data: author.activity.by_date,
              title: :commits_by_date.t,
              y_text: :commits.t
            )
          end
        end

        def activity_by_hour(author)
          Chart.new do |f|
            f.simple_column_chart(
              title: :commits_by_hour.t,
              y_text: :commits.t,
              x_text: :hour.t,
              data_x: (0..23),
              data_y: author.activity.by_hour_array
            )
          end
        end

        def activity_by_wday(author)
          Chart.new do |f|
            f.simple_column_chart(
              title: :commits_by_wday.t,
              y_text: :commits.t,
              x_text: :day.t,
              data_x: I18n.t('date.abbr_day_names'),
              data_y: author.activity.by_wday_array
            )
          end
        end

        def activity_by_month(author)
          Chart.new do |f|
            f.simple_column_chart(
              title: :commits_by_month.t,
              y_text: :commits.t,
              x_text: :month.t,
              data_x: I18n.t('date.abbr_month_names')[1..-1],
              data_y: author.activity.by_month_array
            )
          end
        end

        def activity_by_year(author)
          Chart.new do |f|
            f.column_hash_chart(
              title: :commits_by_year.t,
              y_text: :commits.t,
              x_text: :year.t,
              data: author.activity.by_year
            )
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nova_git_stats-2.4.2 lib/git_stats/stats_view/charts/activity_charts.rb
nova_git_stats-2.4.1 lib/git_stats/stats_view/charts/activity_charts.rb
nova_git_stats-2.4.0 lib/git_stats/stats_view/charts/activity_charts.rb
nova_git_stats-2.3.0 lib/git_stats/stats_view/charts/activity_charts.rb