Class: RailsDataExplorer::Chart::StackedBarChartCategoricalPercent
- Inherits:
-
StackedBarChartCategorical
- Object
- RailsDataExplorer::Chart
- StackedBarChartCategorical
- RailsDataExplorer::Chart::StackedBarChartCategoricalPercent
- Defined in:
- lib/rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb
Overview
Responsibilities:
* Render a stacked bar chart for bivariate analysis of two categorical
data series. Renders percentage distribution of y-data series.
Collaborators:
* DataSet
Instance Attribute Summary
Attributes inherited from RailsDataExplorer::Chart
Instance Method Summary collapse
- #compute_y_axis_label(y_ds_name) ⇒ Object
-
#compute_y_value(data_matrix, x_val, y_val) ⇒ Object
Override this method to change how the y value is computed.
Methods inherited from StackedBarChartCategorical
#compute_chart_attrs, #initialize, #render, #render_nvd3, #render_vega
Methods inherited from RailsDataExplorer::Chart
Constructor Details
This class inherits a constructor from RailsDataExplorer::Chart::StackedBarChartCategorical
Instance Method Details
#compute_y_axis_label(y_ds_name) ⇒ Object
22 23 24 |
# File 'lib/rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb', line 22 def compute_y_axis_label(y_ds_name) "#{ y_ds_name } distribution [%]" end |
#compute_y_value(data_matrix, x_val, y_val) ⇒ Object
Override this method to change how the y value is computed. E.g., to change from absolute values to percentages.
17 18 19 |
# File 'lib/rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb', line 17 def compute_y_value(data_matrix, x_val, y_val) (data_matrix[x_val][y_val] / data_matrix[x_val][:_sum].to_f) * 100 end |