Class: ReportsKit::Reports::Data::ChartOptions
- Inherits:
-
Object
- Object
- ReportsKit::Reports::Data::ChartOptions
- Defined in:
- lib/reports_kit/reports/data/chart_options.rb
Constant Summary collapse
- DEFAULT_COLORS =
%w( #1f77b4 #aec7e8 #ff7f0e #ffbb78 #2ca02c #98df8a #d62728 #ff9896 #9467bd #c5b0d5 #8c564b #c49c94 #e377c2 #f7b6d2 #7f7f7f #c7c7c7 #bcbd22 #dbdb8d #17becf #9edae5 ).freeze
- DEFAULT_OPTIONS =
{ scales: { xAxes: [{ gridLines: { display: false }, barPercentage: 0.9, categoryPercentage: 0.9 }], yAxes: [{ ticks: { beginAtZero: true } }] }, legend: { labels: { usePointStyle: true } }, maintainAspectRatio: false, tooltips: { xPadding: 8, yPadding: 7 } }.freeze
Instance Attribute Summary collapse
-
#chart_options ⇒ Object
Returns the value of attribute chart_options.
-
#data ⇒ Object
Returns the value of attribute data.
-
#dataset_options ⇒ Object
Returns the value of attribute dataset_options.
-
#inferred_options ⇒ Object
Returns the value of attribute inferred_options.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(data, options:, inferred_options: {}) ⇒ ChartOptions
constructor
A new instance of ChartOptions.
- #perform ⇒ Object
Constructor Details
#initialize(data, options:, inferred_options: {}) ⇒ ChartOptions
56 57 58 59 60 61 62 63 64 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 56 def initialize(data, options:, inferred_options: {}) self.data = data self. = .try(:except, :options) || {} self. = .try(:[], :options) || {} self. = .try(:[], :datasets) self.type = .try(:[], :type) || 'bar' self. = .deep_merge(self.) if .present? end |
Instance Attribute Details
#chart_options ⇒ Object
Returns the value of attribute chart_options.
54 55 56 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 54 def @chart_options end |
#data ⇒ Object
Returns the value of attribute data.
54 55 56 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 54 def data @data end |
#dataset_options ⇒ Object
Returns the value of attribute dataset_options.
54 55 56 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 54 def @dataset_options end |
#inferred_options ⇒ Object
Returns the value of attribute inferred_options.
54 55 56 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 54 def @inferred_options end |
#options ⇒ Object
Returns the value of attribute options.
54 55 56 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 54 def @options end |
#type ⇒ Object
Returns the value of attribute type.
54 55 56 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 54 def type @type end |
Instance Method Details
#perform ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/reports_kit/reports/data/chart_options.rb', line 66 def perform set_colors set_type data end |