Skip to content

Commit 85fcce8

Browse files
committed
Don't set default height
This will fix chart height not overridable by global/default options
1 parent ec60196 commit 85fcce8

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/apex_charts/options_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def build_chart
8383
built[:chart].merge!({
8484
id: @options[:chartId] || @options[:id],
8585
group: @options.delete(:group),
86-
height: @options.delete(:height) { target ? 180 : 400 },
86+
height: @options.delete(:height) { target ? 180 : nil },
8787
width: @options.delete(:width),
8888
stacked: @options.delete(:stacked),
8989
animations: enabled(@options.delete(:animations)),

lib/apex_charts/renderer.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,14 @@ def css_class
8989
end
9090

9191
def height
92-
"#{options[:chart][:height].to_i}px"
92+
chart_height = options.dig(:chart, :height)
93+
if chart_height
94+
"#{chart_height.to_i}px"
95+
end
9396
end
9497

9598
def style
96-
"height: #{height}; #{attributes.delete(:style)}"
99+
"#{height && "height: #{height}; "}#{attributes.delete(:style)}"
97100
end
98101

99102
def window_apex

spec/charts/mixed_charts_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
expect(chart.more_options).to eq({})
4545
expect(chart.instance_variable_get(:@series)).to eq(expected_series)
4646
expect(chart.instance_variable_get(:@options)).to eq(
47-
chart: {
48-
height: 400, id: 'chart-1', type: 'area'
49-
},
47+
chart: {id: 'chart-1', type: 'area'},
5048
defer: false,
5149
div: {id: 'chart-1'},
5250
module: false,

0 commit comments

Comments
 (0)