Sha256: 208c3ad17ef982aceafb9b5206c44085a6da9ba209f2e7a43732c967b3a6cdd3

Contents?: true

Size: 973 Bytes

Versions: 3

Compression:

Stored size: 973 Bytes

Contents

# frozen_string_literal: true

module Playbook
  module PbBarGraph
    class BarGraph
      include Playbook::Props
      partial "pb_bar_graph/bar_graph"

      prop :axis_title
      prop :chart_data, type: Playbook::Props::Array,
                        default: []
      prop :orientation, type: Playbook::Props::Enum,
                         values: %w[vertical horizontal],
                         default: "vertical"
      prop :point_start, type: Playbook::Props::Numeric
      prop :subtitle
      prop :title

      def chart_type
        orientation == "horizontal" ? "bar" : "column"
      end

      def chart_options
        {
          id: id,
          chartData: chart_data,
          type: chart_type,
          title: title,
          subtitle: subtitle,
          axisTitle: axis_title,
          pointStart: point_start
        }.to_json.html_safe
      end

      def classname
        generate_classname("pb_bar_graph")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-2.9.8 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-2.9.7 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-2.9.6 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb