Sha256: 5948ff0f5d71f3633359f273826a8fb0c7249a8bcef29287813928fea4d36976

Contents?: true

Size: 1.96 KB

Versions: 86

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbGauge
    class Gauge < Playbook::KitBase
      prop :chart_data, type: Playbook::Props::Array,
                        default: [{ name: "Name", value: 0 }]
      prop :style, type: Playbook::Props::Enum,
                   values: %w[solidgauge],
                   default: "solidgauge"
      prop :title, type: Playbook::Props::String, default: ""
      prop :prefix, type: Playbook::Props::String, default: ""
      prop :suffix, type: Playbook::Props::String, default: ""
      prop :height, type: Playbook::Props::String, default: nil
      prop :tooltip_html, default: '<span style="font-weight: bold; color:{point.color};">●</span>
                                      {point.name}: ' + '<b>{point.y}
                                    </b>'
      prop :full_circle, type: Playbook::Props::Boolean, default: false
      prop :show_labels, type: Playbook::Props::Boolean, default: false
      prop :disable_animation, type: Playbook::Props::Boolean, default: false
      prop :min, type: Playbook::Props::Numeric, default: 0
      prop :max, type: Playbook::Props::Numeric, default: 100
      prop :colors, type: Playbook::Props::Array, default: []

      def chart_data_formatted
        chart_data.map { |hash| hash[:y] = hash.delete :value }
        chart_data
      end

      def chart_options
        {
          id: id,
          chartData: chart_data_formatted,
          circumference: full_circle ? [0, 360] : [-100, 100],
          dark: dark ? "dark" : "",
          disableAnimation: disable_animation,
          height: height,
          min: min,
          max: max,
          title: title,
          suffix: suffix,
          prefix: prefix,
          showLabels: show_labels,
          style: style,
          tooltipHtml: tooltip_html,
          type: "gauge",
          colors: colors,
        }.to_json.html_safe
      end

      def classname
        generate_classname("pb_gauge_kit")
      end
    end
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
playbook_ui-11.15.0.pre.alpha.dependencies1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.16.0.pre.alpha.reactupgrade1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.15.0.pre.alpha.table1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.16.0.pre.alpha.pagination.rails1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.15.0 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.14.0 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.13.0.pre.alpha.fontawesome1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.13.0 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.12.1.pre.alpha.passphrase1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.12.1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.13.0.pre.alpha.fileupload1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.12.0 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.11.0.pre.alpha.paginate2 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.11.0.pre.alpha.dialog2 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.11.0.pre.alpha.paginate1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.11.0.pre.alpha.renderer1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.11.0.pre.alpha.dialog1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.11.0 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.10.0.pre.alpha.pre.bold1 app/pb_kits/playbook/pb_gauge/gauge.rb
playbook_ui-11.10.0.pre.alpha.pagination1 app/pb_kits/playbook/pb_gauge/gauge.rb