Sha256: 9b6eba4f19d0b6cbab2aa1f6f0d435e47a81e206ccad90a201ab0c40d8528789

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

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
      prop :x_axis_categories, type: Playbook::Props::Array,
                                default:[]
      prop :y_axis_min, type: Playbook::Props::Numeric
      prop :y_axis_max, type: Playbook::Props::Numeric


      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,
          xAxisCategories: x_axis_categories,
          yAxisMin: y_axis_min,
          yAxisMax: y_axis_max,
        }.to_json.html_safe
      end

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
playbook_ui-4.15.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.14.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.15.1.alpha1 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.13.1 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.13.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.12.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.11.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.11.0.pre.alpha3 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.11.0.pre.alpha.pre.2 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.10.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.10.0.pre.alpha1 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.9.0.pre.alpha1 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.9.0 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.8.2 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb
playbook_ui-4.8.1 app/pb_kits/playbook/pb_bar_graph/bar_graph.rb